-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Added script to sync fbcode changes with main branch #4769
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
prabhat00155
merged 8 commits into
pytorch:main
from
prabhat00155:prabhat00155/fbcode_sync
Oct 28, 2021
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
67c4c8f
[WIP] Added script to sync fbcode changes with main branch
prabhat00155 4e98902
Make unique branches for multiple runs of the script
prabhat00155 e2c84af
Updated the files
prabhat00155 c7f7835
Change echo message
prabhat00155 f000162
Merge branch 'master' into prabhat00155/fbcode_sync
prabhat00155 d2c96df
Addressed review comments
prabhat00155 d552d1b
Removed from_repo command line argument
prabhat00155 644edd5
Make fork_main_branch optional
prabhat00155 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
Utility scripts | ||
=============== | ||
|
||
* `fbcode_to_main_sync.sh` | ||
|
||
This shell script is used to synchronise internal changes with the main repository. | ||
|
||
To run this script: | ||
|
||
.. code:: bash | ||
|
||
chmod +x fbcode_to_main_sync.sh | ||
./fbcode_to_main_sync.sh <commit_hash> <fork_name> <fork_main_branch> | ||
|
||
where | ||
|
||
``commit_hash`` represents the commit hash in fbsync branch from where we should start the sync. | ||
|
||
``fork_name`` is the name of the remote corresponding to your fork, you can check it by doing `"git remote -v"`. | ||
|
||
``fork_main_branch`` (optional) is the name of the main branch on your fork(default="main"). | ||
|
||
This script will create PRs corresponding to the commits in fbsync. Please review these, add the [FBCode->GH] prefix on the title and publish them. Most importantly, add the [FBCode->GH] prefix at the beginning of the merge message as well. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/bin/bash | ||
|
||
if [ -z $1 ] | ||
then | ||
echo "Commit hash is required to be passed when running this script." | ||
echo "./fbcode_to_main_sync.sh <commit_hash> <fork_name> <fork_main_branch>" | ||
exit 1 | ||
fi | ||
commit_hash=$1 | ||
|
||
if [ -z $2 ] | ||
then | ||
echo "Fork name is required to be passed when running this script." | ||
echo "./fbcode_to_main_sync.sh <commit_hash> <fork_name> <fork_main_branch>" | ||
exit 1 | ||
fi | ||
fork_name=$2 | ||
|
||
if [ -z $3 ] | ||
then | ||
fork_main_branch="main" | ||
else | ||
fork_main_branch=$3 | ||
fi | ||
|
||
from_branch="fbsync" | ||
git stash | ||
git checkout $from_branch | ||
git pull | ||
# Add random prefix in the new branch name to keep it unique per run | ||
prefix=$RANDOM | ||
prabhat00155 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
IFS=' | ||
' | ||
for line in $(git log --pretty=oneline "$commit_hash"..HEAD) | ||
do | ||
if [[ $line != *\[fbsync\]* ]] | ||
then | ||
echo "Parsing $line" | ||
hash=$(echo $line | cut -f1 -d' ') | ||
git checkout $fork_main_branch | ||
git checkout -B cherrypick_${prefix}_${hash} | ||
git cherry-pick -x "$hash" | ||
git push $fork_name cherrypick_${prefix}_${hash} | ||
git checkout $from_branch | ||
fi | ||
done | ||
echo "Please review the PRs, add [FBCode->GH] prefix in the title and publish them." |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.