Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

fbcode_to_main_sync.sh 1.1 KB

You have to be logged in to leave a comment. Sign In
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
  1. #!/bin/bash
  2. if [ -z $1 ]
  3. then
  4. echo "Commit hash is required to be passed when running this script."
  5. echo "./fbcode_to_main_sync.sh <commit_hash> <fork_name> <fork_main_branch>"
  6. exit 1
  7. fi
  8. commit_hash=$1
  9. if [ -z $2 ]
  10. then
  11. echo "Fork name is required to be passed when running this script."
  12. echo "./fbcode_to_main_sync.sh <commit_hash> <fork_name> <fork_main_branch>"
  13. exit 1
  14. fi
  15. fork_name=$2
  16. if [ -z $3 ]
  17. then
  18. fork_main_branch="main"
  19. else
  20. fork_main_branch=$3
  21. fi
  22. from_branch="fbsync"
  23. git stash
  24. git checkout $from_branch
  25. git pull
  26. # Add random prefix in the new branch name to keep it unique per run
  27. prefix=$RANDOM
  28. IFS='
  29. '
  30. for line in $(git log --pretty=oneline "$commit_hash"..HEAD)
  31. do
  32. if [[ $line != *\[fbsync\]* ]]
  33. then
  34. echo "Parsing $line"
  35. hash=$(echo $line | cut -f1 -d' ')
  36. git checkout $fork_main_branch
  37. git checkout -B cherrypick_${prefix}_${hash}
  38. git cherry-pick -x "$hash"
  39. git push $fork_name cherrypick_${prefix}_${hash}
  40. git checkout $from_branch
  41. fi
  42. done
  43. echo "Please review the PRs, add [FBCode->GH] prefix in the title and publish them."
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...