]> git.droids-corp.org - git-central.git/commitdiff
Adding a functions and redoing the tattoo to use the r/X tags.
authorStephen Haberman <stephen@exigencecorp.com>
Tue, 30 Sep 2008 03:47:38 +0000 (22:47 -0500)
committerStephen Haberman <stephen@exigencecorp.com>
Tue, 30 Sep 2008 16:34:05 +0000 (11:34 -0500)
scripts/functions [new file with mode: 0644]
scripts/gc-push
scripts/gc-tattoo
tests/t5500-script-tattoo.sh

diff --git a/scripts/functions b/scripts/functions
new file mode 100644 (file)
index 0000000..b665bcb
--- /dev/null
@@ -0,0 +1,11 @@
+#!/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
+}
+
index 4e72fe500296280531b6407d3293796665a04848..26ffa7b39d7d892469621cafe5683bb854df552e 100644 (file)
@@ -1,13 +1,13 @@
 #!/bin/sh
 
-branch_name=$(git symbolic-ref --quiet HEAD)
-if [[ $? -ne 0 ]] ; then
-       echo "not on a branch"
+. $(dirname $0)/functions
+
+set_branch_name
+if [ "$branch_name" == "" ] ; 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 $?
index d7139bad834b4e4027d0e8c5528a390b6c5e0391..f1bd3a1e7b96fc2fda742dc85537d7b00d8cb6fc 100644 (file)
@@ -1,83 +1,27 @@
 #!/bin/sh
 
-#
-# Some docs
-#
-# A --- B --- C    stable
-# |\         /
-# | D ----- E      topic1
-#  \       /
-#   F --- G        topic2
-#
-# topic1 stable result
-#  D      A      contains, merge base=A
-#  D      C      contains, merge base=A
-#  E      A      contains, merge base=E
-#  E      C      contains, merge base=A
+. $(dirname $0)/functions
 
-#
-# * --- * --------- *   stable
-# |\     \
-# | A --- B ---- C      topic1
-# \             /
-#  D --- E --- F        topic2
-#
-# F: contains=topic1,topic2
-# C: contains=topic1
+git fetch
 
-head=$(git rev-parse HEAD)
+set_branch_name
 
-# Watch out for the very first commit in the repo because we use head^
-# Hopefully we can optimize this away later.
-git rev-parse --verify --quiet "$head^" >/dev/null
-if [ $? -ne 0 ] ; then
-       echo "0"
-       exit 0
-fi
+echo "branch_name='$branch_name'"
 
-contains=($(git branch -r --contains $head))
-if [ ${#contains[@]} -eq 0 ] ; then
-       echo "$head has not been pushed"
+if [ "$branch_name" == "" ] ; then
+       echo "Not on a branch (for $branch_name)"
        exit 1
 fi
 
-potential=" "
-for branch in ${contains[@]} ; do
-       branch=${branch##origin/}
-       #echo "branch=$branch"
-
-       # Walk back until we hit a baserev that is not the branch_tip itself (because it was merged)
-       branch_tip=$(git rev-parse origin/$branch)
-       stable_rev=$(git rev-parse origin/stable)
-       stable_base=$(git merge-base "$branch_tip" "$stable_rev")
-
-       # echo "stable_base=$stable_base"
-       while [ "$stable_base" == "$branch_tip" ] ; do
-               stable_rev=$(git rev-parse "${stable_rev}^")
-               stable_base=$(git merge-base "$branch_tip" "$stable_rev")
-       done
-       # echo "stable_base=$stable_base"
-
-       git rev-list --first-parent $stable_base..$branch_tip | grep --quiet "$head"
-       if [ $? -eq 0 ] ; then
-               if [ "$branch" == "stable" ] ; then
-                       describe=$(git describe $head 2>/dev/null)
-                       if [ $? -eq 0 ] ; then
-                               potential="$potential $describe"
-                       else
-                               potential="$potential stable-$head"
-                       fi
-               else
-                       number=$(git rev-list --first-parent "$stable_base..$head" | wc -l)
-                       potential="$potential $branch-$number"
-               fi
-       fi
-done
-
-potential=($potential)
-if [ ${#potential[@]} -eq 1 ] ; then
-       echo "${potential[0]}"
-else
-       echo "unknown"
-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
 
index bab6dd224d1d47f10209a2446c08e82a938d8d39..561b4bf6580526360c15dbaf7d3e203c09e43306 100644 (file)
@@ -19,11 +19,14 @@ test_expect_success 'setup' '
 
 # 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 first commit' '
-       gc-tattoo | grep 0
+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 &&