Antonio
Antonio

Reputation: 20296

Testing a post-merge hooks script for git

I am very new to GIT, and I have the following doubt:

How can I test if a post-merge script will be doing its duty, without having other people pushing fake changes to the repository? (Is post-merge the correct script, if I want it to be called every time I pull from the repository and some modifications are found? Will it be executed even if the pull exits with error, for example because of conflicts?)

I ask this question related to this other problem I am facing.

Upvotes: 2

Views: 1955

Answers (2)

cohlar
cohlar

Reputation: 51

No need for other people pushing anything to your repo. You can just create a local branch:

git checkout -b <dummy branch>

Make changes in your local branch, commit them, then move to your actual working branch and merge your dummy branch:

git merge <dummy branch>

That should trigger your post-merge script. You can re-do this as much as you need to test your script without annoying anyone :)

Upvotes: 1

VonC
VonC

Reputation: 1326922

I would rather test that post-merger hook by pushing fake changes to a clone of your actual repo.
I would register that hook in the clone the same way it is setup in the current repo.

That way, you don't pollute your original repo with fake history you would have to clean.


If you want to avoid the clone, you can:

  • dedicate a branch for those merges
  • push after having changed user.name and user.email (git config user.name xxx), in order to simulate other authors and committers for your merges.

Once those test merges are done on that branch, you can delete it easily enough.

Upvotes: 2

Related Questions