]> git.droids-corp.org - git-central.git/commitdiff
Drop dashes for post-receive-commitnumbers and post-receive-gitconfig.
authorStephen Haberman <stephen@exigencecorp.com>
Wed, 12 Nov 2008 06:17:52 +0000 (00:17 -0600)
committerStephen Haberman <stephen@exigencecorp.com>
Wed, 12 Nov 2008 06:17:52 +0000 (00:17 -0600)
13 files changed:
README.markdown
server/post-receive-assign-commit-numbers [deleted file]
server/post-receive-commitnumbers [new file with mode: 0644]
server/post-receive-git-config [deleted file]
server/post-receive-gitconfig [new file with mode: 0644]
tests/t2800-post-receive-git-config.sh [deleted file]
tests/t2800-post-receive-gitconfig.sh [new file with mode: 0644]
tests/t2801-post-receive-git-config-hooks.sh [deleted file]
tests/t2801-post-receive-gitconfig-hooks.sh [new file with mode: 0644]
tests/t3001-post-receive-trac-with-commit-numbers.sh [deleted file]
tests/t3001-post-receive-trac-with-commitnumbers.sh [new file with mode: 0644]
tests/t3200-post-receive-assign-commit-numbers.sh [deleted file]
tests/t3200-post-receive-commitnumbers.sh [new file with mode: 0644]

index d42a5a436d76e37e98b6e9129816751255abcd4c..86436a92467f416bbf4aa39635f245b868d80322 100644 (file)
@@ -20,7 +20,7 @@ Server-side Hooks
 
 See the individual scripts for documentation, but an overview:
 
-* [post-receive-assign-commitnumbers][1]: makes Subversion-like monotonically increasing commit numbers for every commit
+* [post-receive-commitnumbers][1]: makes Subversion-like monotonically increasing commit numbers for every commit
 * [post-receive-email][2]: contrib email script with customizations for stuff like combined diffs
 * [post-receive-gitconfig][3]: auto-updates the git config+hooks on the server when updated in the repo
 * [post-receive-hudson][4]: auto-creates new jobs in Hudson when branches in git are created
@@ -31,7 +31,7 @@ See the individual scripts for documentation, but an overview:
 * [update-lock-check][9]: enforces locked/preserved branches
 * [update-stable][10]: enforces proper movement of stable
 
-[1]: master/server/post-receive-assign-commitnumbers
+[1]: master/server/post-receive-commitnumbers
 [2]: master/server/post-receive-email
 [3]: master/server/post-receive-gitconfig
 [4]: master/server/post-receive-hudson
diff --git a/server/post-receive-assign-commit-numbers b/server/post-receive-assign-commit-numbers
deleted file mode 100644 (file)
index 364618b..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/sh
-
-. $(dirname $0)/functions
-
-while read oldrev newrev refname ; do
-       set_new_commits
-       echo "$new_commits" | git rev-list --reverse --stdin | while read commit ; do
-               if [[ $(grep "$commit" "$GIT_DIR/commitnumbers" 2>/dev/null) == "" ]] ; then
-                       with_lock "$GIT_DIR/commitnumbers.lock" 'echo "$commit $refname" >> "$GIT_DIR/commitnumbers"'
-                       number=$(grep --max-count=1 --line-number "$commit" "$GIT_DIR/commitnumbers" | grep -oP "^\d+(?=:)")
-                       git tag "r/$number" "$commit"
-               fi
-       done
-done
-
diff --git a/server/post-receive-commitnumbers b/server/post-receive-commitnumbers
new file mode 100644 (file)
index 0000000..364618b
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+. $(dirname $0)/functions
+
+while read oldrev newrev refname ; do
+       set_new_commits
+       echo "$new_commits" | git rev-list --reverse --stdin | while read commit ; do
+               if [[ $(grep "$commit" "$GIT_DIR/commitnumbers" 2>/dev/null) == "" ]] ; then
+                       with_lock "$GIT_DIR/commitnumbers.lock" 'echo "$commit $refname" >> "$GIT_DIR/commitnumbers"'
+                       number=$(grep --max-count=1 --line-number "$commit" "$GIT_DIR/commitnumbers" | grep -oP "^\d+(?=:)")
+                       git tag "r/$number" "$commit"
+               fi
+       done
+done
+
diff --git a/server/post-receive-git-config b/server/post-receive-git-config
deleted file mode 100644 (file)
index c80322a..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/sh
-
-while read oldrev newrev refname ; do
-       if [ "$refname" == "refs/heads/gitconfig" ] ; then
-               config_hash=$(git ls-tree $newrev | grep config | grep -oP '\w{40}')
-               if [[ "$config_hash" != "" ]] ; then
-                       git cat-file blob "$config_hash" | while read line ; do
-                               key="${line%=*}"
-                               value="${line#*=}"
-                               git config "${key}" "${value}"
-                       done
-               fi
-
-               hooks_hash=$(git ls-tree $newrev | grep hooks | grep -oP '\w{40}')
-               if [[ "$hooks_hash" != "" ]] ; then
-                       git ls-tree "$hooks_hash" | while read mode type file_hash file_name ; do
-                               echo "Installing $file_name"
-                               git cat-file blob "$file_hash" > "hooks/$file_name"
-                       done
-               fi
-       fi
-done
-
diff --git a/server/post-receive-gitconfig b/server/post-receive-gitconfig
new file mode 100644 (file)
index 0000000..c80322a
--- /dev/null
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+while read oldrev newrev refname ; do
+       if [ "$refname" == "refs/heads/gitconfig" ] ; then
+               config_hash=$(git ls-tree $newrev | grep config | grep -oP '\w{40}')
+               if [[ "$config_hash" != "" ]] ; then
+                       git cat-file blob "$config_hash" | while read line ; do
+                               key="${line%=*}"
+                               value="${line#*=}"
+                               git config "${key}" "${value}"
+                       done
+               fi
+
+               hooks_hash=$(git ls-tree $newrev | grep hooks | grep -oP '\w{40}')
+               if [[ "$hooks_hash" != "" ]] ; then
+                       git ls-tree "$hooks_hash" | while read mode type file_hash file_name ; do
+                               echo "Installing $file_name"
+                               git cat-file blob "$file_hash" > "hooks/$file_name"
+                       done
+               fi
+       fi
+done
+
diff --git a/tests/t2800-post-receive-git-config.sh b/tests/t2800-post-receive-git-config.sh
deleted file mode 100644 (file)
index 63d1f98..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/bin/sh
-
-test_description='server update git config'
-
-. ./test-lib.sh
-
-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 config --add branch.master.remote origin &&
-       git config --add branch.master.merge refs/heads/master &&
-       git fetch
-'
-
-install_post_receive_hook 'post-receive-git-config'
-
-test_expect_success 'pushing initial value works' '
-       cd server &&
-       ! git config --list | grep foo &&
-       cd .. &&
-
-       ../../scripts/make-gitconfig-branch &&
-       git checkout gitconfig &&
-       echo "foo.foo=bar" > config &&
-       git commit -a -m "Set foo.foo=bar."
-       git push origin gitconfig
-
-       cd server &&
-       git config --list | grep foo &&
-       cd ..
-'
-
-test_done
-
diff --git a/tests/t2800-post-receive-gitconfig.sh b/tests/t2800-post-receive-gitconfig.sh
new file mode 100644 (file)
index 0000000..75eae1f
--- /dev/null
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+test_description='server update git config'
+
+. ./test-lib.sh
+
+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 config branch.master.remote origin &&
+       git config branch.master.merge refs/heads/master &&
+       git fetch
+'
+
+install_post_receive_hook 'post-receive-gitconfig'
+
+test_expect_success 'pushing initial value works' '
+       cd server &&
+       ! git config --list | grep foo &&
+       cd .. &&
+
+       ../../scripts/create-gitconfig &&
+       git checkout gitconfig &&
+       echo "foo.foo=bar" > config &&
+       git commit -a -m "Set foo.foo=bar."
+       git push origin gitconfig
+
+       cd server &&
+       git config --list | grep foo &&
+       cd ..
+'
+
+test_done
+
diff --git a/tests/t2801-post-receive-git-config-hooks.sh b/tests/t2801-post-receive-git-config-hooks.sh
deleted file mode 100644 (file)
index e0c0057..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-#!/bin/sh
-
-test_description='server update git config'
-
-. ./test-lib.sh
-
-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
-'
-
-install_post_receive_hook 'post-receive-git-config'
-
-test_expect_success 'adding hook' '
-       ls server/.git/hooks | grep post-receive &&
-       ../../scripts/make-gitconfig-branch &&
-       git checkout gitconfig &&
-
-       mkdir hooks &&
-       cd hooks &&
-       echo "#!/bin/sh" > post-receive &&
-       echo "../../../../server/post-receive-git-config" >> post-receive &&
-       echo "echo barbar" >> post-receive &&
-       echo "#!/bin/sh" > update  &&
-       echo "echo foofoo" >> update &&
-       git add post-receive &&
-       git add update &&
-       git commit -m "added post-receive and update" &&
-       git push origin gitconfig &&
-       cd .. &&
-
-       cat server/.git/hooks/post-receive | grep barbar &&
-       cat server/.git/hooks/update | grep foofoo
-'
-
-test_expect_success 'changing hook' '
-       echo "#!/bin/sh" > hooks/update  &&
-       echo "echo lala" >> hooks/update &&
-       git commit -a -m "changed update" &&
-       git push origin gitconfig &&
-
-       cat server/.git/hooks/post-receive | grep barbar &&
-       ! cat server/.git/hooks/update | grep barbar &&
-       cat server/.git/hooks/update | grep lala
-'
-
-test_expect_success 'removing hook does not work' '
-       git rm hooks/update &&
-       git commit -m "removed update" &&
-       git push origin gitconfig &&
-
-       ls server/.git/hooks | grep post-receive
-       ls server/.git/hooks | grep update
-'
-
-test_done
-
diff --git a/tests/t2801-post-receive-gitconfig-hooks.sh b/tests/t2801-post-receive-gitconfig-hooks.sh
new file mode 100644 (file)
index 0000000..464f262
--- /dev/null
@@ -0,0 +1,61 @@
+#!/bin/sh
+
+test_description='server update git config'
+
+. ./test-lib.sh
+
+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
+'
+
+install_post_receive_hook 'post-receive-gitconfig'
+
+test_expect_success 'adding hook' '
+       ls server/.git/hooks | grep post-receive &&
+       ../../scripts/create-gitconfig &&
+       git checkout gitconfig &&
+
+       mkdir hooks &&
+       cd hooks &&
+       echo "#!/bin/sh" > post-receive &&
+       echo "../../../../server/post-receive-gitconfig" >> post-receive &&
+       echo "echo barbar" >> post-receive &&
+       echo "#!/bin/sh" > update  &&
+       echo "echo foofoo" >> update &&
+       git add post-receive &&
+       git add update &&
+       git commit -m "added post-receive and update" &&
+       git push origin gitconfig &&
+       cd .. &&
+
+       cat server/.git/hooks/post-receive | grep barbar &&
+       cat server/.git/hooks/update | grep foofoo
+'
+
+test_expect_success 'changing hook' '
+       echo "#!/bin/sh" > hooks/update  &&
+       echo "echo lala" >> hooks/update &&
+       git commit -a -m "changed update" &&
+       git push origin gitconfig &&
+
+       cat server/.git/hooks/post-receive | grep barbar &&
+       ! cat server/.git/hooks/update | grep barbar &&
+       cat server/.git/hooks/update | grep lala
+'
+
+test_expect_success 'removing hook does not work' '
+       git rm hooks/update &&
+       git commit -m "removed update" &&
+       git push origin gitconfig &&
+
+       ls server/.git/hooks | grep post-receive
+       ls server/.git/hooks | grep update
+'
+
+test_done
+
diff --git a/tests/t3001-post-receive-trac-with-commit-numbers.sh b/tests/t3001-post-receive-trac-with-commit-numbers.sh
deleted file mode 100644 (file)
index b4e5d65..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-#!/bin/sh
-
-test_description='server post receive trac with commit numbers'
-
-. ./test-lib.sh
-
-export PYTHON=echo
-export TRAC_ENV=/foo/trac
-
-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
-'
-
-install_post_receive_hook 'post-receive-assign-commit-numbers' 'post-receive-trac'
-
-test_expect_success 'new branch' '
-       git checkout -b topic1 master &&
-       echo "$test_name" >a &&
-       git commit -a -m "changed on topic1" &&
-       new_commit_hash=$(git rev-parse HEAD) &&
-       git push origin topic1 2>push.err &&
-       cat push.err | grep "/foo/trac topic1 $new_commit_hash r/1 $new_commit_hash"
-'
-
-test_expect_success 'new branch with already existing does not double tap' '
-       git checkout -b topic2 topic1 &&
-       existing_commit_hash=$(git rev-parse HEAD) &&
-       git push origin topic2 2>push.err &&
-       ! cat push.err | grep "/foo/trac topic2"
-'
-
-test_expect_success 'update branch' '
-       # Already on topic2
-       echo "$test_name" >a &&
-       git commit -a -m "changed on topic2" &&
-       new_commit_hash=$(git rev-parse HEAD) &&
-       git push origin topic2 2>push.err &&
-       cat push.err | grep "/foo/trac topic2 $new_commit_hash r/2 $new_commit_hash"
-'
-
-test_expect_success 'update branch to an already published commit does not double tap' '
-       # Make topic1 catch up to topic2, which will be a fast forward that does need re-tapped
-       git checkout topic2 &&
-       topic2_hash=$(git rev-parse HEAD) &&
-
-       git checkout topic1 &&
-       git merge topic2 &&
-       topic1_hash=$(git rev-parse HEAD) &&
-
-       git push 2>push.err &&
-
-       ! cat push.err | grep "/foo/trac topic2"
-       ! cat push.err | grep "/foo/trac topic1"
-'
-
-test_expect_success 'update branch with abbreviation' '
-       git checkout topic2
-       git tag -m "release1" release1 &&
-       git push --tags &&
-
-       echo "$test_name" >a &&
-       git commit -a -m "changed on topic2" &&
-       new_commit_describe=$(git describe HEAD) &&
-       new_commit_hash=$(git rev-parse HEAD) &&
-       git push origin topic2 2>push.err &&
-       cat push.err | grep "/foo/trac topic2 $new_commit_describe r/3 $new_commit_hash"
-'
-
-test_expect_success 'update branch with abbreviation and two commits' '
-       echo "$test_name 1" >a &&
-       git commit -a -m "changed on topic2 1" &&
-       first_commit_describe=$(git describe HEAD) &&
-       first_commit_hash=$(git rev-parse HEAD) &&
-
-       echo "$test_name 2" >a &&
-       git commit -a -m "changed on topic2 2" &&
-       second_commit_describe=$(git describe HEAD) &&
-       second_commit_hash=$(git rev-parse HEAD) &&
-
-       git push origin topic2 2>push.err &&
-       cat push.err | grep "/foo/trac topic2 $first_commit_describe r/4 $first_commit_hash" &&
-       cat push.err | grep "/foo/trac topic2 $second_commit_describe r/5 $second_commit_hash"
-'
-
-test_done
-
diff --git a/tests/t3001-post-receive-trac-with-commitnumbers.sh b/tests/t3001-post-receive-trac-with-commitnumbers.sh
new file mode 100644 (file)
index 0000000..8a337d4
--- /dev/null
@@ -0,0 +1,91 @@
+#!/bin/sh
+
+test_description='server post receive trac with commit numbers'
+
+. ./test-lib.sh
+
+export PYTHON=echo
+export TRAC_ENV=/foo/trac
+
+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
+'
+
+install_post_receive_hook 'post-receive-commitnumbers' 'post-receive-trac'
+
+test_expect_success 'new branch' '
+       git checkout -b topic1 master &&
+       echo "$test_name" >a &&
+       git commit -a -m "changed on topic1" &&
+       new_commit_hash=$(git rev-parse HEAD) &&
+       git push origin topic1 2>push.err &&
+       cat push.err | grep "/foo/trac topic1 $new_commit_hash r/1 $new_commit_hash"
+'
+
+test_expect_success 'new branch with already existing does not double tap' '
+       git checkout -b topic2 topic1 &&
+       existing_commit_hash=$(git rev-parse HEAD) &&
+       git push origin topic2 2>push.err &&
+       ! cat push.err | grep "/foo/trac topic2"
+'
+
+test_expect_success 'update branch' '
+       # Already on topic2
+       echo "$test_name" >a &&
+       git commit -a -m "changed on topic2" &&
+       new_commit_hash=$(git rev-parse HEAD) &&
+       git push origin topic2 2>push.err &&
+       cat push.err | grep "/foo/trac topic2 $new_commit_hash r/2 $new_commit_hash"
+'
+
+test_expect_success 'update branch to an already published commit does not double tap' '
+       # Make topic1 catch up to topic2, which will be a fast forward that does need re-tapped
+       git checkout topic2 &&
+       topic2_hash=$(git rev-parse HEAD) &&
+
+       git checkout topic1 &&
+       git merge topic2 &&
+       topic1_hash=$(git rev-parse HEAD) &&
+
+       git push 2>push.err &&
+
+       ! cat push.err | grep "/foo/trac topic2"
+       ! cat push.err | grep "/foo/trac topic1"
+'
+
+test_expect_success 'update branch with abbreviation' '
+       git checkout topic2
+       git tag -m "release1" release1 &&
+       git push --tags &&
+
+       echo "$test_name" >a &&
+       git commit -a -m "changed on topic2" &&
+       new_commit_describe=$(git describe HEAD) &&
+       new_commit_hash=$(git rev-parse HEAD) &&
+       git push origin topic2 2>push.err &&
+       cat push.err | grep "/foo/trac topic2 $new_commit_describe r/3 $new_commit_hash"
+'
+
+test_expect_success 'update branch with abbreviation and two commits' '
+       echo "$test_name 1" >a &&
+       git commit -a -m "changed on topic2 1" &&
+       first_commit_describe=$(git describe HEAD) &&
+       first_commit_hash=$(git rev-parse HEAD) &&
+
+       echo "$test_name 2" >a &&
+       git commit -a -m "changed on topic2 2" &&
+       second_commit_describe=$(git describe HEAD) &&
+       second_commit_hash=$(git rev-parse HEAD) &&
+
+       git push origin topic2 2>push.err &&
+       cat push.err | grep "/foo/trac topic2 $first_commit_describe r/4 $first_commit_hash" &&
+       cat push.err | grep "/foo/trac topic2 $second_commit_describe r/5 $second_commit_hash"
+'
+
+test_done
+
diff --git a/tests/t3200-post-receive-assign-commit-numbers.sh b/tests/t3200-post-receive-assign-commit-numbers.sh
deleted file mode 100644 (file)
index 013b3c5..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-#!/bin/sh
-
-test_description='server assign commit numbers'
-
-. ./test-lib.sh
-
-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 config --add branch.master.remote origin &&
-       git config --add branch.master.merge refs/heads/master &&
-       git fetch
-'
-
-install_post_receive_hook 'post-receive-assign-commit-numbers'
-
-test_expect_success 'assign one new commit' '
-       git checkout master &&
-       echo "$test_name" >a &&
-       git commit -a -m "changed a" &&
-       git push origin master &&
-       git fetch &&
-
-       test "$(git rev-parse HEAD)" = "$(git rev-parse r/1)" &&
-       test "$(git describe --tags)" = "r/1" &&
-       test "$(git rev-parse HEAD) refs/heads/master" = "$(cat server/.git/commitnumbers)"
-'
-
-test_expect_success 'assign two new commits' '
-       echo "$test_name first" >a &&
-       git commit -a -m "changed a first" &&
-       echo "$test_name second" >a &&
-       git commit -a -m "changed a second" &&
-       git push origin master &&
-       git fetch &&
-
-       test "$(git rev-parse HEAD)" = "$(git rev-parse r/3)" &&
-       test "$(git describe --tags)" = "r/3" &&
-
-       test "$(git rev-parse HEAD^)" = "$(git rev-parse r/2)" &&
-       test "$(git describe --tags HEAD^)" = "r/2"
-'
-
-test_expect_success 'pushing commits to a new branch does not reassign' '
-       git checkout -b topica &&
-       echo "$test_name" &&
-       git push origin topica &&
-       git fetch &&
-
-       ! git rev-parse r/4
-'
-
-test_done
-
diff --git a/tests/t3200-post-receive-commitnumbers.sh b/tests/t3200-post-receive-commitnumbers.sh
new file mode 100644 (file)
index 0000000..985aadc
--- /dev/null
@@ -0,0 +1,58 @@
+#!/bin/sh
+
+test_description='server assign commit numbers'
+
+. ./test-lib.sh
+
+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 config branch.master.remote origin &&
+       git config branch.master.merge refs/heads/master &&
+       git fetch
+'
+
+install_post_receive_hook 'post-receive-commitnumbers'
+
+test_expect_success 'assign one new commit' '
+       git checkout master &&
+       echo "$test_name" >a &&
+       git commit -a -m "changed a" &&
+       git push origin master &&
+       git fetch &&
+
+       test "$(git rev-parse HEAD)" = "$(git rev-parse r/1)" &&
+       test "$(git describe --tags)" = "r/1" &&
+       test "$(git rev-parse HEAD) refs/heads/master" = "$(cat server/.git/commitnumbers)"
+'
+
+test_expect_success 'assign two new commits' '
+       echo "$test_name first" >a &&
+       git commit -a -m "changed a first" &&
+       echo "$test_name second" >a &&
+       git commit -a -m "changed a second" &&
+       git push origin master &&
+       git fetch &&
+
+       test "$(git rev-parse HEAD)" = "$(git rev-parse r/3)" &&
+       test "$(git describe --tags)" = "r/3" &&
+
+       test "$(git rev-parse HEAD^)" = "$(git rev-parse r/2)" &&
+       test "$(git describe --tags HEAD^)" = "r/2"
+'
+
+test_expect_success 'pushing commits to a new branch does not reassign' '
+       git checkout -b topica &&
+       echo "$test_name" &&
+       git push origin topica &&
+       git fetch &&
+
+       ! git rev-parse r/4
+'
+
+test_done
+