From 11d32d723cbf49f139e866cda193ca374a3b6b80 Mon Sep 17 00:00:00 2001 From: Stephen Haberman Date: Tue, 11 Nov 2008 16:42:37 -0600 Subject: [PATCH] Cleaning up scripts to only include useful stuff. --- scripts/README.markdown | 60 ++--------- scripts/{gc-checkout => checkout} | 0 ...make-gitconfig-branch => create-gitconfig} | 0 scripts/{make-stable-branch => create-stable} | 0 scripts/functions | 11 -- scripts/gc-add | 10 -- scripts/gc-push | 17 --- scripts/gc-remerge | 25 ----- scripts/gc-tattoo | 27 ----- scripts/{gc-pull => pull} | 0 scripts/push | 17 +++ scripts/{gc-refollow => refollow} | 0 ...0-script-checkout.sh => t5000-checkout.sh} | 0 tests/{t5100-script-push.sh => t5100-push.sh} | 10 +- tests/{t5200-script-pull.sh => t5200-pull.sh} | 8 +- tests/t5300-script-add.sh | 39 ------- ...0-script-refollow.sh => t5400-refollow.sh} | 10 +- tests/t5500-script-tattoo.sh | 101 ------------------ 18 files changed, 40 insertions(+), 295 deletions(-) rename scripts/{gc-checkout => checkout} (100%) rename scripts/{make-gitconfig-branch => create-gitconfig} (100%) rename scripts/{make-stable-branch => create-stable} (100%) delete mode 100644 scripts/functions delete mode 100644 scripts/gc-add delete mode 100644 scripts/gc-push delete mode 100644 scripts/gc-remerge delete mode 100644 scripts/gc-tattoo rename scripts/{gc-pull => pull} (100%) create mode 100644 scripts/push rename scripts/{gc-refollow => refollow} (100%) rename tests/{t5000-script-checkout.sh => t5000-checkout.sh} (100%) rename tests/{t5100-script-push.sh => t5100-push.sh} (82%) rename tests/{t5200-script-pull.sh => t5200-pull.sh} (95%) delete mode 100644 tests/t5300-script-add.sh rename tests/{t5400-script-refollow.sh => t5400-refollow.sh} (94%) delete mode 100644 tests/t5500-script-tattoo.sh diff --git a/scripts/README.markdown b/scripts/README.markdown index c00bec2..8630c70 100644 --- a/scripts/README.markdown +++ b/scripts/README.markdown @@ -1,66 +1,24 @@ -gc-add -====== +checkout +======== -`gc-add ...` - -* If no arguments, adds all new, adds all changed, removes all removed -* If arguments, passes through to `git add` - -gc-checkout -=========== - -`gc-checkout ` +`checkout ` * If `branch` already exists locally, check it out * If `branch` already exists remotely, check it out * If `branch` is new, create it locally and remotely -gc-commit -========= - -`gc-commit` - -* Passes through to `git commit` - -gc-diff -======= - -`gc-diff` - -* Passes through to `git diff` - -gc-pull -======= +pull +==== -`gc-pull` +`pull` * Passes through to `git pull` but with `--rebase` flag -gc-push -======= +push +==== -`gc-push` +`push` * Pushes only the current branch to `origin` -gc-remerge -========== - -* Work in progress, not done - -gc-rm -===== - -`gc-rm` - -* Passes through to `git rm` - -gc-status -========= - -`gc-status` - -* Passes through to `git status` - - diff --git a/scripts/gc-checkout b/scripts/checkout similarity index 100% rename from scripts/gc-checkout rename to scripts/checkout diff --git a/scripts/make-gitconfig-branch b/scripts/create-gitconfig similarity index 100% rename from scripts/make-gitconfig-branch rename to scripts/create-gitconfig diff --git a/scripts/make-stable-branch b/scripts/create-stable similarity index 100% rename from scripts/make-stable-branch rename to scripts/create-stable diff --git a/scripts/functions b/scripts/functions deleted file mode 100644 index b665bcb..0000000 --- a/scripts/functions +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -function set_branch_name() { - branch_name=$(git symbolic-ref --quiet HEAD) - if [[ $? -ne 0 ]] ; then - branch_name="" - else - branch_name=${branch_name/refs\/heads\//} - fi -} - diff --git a/scripts/gc-add b/scripts/gc-add deleted file mode 100644 index 71a13b7..0000000 --- a/scripts/gc-add +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -if [[ $# -eq 0 ]] ; then - git ls-files -d | xargs -r git rm - git ls-files -m | xargs -r git add - git ls-files -o --exclude-standard | xargs -r git add -else - git add $* -fi - diff --git a/scripts/gc-push b/scripts/gc-push deleted file mode 100644 index 26ffa7b..0000000 --- a/scripts/gc-push +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - -. $(dirname $0)/functions - -set_branch_name -if [ "$branch_name" == "" ] ; then - echo "Not on a branch" - exit 1 -fi - -git push origin $branch_name -if [[ $? -ne 0 ]] ; then - exit $? -fi - -# ...tags... - diff --git a/scripts/gc-remerge b/scripts/gc-remerge deleted file mode 100644 index 99d868b..0000000 --- a/scripts/gc-remerge +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh - -git rev-list --first-parent "origin/stable..HEAD" | while read commit ; do - number_of_parents=$(git rev-list -n 1 --parents $commit | sed 's/ /\n/g' | grep -v $commit | wc -l) - if [[ $number_of_parents > 1 ]] ; then - # For each parent - git rev-list --no-walk --parents $commit | sed 's/ /\n/g' | grep -v $commit | while read parent ; do - echo "merge=$commit parent=$parent" - # Does this parent have any children besides us? - # - # List the parents of all branch commits (after stable/parent), find - # those that include our parent, get their sha1, remove our merge - git rev-list --parents --branches ^stable "^$parent" | grep $parent | gawk '{print $1}' | grep -v $commit | while read child ; do - echo "child $child" - git rev-list "$child" "^$commit" - done - # Find any commits in the parent (and another branch) but not us--that means we need it - # number_missing=$(git rev-list "$parent" --branches "^HEAD" | wc -l) - # if [[ $number_missing > 0 ]] ; then - # git rev-list "$parent" --branches "^HEAD" | xargs git name-rev - # fi - done - fi -done - diff --git a/scripts/gc-tattoo b/scripts/gc-tattoo deleted file mode 100644 index f1bd3a1..0000000 --- a/scripts/gc-tattoo +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh - -. $(dirname $0)/functions - -git fetch - -set_branch_name - -echo "branch_name='$branch_name'" - -if [ "$branch_name" == "" ] ; then - echo "Not on a branch (for $branch_name)" - exit 1 -fi - -describe=$(git describe --tags --always HEAD) -case "$describe" in - r/*) - describe=${describe##r\/} - echo "$branch_name-$describe" - ;; - *) - echo "No commit number tag found" - exit 1 - ;; -esac - diff --git a/scripts/gc-pull b/scripts/pull similarity index 100% rename from scripts/gc-pull rename to scripts/pull diff --git a/scripts/push b/scripts/push new file mode 100644 index 0000000..7583ce6 --- /dev/null +++ b/scripts/push @@ -0,0 +1,17 @@ +#!/bin/sh + +branch_name=$(git symbolic-ref --quiet HEAD) +if [[ $? -ne 0 ]] ; then + echo "Not on a branch" + exit 1 +fi + +branch_name=${branch_name/refs\/heads\//} + +git push origin $branch_name +if [[ $? -ne 0 ]] ; then + exit $? +fi + +# ...tags... + diff --git a/scripts/gc-refollow b/scripts/refollow similarity index 100% rename from scripts/gc-refollow rename to scripts/refollow diff --git a/tests/t5000-script-checkout.sh b/tests/t5000-checkout.sh similarity index 100% rename from tests/t5000-script-checkout.sh rename to tests/t5000-checkout.sh diff --git a/tests/t5100-script-push.sh b/tests/t5100-push.sh similarity index 82% rename from tests/t5100-script-push.sh rename to tests/t5100-push.sh index 7ca75e8..587e036 100644 --- a/tests/t5100-script-push.sh +++ b/tests/t5100-push.sh @@ -13,8 +13,8 @@ test_expect_success 'setup' ' git clone ./. server && rm -fr server/.git/hooks && git remote add origin ./server && - git config --add branch.master.remote origin && - git config --add branch.master.merge refs/heads/master && + git config branch.master.remote origin && + git config branch.master.merge refs/heads/master && git fetch && git checkout -b stable && @@ -22,17 +22,17 @@ test_expect_success 'setup' ' ' test_expect_success 'push only does one branch' ' - gc-checkout topic1 && + checkout topic1 && echo "$test_name" >a && git commit -a -m "move topic1" && git rev-parse HEAD >head.topic1 && - gc-checkout topic2 && + checkout topic2 && echo "$test_name" >a && git commit -a -m "move topic2" && git rev-parse HEAD >head.topic2 && - gc-push && + push && git rev-parse origin/topic2 >head.origin.topic2 && git rev-parse origin/topic1 >head.origin.topic1 && diff --git a/tests/t5200-script-pull.sh b/tests/t5200-pull.sh similarity index 95% rename from tests/t5200-script-pull.sh rename to tests/t5200-pull.sh index 39e660d..6fdfb07 100644 --- a/tests/t5200-script-pull.sh +++ b/tests/t5200-pull.sh @@ -18,7 +18,7 @@ test_expect_success 'setup' ' ' test_expect_success 'pull does a rebase' ' - gc-checkout topic1 && + checkout topic1 && echo "$test_name" >a.topic1 && git add a.topic1 && git commit -m "move topic1" && @@ -31,12 +31,12 @@ test_expect_success 'pull does a rebase' ' cd .. && # Only one parent - gc-pull && + pull && test 1 = $(git cat-file commit $(git rev-parse HEAD) | grep parent | wc -l) ' test_expect_success 'pull does a rebase but does not fuck up merges' ' - gc-checkout topic2 && + checkout topic2 && echo "$test_name on topic2" >a.topic2 && git add a.topic2 && git commit -a -m "create topic2" && @@ -62,7 +62,7 @@ test_expect_success 'pull does a rebase but does not fuck up merges' ' # Merge stable locally too--should conflict git checkout topic2 && - gc-pull && + pull && test 1 = $(git rev-list --all --pretty=oneline | grep "replayed" | wc -l) ' diff --git a/tests/t5300-script-add.sh b/tests/t5300-script-add.sh deleted file mode 100644 index 76fdca2..0000000 --- a/tests/t5300-script-add.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh - -test_description='script add' - -. ./test-lib.sh - -export PATH=$PATH:../../scripts - -test_expect_success 'setup' ' - echo "setup" >a && - git add a && - git commit -m "setup" && - git clone ./. server && - rm -fr server/.git/hooks && - git remote add origin ./server && - git checkout -b stable && - git push origin stable -' - -test_expect_success 'add picks up new files' ' - echo "$test_name" >a.new && - gc-add && - git commit -m "add" -' - -test_expect_success 'add picks up changed files' ' - echo "$test_name" >a.new && - gc-add && - git commit -m "change" -' - -test_expect_success 'add picks up removed files' ' - rm a.new && - gc-add && - git commit -m "remove" -' - -test_done - diff --git a/tests/t5400-script-refollow.sh b/tests/t5400-refollow.sh similarity index 94% rename from tests/t5400-script-refollow.sh rename to tests/t5400-refollow.sh index 911f177..70e90d4 100644 --- a/tests/t5400-script-refollow.sh +++ b/tests/t5400-refollow.sh @@ -42,7 +42,7 @@ test_expect_success 'make topic1 then move stable' ' test_expect_success 'refollow fails with dirty index' ' echo "$test_name" >a && git add a && - ! gc-refollow 2>refollow.err && + ! refollow 2>refollow.err && cat refollow.err | grep "refusing to refollow--your index is not clean" && ! git reset a ' @@ -51,7 +51,7 @@ test_expect_success 'refollow topic1 onto stable' ' echo "$test_name" >a && git commit -a -m "move stable" && git push origin stable && - gc-refollow >refollow.out && + refollow >refollow.out && cat refollow.out | grep "Merging stable into topic1...succeeded" git checkout topic1 && @@ -62,7 +62,7 @@ test_expect_success 'refollow topic1 onto stable' ' test_expect_success 'refollow does not double tap' ' # Still on topic1 head=$(git rev-parse HEAD) && - gc-refollow && + refollow && git pull origin topic1 && git rev-parse HEAD | grep $head ' @@ -76,7 +76,7 @@ test_expect_success 'refollow respects excused' ' git commit -a -m "move stable" && git push origin stable && - gc-refollow && + refollow && git checkout gitconfig && git pull origin gitconfig && @@ -94,7 +94,7 @@ test_expect_success 'refollow continues on conflict' ' git commit -a -m "move stable" && git push origin stable && - gc-refollow > refollow.out && + refollow > refollow.out && cat refollow.out | grep "Merging stable into topic1...succeeded" cat refollow.out | grep "Merging stable into topic2...failed merge" ' diff --git a/tests/t5500-script-tattoo.sh b/tests/t5500-script-tattoo.sh deleted file mode 100644 index 561b4bf..0000000 --- a/tests/t5500-script-tattoo.sh +++ /dev/null @@ -1,101 +0,0 @@ -#!/bin/sh - -test_description='script tattoo' - -. ./test-lib.sh - -export PATH=$PATH:../../scripts - -test_expect_success 'setup' ' - echo "setup" >a && - git add a && - git commit -m "setup" && - git clone ./. server && - rm -fr server/.git/hooks && - git remote add origin ./server && - git checkout -b stable && - git push origin stable -' - -# tattoo makes assumptions based on the update stable hook sanity checks -install_update_hook 'update-stable' -install_post_receive_hook 'post-receive-assign-commit-numbers' - -test_expect_success 'tattoo of unpublished commit fails' ' - gc-tattoo | grep "No commit number tag found" -' - -test_done - -test_expect_success 'tattoo 1' ' - git checkout -b topic1 && - echo "$test_name" >a.topic1 && - git add a.topic1 && - git commit -a -m "move topic1-1" && - git push origin topic1 && - gc-tattoo | grep topic1-1 -' - -test_expect_success 'tattoo 2' ' - echo "$test_name" >a && - git commit -a -m "make topic1-2" && - git push origin topic1 && - gc-tattoo | grep topic1-2 -' - -test_expect_success 'merge topic2 into topic1 as tattoo 3' ' - git checkout -b topic2 stable && - echo "$test_name" >a.topic2 && - git add a.topic2 && - git commit -m "make topic2-1" && - git push origin topic2 && - gc-tattoo | grep topic2-1 && - - git checkout topic1 && - git merge topic2 && - git push origin topic1 && - gc-tattoo | grep topic1-3 && - - git checkout topic2 && - gc-tattoo | grep topic2-1 -' - -test_expect_success 'fails if not pushed' ' - git checkout topic1 && - echo "$test_name" >a && - git commit -a -m "make topic1-4" && - head=$(git rev-parse HEAD) && - gc-tattoo | grep "$head has not been pushed" && - git push origin topic1 && - gc-tattoo | grep topic1-4 -' - -test_expect_success 'stable fails if not pushed' ' - git checkout stable && - git merge --no-ff topic1 && - head=$(git rev-parse HEAD) && - gc-tattoo | grep "$head has not been pushed" && - git push && - gc-tattoo | grep "stable-$head" -' - -test_expect_success 'stable without a tag' ' - git checkout stable && - head=$(git rev-parse HEAD) && - gc-tattoo | grep "stable-$head" -' - -test_expect_success 'stable with a tag' ' - git tag -m "1.0" 1.0 && - gc-tattoo | grep "1.0" -' - -test_expect_success 'use origin stable not local' ' - git checkout origin/stable && - git branch -d stable && - git checkout topic2 && - gc-tattoo | grep "topic2-1" -' - -test_done - -- 2.39.5