git-sticker icon indicating copy to clipboard operation
git-sticker copied to clipboard

Hey Jeff! Use this script to automatically merge all the PR's

Open onlyamessenger opened this issue 4 years ago • 7 comments

Hi @codediodeio ,

Pretty sure you don't want to manually merge all these PR's. So you can use the below bash script to do some of the heavy lifting. You'll need to modify it for your decryption step to be automated as well, but this should be a good starting point.

Disclaimer: The auto merging will only work if there aren't any merge conflicts, so here's hoping 🤞🏻

# List all pull requests to master and grab the first half (before space) of each line
git ls-remote origin 'pull/*/head' | awk '{print $1}' |
# Loop through all the lines
while read ref; do
  # Clean up the line
  pr=$(echo $ref | cut -d/ -f3)
  echo "Attempting to automatically merge and decrypt from pull request $ref"
  # Merge the PR automagically (if it is valid)
  git merge --no-ff $ref -m "Auto merge of pull request $ref"
done
# Once everything is merged, loop through all text files in stickers dir
for entry in stickers/*
do
  echo "Attempting to decrypt $entry"
  # Maybe your script should take a file name as an arg? Then you can use the below
  address=$(npm run test --someArg $entry)
  # Do something with your decrypted address :)
  echo $address
done

onlyamessenger avatar Mar 17 '20 18:03 onlyamessenger

I guess Jeff loves us all and he'll go through that manually and say something nice for trying 😉

daniels20000 avatar Mar 17 '20 18:03 daniels20000

This looks awesome! Thank you so much 👍

codediodeio avatar Mar 17 '20 18:03 codediodeio

Might need some more code to do some checks such as:

  1. Whether they only edit one file. (the package-lock JSON trick was clever!)
  2. Whether the encrypted string is valid (isn't missing any characters)
  3. Whether they consist of only one commit.

Those are all I can think of off the top of my head. What do you guys think?

Ry-DS avatar Mar 18 '20 00:03 Ry-DS

  1. Whether they consist of only one commit.

Would the number of commits matter if only one file is changed? I don't think one commit was a requirement, but I might be missing something.

Snarr avatar Mar 18 '20 07:03 Snarr

  1. Whether they consist of only one commit.

Would the number of commits matter if only one file is changed? I don't think one commit was a requirement, but I might be missing something.

Ah, must have read it wrong. As long as one file is edited all should be good then!

Other considerations might be to check if the master branch was edited in the PR, as one could infer from the instructions that it's not allowed - changes should only be merged from your own custom-named branch. Or maybe this is too strict?

Ry-DS avatar Mar 18 '20 10:03 Ry-DS

I ended up putting something together with the GitHub GraphQL API to validate the PRs. I'll give @ascendedco a shoutout in the video follow-up bc this is a helpful little script.

codediodeio avatar Mar 21 '20 20:03 codediodeio

@codediodeio, can you please enable the script? :)

TheDechev avatar Sep 03 '22 15:09 TheDechev