From 9e7024c2798f429bcb76c5bb7a2131e1d2ae3ff4 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 29 Jan 2013 14:33:14 -0500 Subject: Initial versions of pbs-package-* commands --- pbs-package-commit | 41 +++++++++++++++++++++++++++++++++++++++++ pbs-package-fork | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ pbs-package-merge | 39 +++++++++++++++++++++++++++++++++++++++ pbs-package-new | 38 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 171 insertions(+) create mode 100755 pbs-package-commit create mode 100755 pbs-package-fork create mode 100755 pbs-package-merge create mode 100755 pbs-package-new diff --git a/pbs-package-commit b/pbs-package-commit new file mode 100755 index 0000000..54e944f --- /dev/null +++ b/pbs-package-commit @@ -0,0 +1,41 @@ +#!/bin/bash -euE + +. $(which libremessages) + +cmd=${0##*/} +usage() { + echo "Usage: $cmd [git-commit OPTIONS]" + echo 'Commits to a package (run from the package directory).' + echo '' + echo 'This is the same as `git commit`, but cascades up out of the' + echo 'submodule.' + echo '' + echo 'Options:' + echo ' -h Show this message' + echo '' + echo ' ====================== `git commit` usage ======================' + echo '' + git commit -h +} + +main() { + if in_array '-h' "$@"; then + usage + return 0 + fi + + if [[ ! -f .git ]]; then + error "Must be in a package directory" + return 1 + fi + + git commit "$@" + git push + local msg="$(git log -n1 --pretty=format:%B)" + local dir="$(pwd)" + cd .. + git add "${dir##*/}" + git commit -m "$msg" +} + +main "$@" 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 "$@" diff --git a/pbs-package-merge b/pbs-package-merge new file mode 100755 index 0000000..b30c26d --- /dev/null +++ b/pbs-package-merge @@ -0,0 +1,39 @@ +#!/bin/bash -euE + +. $(which libremessages) + +cmd=${0##*/} +usage() { + echo "Usage: $cmd [OPTIONS]" + echo 'Fetches and merges changes from an upstream package' + echo '' + echo 'The repository and refspec that are merged are controlled by the' + echo 'file `pbstrack`.' + 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 [[ $# > 0 ]]; then + usage + return 1 + fi + + if [[ ! -f .git ]]; then + error "Must be in a package directory" + fi + if [[ ! -r pbstrack ]]; then + error "No pbstrack file found, don't know where to pull from" + fi + git pull $(cat pbstrack) +} + +main "$@" diff --git a/pbs-package-new b/pbs-package-new new file mode 100755 index 0000000..2787a07 --- /dev/null +++ b/pbs-package-new @@ -0,0 +1,38 @@ +#!/bin/bash -euE + +. $(which libremessages) + +cmd=${0##*/} +usage() { + echo "Usage: $cmd [OPTIONS] REPO/PACKAGE" + echo 'Fetches and merges changes from an upstream package' + echo '' + echo 'The repository and refspec that are merged are controlled by the' + echo 'file `pbstrack`.' + 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 [[ $# > 0 ]]; then + usage + return 1 + fi + + local dest=$1 + local package="${dest##*/}" + + git submodule add ./ "${dest}" + cd "${dest}" + git checkout --orphan "packages/${package}" +} + +main "$@" -- cgit v1.2.3-54-g00ecf