Skyscanner/turbolift

Refresh from upstream after cloning

Closed this issue ยท 3 comments

Personal forks of repos can become seriously outdated in between uses of the tool, meaning that it's easy to accidentally create PRs against very old versions of the target repos. This can result in merge conflicts when creating PRs.

I believe that the simplest way to prevent this would be to amend turbolift clone so that it effectively does:

  • Create a fork
  • Clone the forked repo locally
  • Create a new local branch
  • New: Pull changes from upstream/main or upstream/master into the local branch, so that any changes made by the user are against the latest available version of upstream
rnorth commented

@Dan7-7-7 just so you're aware, there are probably a few different ways of determining the name of the default branch, some simpler than others. Please make sure you've scouted a few things out before getting stuck in to anything complicated - feel free to shout if you want to bounce ideas off us!

The cloned repos already have a remote for upstream, so as a workaround we can use:

turbolift foreach git pull upstream main
turbolift foreach git push origin HEAD:main

For determining the default branch, how about: gh repo view --json defaultBranchRef --jq .defaultBranchRef.name