简体   繁体   中英

Clone GitHub Repository and Merge All Pull Requests

Here is the repository I am looking to use - https://github.com/Sumi-Interactive/SIAlertView

What is the best way to clone this GitHub repository and merge all of the 36 open pull requests on that repository into the one I have just cloned?

This would kind of achieve what you want. Clone the remote, configure fetching of pull requests and then merge each of the PR branches.

However, there are conflicts between the branches. They are changing the same files in different ways. So merging all of them together is not a trivial task. And thus the script fails.

#!/usr/bin/env bash

set -e

git clone https://github.com/Sumi-Interactive/SIAlertView
cd SIAlertView

git config --add remote.origin.fetch "+refs/pull/*/head:refs/remotes/origin/pr/*"
git fetch

for branch in $(git branch -r); do
    [[ $branch =~ origin/pr/ ]] && git merge $branch
done

Go through them, review them, and if it passes review click the merge button. If it doesn't comment and either fix it yourself or wait for the contributor to fix it.

You don't want to automate this, the point of having a PR is someone reviews it. If you automate acceptance it defeats the point. If you don't want to review PRs then skip them entirely and give contributors permission to push to master (probably not a great idea).

You don't appear to have Continuous Integration Testing of the PRs, so you're not even sure the PRs work. Even if they work individually there's no guarantee they'll all work once smashed together. master will be a mess.

And with 36 simultaneous PRs there's a very good chance blindly merging all of them will cause conflicts (or worse, silently overwrite each other's changes). You need to integrate them intelligently.

And now that you've advertised your project is blindly accepting PRs, it's very easy for a malicious attacker to insert malware into your project.

What would be better is to find a few more people to help out with review and integration. This can be unofficial, just ask some people to comment on the PRs, or you can use Github's review process .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM