summaryrefslogtreecommitdiff
path: root/pbs-package-fork
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2013-01-29 14:33:14 -0500
committerLuke Shumaker <LukeShu@sbcglobal.net>2013-01-29 14:33:14 -0500
commit9e7024c2798f429bcb76c5bb7a2131e1d2ae3ff4 (patch)
tree27a753c2894282b512fa39dd26c53958310cfd23 /pbs-package-fork
parent694a9d979213280ad503a53c64eb195c5277b63e (diff)
Initial versions of pbs-package-* commands
Diffstat (limited to 'pbs-package-fork')
-rwxr-xr-xpbs-package-fork53
1 files changed, 53 insertions, 0 deletions
diff --git a/pbs-package-fork b/pbs-package-fork
new file mode 100755
index 0000000..c906493
--- /dev/null
+++ b/pbs-package-fork
@@ -0,0 +1,53 @@
+#!/bin/bash -euE
+
+. $(which libremessages)
+
+cmd=${0##*/}
+usage() {
+ echo "Usage: $cmd [OPTIONS] REPOSITORY OLDPACKAGE REPO/NEWPACKAGE"
+ echo 'Forks a package.'
+ echo ''
+ echo 'To fork a local package, (for example, making `pcr/emacs-lucid`'
+ echo 'from `pcr/emacs-lucid`), the repository is the local filesystem,'
+ echo 'so use `./`'
+ echo ''
+ echo ' $cmd ./ emacs pcr/emacs-lucid'
+ echo ''
+ echo 'This forks the branch `packages/emacs` into a new branch'
+ echo '`packages/emacs-lucid`, creates the file `pbstrack` in it, and'
+ echo 'checks it out as a git submodule to the directory '
+ echo '`prc/emacs-lucid`.'
+ echo ''
+ echo 'Use `pbs-merge` to pull updates from the original package.'
+ echo ''
+ echo 'Options:'
+ echo ' -h Show this message'
+}
+
+main() {
+ while getopts 'h' arg; do
+ case $arg in
+ h) usage; return 0;;
+ *) usage; return 1;;
+ esac
+ done
+ shift $(($OPTIND - 1))
+ if [[ $# != 3 ]]; then
+ usage
+ return 1
+ fi
+
+ local repository=$1
+ local oldpackage=$2
+ local dest=$3
+ local newpackage="${dest##*/}"
+
+ git submodule add -b "packages/${oldpackage}" "${repository}" "${dest}"
+ cd "${dest}"
+ git checkout -b "packages/${newpackage}"
+ printf '%s packages/%s\n' "${repository}" "${oldpackage}" > pbstrack
+ git add pbstrack
+ git commit -m 'Fork package from ${repository} ${oldpackage} to ${dest}'
+}
+
+main "$@"