0

My team has recently transitioned to a GitHub Actions CI/CD workflow and we are encountering an issue that I'm uncertain how best to resolve.

First, I'll describe our current branching strategy:

We are a Salesforce stack shop that uses the Org Development model. This means that each developer has their own sandbox, and in addition we have Integration, UAT, and Production environments.

We have created 3 long-lived branches in git that are meant to represent each of these non-developer sandboxes (int, uat, main). The intended workflow is as follows:

  • All feature branches should be based from main.
  • Once a feature branch is considered ready for QA, a Pull Request is opened to compare the branch to int. Once squashed and merged, a GitHub Action will deploy the delta to the Integration environment.
  • Once QA is complete, a Pull Request is created to compare the feature branch to uat. Once squashed and merged, a GitHub Action will deploy the delta to the UAT environment.
  • After UAT sign-off, a Pull Request is created to compare the feature branch to main. Once squashed and merged, a GitHub Action will deploy the delta to the Production environment.
  • If at any point main should be updated, the feature branch should be rebased on top of main.

The issue we have encountered is that after a feature branch has been merged into both int and main, our int branch still seems to think that it is behind the main branch. Example:

  • feature/A with commit1 has been squashed and merged into int, uat and main via Pull Requests and subsequently deployed to their relevant environments.
  • feature/B is then created based on main, which includes the changes from feature/A.
  • feature/B is ready to be merged into int, and a Pull Request is created.
  • At this point, git does not see that commit1 is already represented in int and wants to re-merge this commit into int.

Looking into it, I can see that commit1 has a different hash in the int branch than the one in main. So, I believe I understand why git does not see these as the same commit, but I'm unsure what has caused the hash to change.

I'm certain I'm overlooking something here, or perhaps misunderstanding what is happening with git behind the scenes. Any help would be greatly appreciated.

1
  • I’ve added a link. Hope it’s correct. Commented Mar 28 at 9:37

1 Answer 1

1

Once squashed ...

Stop doing that.

In the same way that adding comments as a deodorant to cover up stinking code is a bad idea, squashing branches because the version history stinks is also a bad idea (and that is always the reasoning behind why people want to squash branches on pull requests, although expressed as an euphemism like "clean up the branch" or whatever).

Using fixup or squash in interactive rebase while working on a feature is not only perfectly fine (I am in no way advocating that commits are immutable and should never be changed), but more than that - almost required. However at the point when creating a pull request the history should be clean and proper (including all commits pass tests) and squashing is wrong.

Squashing will ruin your ability to drill down problems with git bisect. And as you have experienced it also breaks your workflow.

3
  • Not squashing doesn't merely "stink", it litters the the master branch with meaningless commits, possibly not even related to the problem at hand, i.e. fixing a bug introduced while working on a branch, so at no point in time it existed in the master branch. When admins get a problem in prod they want to know by which PR it was introduced and when, regardless if the underlying branch was cooked in a week or in a year. Requiring foreign contributors to conform to possibly arcane rules of CI/CD pipeline in every single commit is pretty asinine also. Commented Jun 17 at 18:19
  • @BillerBuilder Did you read my answer fully? For instance the issue "fixing a bug introduced while working on a branch" is specifically covered by "squash ... while working on a feature is ... almost required". If you introduce a bug in one commit on the branch and then fix it in a later commit the remedy is to use fixup or squash in interactive rebase to amend the original buggy commit to be non-buggy. This is done before creating a pull request.
    – hlovdal
    Commented Jun 17 at 21:49
  • What happens if the bug is found after the review on PR? You logic assumes (but doesn't state) some sort of out of band communication channel when it's not a thing with one-off contribs from literal whos. And the chance of additional commits increases the more time it takes to merge, if only to sync up with the master branch. "Messy" commit history on a working branch is preferable to constantly rebasing/squashing one. Big git providers tend not to like frivolous rebases and instead append them as commits to the history anyway. Commented Jun 20 at 17:17

Not the answer you're looking for? Browse other questions tagged or ask your own question.