We recently completed a migration from an old gitosis/gitweb/git daemon server to Stash; a handful of repositories had been "fiddled with" on the server, it turns out. The .git/config file was modified and some remotes were added - say, a remote called "upstream" with the url to an open source project out on the interwebs. Then a cron job had been installed to go into the folder on the git server and do a git fetch & prune. The end result is the hosted repos magically stayed up to date on specific "branches" with the open source community. I didn't know about this until the final few days of the move from gitosis to Stash. So not addressing the pro's and con's of whether or not this is wise - that's a seperate question - what's the best way to solve this in Stash?
I would rather not dig into the Stash data folder and manually edit the .git/config file in the handful of repos and run a cron job to do a behind the scenes fetch, mostly because I'm not confident it would work, and I'm also worried about messing around where I shouldn't - Stash's documentation clearly states to not manually modify anything in your data folder. I would like to keep upgrading Stash without a problem, so I don't want to cause a headache for myself down the road. I've checked out the marketplace as well - the two mirroring plugins that are up to date mirror the wrong direction - they allow you to mirror your Stash repo to somewhere else - either another instance of Stash, or another git server completely (bitbucket, github, et al). There's one plugin that looks like it might have worked but it quit being updated after Stash 2.2 and doesn't look viable any longer.
One idea I have is to use Bamboo for this, instead of cron. Make a sh script task to clone the open source repo and push it to our Stash repo. Like this - here’s the old .git config:
url = git://git.yoctoproject.org/yocto-autobuilder.git
fetch = +refs/heads/*:refs/heads/upstream/*
Here’s my solution:
git clone git://git.yoctoproject.org/yocto-autobuilder.git
git push --prune ssh://email@example.com:7999/test/yocto-autobuilder.git +refs/remotes/origin/*:refs/heads/upstream/* +refs/tags/*:refs/tags/*
You're right to avoid digging into Stash's data folder for this. The general solution would be to externally poll and push via git, so your approach of using a bamboo task to push updates to Stash is a good one. I'm not sure of the exact syntax for the push command to use, there might be something simpler or more reliable.
Thanks. I also hit the Expert Bar at Summit13 and they said essentially the same thing. They hemmed and hawwed ;) a little on whether or not to stay out of the data fold; they said in this instance it wouldn't be the end of the world, but they generally agreed to stay out of it, unless the alternative is worst than going into data.
They liked the bamboo git clone & git push method best, with modifying the .git configs in the data folder & a cron job a distant second. I'll mark your response as the answer, thanks!
As a project manager, I have discovered that different developers want to bring their previous branching method with them when they join the team. Some developers are used to performing individual wo...
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG
You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs