ef-labs / stash-hook-mirror

An Atlassian Stash repository hook for mirroring to one or more remote git repositories.
MIT License
77 stars 58 forks source link

Mirroring not working with SubGit (on same host) #9

Open friesoft opened 11 years ago

friesoft commented 11 years ago

Hi,

I'm using Atlassian Stash 2.5.0 with SubGit 2.0.0 and Repository Mirroring 1.3.0.

The repository is set to sync to and with SubGit. As long as I commit from git and push it works - as soon as I'm commiting from within SVN it doesn't work (the push is not recognized and the changes are not mirrored to the remote mirror).

You have already answered me in the reviews of the addon:

Thanks for the feedback.  Unfortunately the plugin uses the stash repository hook api AsyncPostReceiveRepositoryHook:

https://developer.atlassian.com/static/javadoc/stash/latest/spi/reference/com/atlassian/stash/hook/repository/AsyncPostReceiveRepositoryHook.html

This only fires for pushes and pull request acceptance.

Are you running subgit locally on the stash server?  If you run subgit on a different machine and then perform a push it should work.  I suppose one way to fix this would be to create a git hook that can trigger the stash repository hook to run.  Feel free to enter an issue here: https://github.com/englishtown/stash-hook-mirror/issues (and contribute if you'd like)

How do I create such a trigger?

Regards, Bernhard Friedreich

adrianluisgonzalez commented 11 years ago

Standard git hooks (vs stash repository hooks) are shell scripts, so one option would be to investigate the REST api exposed by Stash. It may not be possible to force an AsyncPostReceiveHook to run via current REST operations and may require adding additional operations for this hook.

Frankly this sounds like a fair amount of effort and I would personally work around this by running subgit on a different server and push the changes to the Stash server.

Please feel free to submit a pull request if you want to contribute.

vs commented 11 years ago

Hi,

I'm one of SubGit developers and I've just come across your discussion here.

Indeed, current version (both SubGit 2.0.x and SVN Mirror Add-on 2.0.x) do not trigger any Git/Stash hooks when translating SVN revisions to Git commits. That's something we're going to fix a bit later. Please follow the issue for more updates on that: http://issues.tmatesoft.com/issue/SG-34

From Git mirror side it would make sense to attempt mirroring new commits periodically in order to workaround the issue.

deatharse commented 9 years ago

Has any work been carried out on this yet? I noticed it's tagged as wontfix, is there a reason for that? It would be great if it fired the hooks when translating SVN into Git commits.

adrianluisgonzalez commented 9 years ago

@alasdairdc, I haven't looked at this plugin for a while, but it is due for some attention. If subgit does not trigger the Stash web hooks to run, there is not much the stash-hook-mirror plugin can do.

Do you have a suggestion on how to handle this?

deatharse commented 9 years ago

ah okay its down to subgit. may take a look at it and see if theres anything that can be done.

vs commented 9 years ago

Updates from our side:

SubGit 3.0 EAP

Since version 3.0 it is possible to make SubGit trigger user-post-receive hook every time it fetches new changes from SVN repository:

$ edit REPO/subgit/config
[svn]
...
triggerSvnPostReceive = true

$ subgit install REPO

So, this should be possible to trigger necessary Stash hooks from user-post-receive in order to enable mirroring for changes arrived from SVN repository.

SVN Mirror add-on for Atlassian Stash

Since version 2.0.15 our plugin fires SvnFetchEvent implements RepositoryRefsChangedEvent every time it fetches new changes from SVN repository. I think it makes a lot of sense for Git mirroring plugin to listen to updated refs via RepositoryRefsChangedEvent mechanism. If that is done, the mirroring should work properly.