File: fbcode_to_main_sync.sh

package info (click to toggle)
pytorch-vision 0.21.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 20,228 kB
  • sloc: python: 65,904; cpp: 11,406; ansic: 2,459; java: 550; sh: 265; xml: 79; objc: 56; makefile: 33
file content (47 lines) | stat: -rwxr-xr-x 1,147 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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
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."