diff options
author | Daniel Silverstone <daniel.silverstone@codethink.co.uk> | 2012-05-25 15:26:25 +0100 |
---|---|---|
committer | Daniel Silverstone <daniel.silverstone@codethink.co.uk> | 2012-05-25 15:26:25 +0100 |
commit | 0e60a1538e05d331d2f544ca63c6f7cb318824de (patch) | |
tree | 85d6f49f34fe1e381645e4a01687dbfaaaf108ed | |
parent | 9ab6fc84d1bf0f90a8cbd3d0d8accb93a171b23b (diff) | |
download | git-pull-request-0e60a1538e05d331d2f544ca63c6f7cb318824de.tar.bz2 |
-rwxr-xr-x | git-pull-request.sh | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/git-pull-request.sh b/git-pull-request.sh index f394230..6531e11 100755 --- a/git-pull-request.sh +++ b/git-pull-request.sh @@ -733,6 +733,47 @@ EOF rm -f "${PR_INDEX_FILE}" } +cmd_archive () { + local PR + PR="$1" + if test "x$PR" = "x"; then + echo >&2 "Please specify a pull-request name to archive." + exit 1 + fi + local COMMIT BRANCH + while read _COMMIT _BRANCH; do + COMMIT="${_COMMIT}" + BRANCH="${_BRANCH}" + done <<<$(rgit show-ref "$PR"__meta) + if test "x$COMMIT" = "x"; then + echo >&2 "Pull request '${PR}' not found." + exit 1 + fi + + if sane_grep -q -F /archive/ <<<"${BRANCH}"; then + echo >&2 "Pull request '${PR}' is already archived" + exit 1 + fi + + load_meta_from "${COMMIT}" + case "${METADATA[STATE]}" in + merged|rejected) + ;; + *) + echo >&2 "Pull request '${PR}' is not merged or rejected" + exit 1 + ;; + esac + + rgit update-ref -m "Archive '${PR}'" \ + "refs/pull-requests/archive/${PR}__meta" "${COMMIT}" + rgit update-ref -m "Archive '${PR}'" -d \ + "refs/pull-requests/heads/${PR}__meta" + rgit update-ref -m "Archive '${PR}'" -d \ + "refs/pull-requests/heads/${PR}__anchor" + exit 0 +} + ############################################################################# ## Command invocation ##################################################### ############################################################################# |