2

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.

Community
  • 1
  • 1
Antonio
  • 19,451
  • 13
  • 99
  • 197

2 Answers2

2

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.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks, it's a nice idea, but I was wondering if I could avoid cloning the project (it's quite bulky). Furthermore, is there a way of simulating someone else pushing something in the repository, so that I can pull, or I have necessarily to involve another person? – Antonio Jul 24 '13 at 20:42
  • @Antonio You can push, just after changing `user.name` and `user.email`, in order to make git believe the commit comes from someone else. You can then test those merges in a special branch, that would be easy to clean (delete) after said tests. I have edited my answer. – VonC Jul 24 '13 at 20:43
1

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 :)

cohlar
  • 21
  • 4