We have some devs pushing to a remote bare repo on a server, and would like to do something like automate a push to perforce nightly using git p4 from this central bare repo. But am running into a snag because it seems you can't run git p4 submit outside of a working tree.
What's the recommended way to deal with something like this?
I do something similar with a script that runs every few minutes and does a 2-way sync between git and p4. But git-p4 can't work without both a checked-out git tree and a p4 repo. In all you end up with 3 versions of your source:
Developers push to a bare git repo (held on gitolite), using a branch called 'dev'. Then every few minutes, there's a script that does:
Gotchas
Merge conflicts. These actually occur very infrequently but can cause a few problems.
I had to add some locking around the whole thing so that developers don't lose changes if they push a change between (1) and (5). The locking just creates a lock directory that then gets used in one of the hook scripts to delay pushes.
RCS keywords. Newer versions of 'git p4' now copes with RCS keywords but originally it didn't, so the whole thing would occasionally get stuck as they cause merge conflicts.
It took a while to setup but it's now been going for 18 months with 100+ developers with very few incidents.