pantheon-systems / quicksilver-pushback

Push any commits made on the Pantheon dashboard back to the original GitHub repository.
MIT License
14 stars 13 forks source link

Pushback Sqaushing Upstream Updates #24

Open jessedyck opened 1 year ago

jessedyck commented 1 year ago

Summary

I’m using pushback, with a custom WP upstream and Build Tools, and want to ensure the downstream Pantheon sites and their respective Gitlab (canonical) repos are kept up to date, both with changes committed directly to Pantheon and the upstream changes applied from the upstream (via the dashboard - Apply Updates).

When I do an Apply Updates to bring upstream changes into the downstream, the changes are getting pushed to Gitlab, but as one big commit rather than all of the commits from the upstream repo (which I do see in the history on the Pantheon repo). Effectively pushing a squashed commit of all the upstream changes to the canonical downstream repo.

From what I can tell, Pushback is essentially checking out Gitlab’s commit from the metadata.json file, then overlaying all changes from the previous commit in Pantheon onto that. When there are multiple commits in between this has the effect of squashing them and would ultimately diverge the histories and create future issues trying to merge/apply updates again.

From tracing through the code it seems like this might either be expected/intended, or perhaps I’m looking at using it for something it’s not (yet?) intended to do.

High level repo steps:

I haven't yet gone through the process of recreating these steps outside of my use-case; these are just high level to illustrate what I have set up and get the conversation started.

  1. Create a custom upstream (In this case - WordPress/Bedrock) in Gitlab. Add Build Tools scripts and Pushback.
  2. Create a new downstream site based on the upstream repo using Build Tools; reset the commit history to match the upstream and then associate to the upstream through Terminus
  3. Push a few changes to the upstream gitlab repo’s master branch
  4. Apply upstream updates to downstream site via dashboard
  5. Pushback runs successfully

Actual Behaviour

The changes are pushed to the canonical repo in a new branch, but they contain all the changes from step 3 squashed in one commit, rather multiple commits as were made in step 3.

Expected Behaviour

I was expecting that applying an upstream update on a downstream site would push the commits back to my canonical downstream repo such that both repos (Pantheon and Gitlab) would maintain the same history and continue to support this workflow.

rwagner00 commented 1 year ago

While at present the system works as designed, it should be possible to script this to push back to the source repo. That would look something like:

  1. You add commit abcd to your main branch in Github
  2. CI pushes commit abcd and adds bcde only to Pantheon repo (CI built assets)
  3. You add commits cdef and defg to Pantheon
  4. Pushback squashes cdef and defg into efgh and pushes that to a new branch in Github
  5. Then, you through some git mechanism (cherry-pick, merge, rebase, whatever) put efgh into Github’s main branch (either with the same hash or a different one)
  6. CI will push efgh back to Pantheon and add a new commit (e.g. fghi ) with CI assets to Pantheon. This is a force push so the repos here will be back to the state in #2