Re: [RTC/PATCH] Add 'update-branch' hook

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Apr 20, 2014 at 10:23 PM, Felipe Contreras
<felipe.contreras@xxxxxxxxx> wrote:
> This hook is invoked whenever a branch is updated, either when a branch
> is created or updated with 'git branch', or when it's rebased with 'git
> rebase'. It receives two parameters; the name of the branch, and the
> SHA-1 of the latest commit, additionally, if there was a base commit the
> branch was rebased onto, a third parameter contains it.
>
> It can be used to verify the validity of branch names, and also to keep
> track of the origin point of a branch, which is otherwise not possible
> to find out [1].
>
> [1] http://thread.gmane.org/gmane.comp.version-control.git/198587
>
> Signed-off-by: Felipe Contreras <felipe.contreras@xxxxxxxxx>
> ---
> diff --git a/t/t5408-update-branch-hook.sh b/t/t5408-update-branch-hook.sh
> new file mode 100755
> index 0000000..d921c0e
> --- /dev/null
> +++ b/t/t5408-update-branch-hook.sh
> @@ -0,0 +1,39 @@
> +#!/bin/sh
> +
> +test_description='Test the update-branch hook'
> +
> +. ./test-lib.sh
> +
> +setup () {
> +       mkdir -p .git/hooks &&
> +       cat > .git/hooks/update-branch <<-'EOF' &&
> +       #!/bin/sh
> +       echo $@ > .git/update-branch.args
> +       EOF
> +       chmod +x .git/hooks/update-branch &&
> +       echo one > content &&
> +       git add content &&
> +       git commit -a -m one
> +}
> +
> +setup
> +
> +test_expect_success 'creating a branch' '
> +       git checkout -b test master &&
> +       echo two > new &&
> +       git add new &&
> +       git commit -a -m two

Broken &&-chain.

> +       echo "test $(git rev-parse master)" > expected &&
> +       test_cmp expected .git/update-branch.args
> +'
> +
> +test_expect_success 'doing a rebase' '
> +       git checkout -b next master &&
> +       echo three > content &&
> +       git commit -a -m three &&
> +       git rebase --onto next master test &&
> +       echo "test $(git rev-parse HEAD) $(git rev-parse next)" > expected &&
> +       test_cmp expected .git/update-branch.args
> +'
> +
> +test_done
> --
> 1.9.2+fc1.1.g5c924db
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]