I never found the perfect solution, but what we do now seems to work. The main drawback is that commits within the deployment room initially have one SHA1 that then changes to a different SHA1 after being merged with the dev room. The good news is that git
quite easily recognizes them as the same commits can can merge
right through them.
- There are 3 checkpoints we must keep track of:
dev/master
which has the newest development in the dev room.deploy/master
which has the newest development in the deploy room.dev_deploy_common
which is the last commit the two histories share.
.
When we move code from dev to deploy (using a bundle), we bring the commits in as part of the
dev_deploy_common
branch within the deploy room (git pull
intodev_deploy_common
), and then fromdeploy/master
do agit merge dev_deploy_common
and resolve and conflicts then and there.When we move code from deploy to dev (which must be a text file) we make a few extra steps:
First we rebase
deploy/master
ontodev_deploy_common
so that all of our patches are contiguous. This is generally easy since we've already handled any conflicts during the merges which occurred when bringing the bundle from dev to deploy.Second we generate a patch set using
git format-patch -M25 -C25 --find-copies-harder -k --ignore-if-in-upstream
The
-M25 -C25 --find-copies-harder
options just reduce the output text size. The-k
option keeps commit subjects intact. The--ignore-if-in-upstream
restricts our commits to just the new ones sincedev_deploy_common
.The result of this is a
patchset.txt
collection of patches. This file can be hand-reviewed and then moved to the dev room.In the dev room we import the patchset using the following command:
git am -k -3 --keep-cr --committer-date-is-author-date patchset.txt
Unfortunately, even though we use all the commands we can to keep the patch exactly the same, a few of the attributes change, primarily the committer. As a result the "same" commit will have different SHA1's in the dev and deploy rooms. This difference will persist until we move a bundle back into the deploy room.
When moving a bundle from dev to deploy, the
merge
operation (typically) recognizes the identical patches and seamlessly replaces the commit with the one in the dev history. See Step 1.