First pass at sequential commit numbers.
[git-central.git] / tests / t3200-server-post-receive-assign-commit-numbers.sh
1 #!/bin/sh
2
3 test_description='server assign commit numbers'
4
5 . ./test-lib.sh
6
7 test_expect_success 'setup' '
8         echo "setup" >a &&
9         git add a &&
10         git commit -m "setup" &&
11         git clone ./. server &&
12         rm -fr server/.git/hooks &&
13         git remote add origin ./server &&
14         git config --add branch.master.remote origin &&
15         git config --add branch.master.merge refs/heads/master &&
16         git fetch
17 '
18
19 install_post_receive_hook 'post-receive-assign-commit-numbers'
20
21 test_expect_success 'assign one new commit' '
22         git checkout master &&
23         echo "$test_name" >a &&
24         git commit -a -m "changed a" &&
25         git push origin master &&
26         git fetch &&
27
28         test "$(git rev-parse HEAD)" = "$(git rev-parse r/0)"
29         test "$(git describe --tags)" = "r/0"
30 '
31
32 test_expect_success 'assign two new commits' '
33         echo "$test_name first" >a &&
34         git commit -a -m "changed a first" &&
35         echo "$test_name second" >a &&
36         git commit -a -m "changed a second" &&
37         git push origin master &&
38         git fetch &&
39
40         test "$(git rev-parse HEAD)" = "$(git rev-parse r/2)"
41         test "$(git describe --tags)" = "r/2"
42
43         test "$(git rev-parse HEAD^)" = "$(git rev-parse r/1)"
44         test "$(git describe --tags HEAD^)" = "r/1"
45 '
46
47 test_expect_success 'pushing commits to a new branch does not reassign' '
48         git checkout -b topica &&
49         echo "$test_name" &&
50         git push origin topica &&
51         git fetch &&
52
53         ! git rev-parse r/3
54 '
55
56 test_done
57