reconquest / atlassian-external-hooks

External Hooks plugin for Atlassian Bitbucket
https://external-hooks.reconquest.io
Other
44 stars 37 forks source link

Commit hash passed to external hook script when braches created/merged is 000000000 #14

Closed linjer closed 4 years ago

linjer commented 9 years ago

During a merge into the master branch the parameters from the external hook plugin to the external bash script were: e5e98e5cb9f6c9dd4a12bb47de36c0283899236c 0000000000000000000000000000000000000000 refs/heads/user-dash

When a new branch was made locally, and committed, the parameters passed to the script were: 0000000000000000000000000000000000000000 f18cb17e1c0e31b52f5f8cd118e903e272f8af26 refs/heads/dashboards_dev

This caused trouble in the git log command used in the script (00... invalid commit).

Environment

Stash 3.2.0 External Hooks 2.0-1 CentOS 6.5 git 2.1.0-rc0

seletskiy commented 9 years ago

Do you use Delete source branch after merging option when merging branch in the pull request? If so, it's not surprising that you'll see that source branch will got deleted (00..00 hash means ref deletion in git).

linjer commented 9 years ago

My co-worker did it and I believe we observed it (00..00 hash) on 3 occasions, and he did use the delete source branch after merging PR on at least 1. The other 2 I do not think so.

In sourcetree, when I look at the history, they all have parent hashes that are not 00..00 but I do observe some have 2 hash parents (for merge).

Also observed 00..00 on to-ref hash after branching. That doesn't include any deletion.

seletskiy commented 9 years ago

All ref changes are passed from Stash as is without any modification logic (https://github.com/ngsru/atlassian-external-hooks/blob/master/src/main/java/com/ngs/stash/externalhooks/hook/ExternalPreReceiveHook.java#L99).

So, on my opinion, you've just misinterpret passed values. Seeing zeros in to_rev field means that specified ref gets deleted; you can check it out by cloning repo to the clean directory and search for that ref in git show-ref output.

However, if you have reproduceable test case, please let me know.