|
1 |
| -# Usage: cherrypick.sh <source_ydblib_repo_root> <target_ydb_repo_root> |
2 |
| -# Expects previous github SHA in <target_ydb_repo_root>/library_import.txt |
3 |
| -# Will loop through the commits in the source repo after previous SHA, and cherry-pick is to the target. |
| 1 | +# Usage: cherrypick.sh <ydb_repo_root> |
| 2 | +# Expects previous github SHA in <ydb_repo_root>/library_import.txt |
| 3 | +# Reads new commits from the 'rightlib' branch, cheery-picks them to a new branch, and creates PR |
4 | 4 |
|
5 | 5 | set -e
|
6 | 6 | set -o pipefail
|
7 | 7 |
|
8 |
| -LIB_ROOT=$1 |
9 |
| -if [ -z "${LIB_ROOT}" ]; then |
10 |
| - echo "Source lib root must be provided as a first free arg" |
| 8 | +ROOT=$1 |
| 9 | +if [ -z "${ROOT}" ]; then |
| 10 | + echo "YDB repo root must be provided as a first free arg" |
11 | 11 | exit 1
|
12 | 12 | fi
|
13 |
| -echo "Source library root: ${LIB_ROOT}" |
14 |
| -newsha=$(cd ${LIB_ROOT} && git rev-parse HEAD) |
15 |
| -echo "Source current commit sha: $newsha" |
| 13 | +echo "YDB repo root: ${ROOT}" |
16 | 14 |
|
17 |
| -MAIN_ROOT=$2 |
18 |
| -if [ -z "${MAIN_ROOT}" ]; then |
19 |
| - echo "Target main root must be provided as a second free arg" |
20 |
| - exit 1 |
21 |
| -fi |
22 |
| -echo "Target Main root: ${MAIN_ROOT}" |
23 |
| -shapath="${MAIN_ROOT}/library_import.txt" |
| 15 | +shapath="${ROOT}/library/rightlib_sha.txt" |
24 | 16 | prevsha=$(cat ${shapath}) || true
|
25 | 17 | if [ -z "${prevsha}" ]; then
|
26 | 18 | echo "File ${shapath} not found, which must contain previous completed import commit SHA"
|
27 | 19 | exit 1
|
28 | 20 | fi
|
29 | 21 | echo "Previous sha: ${prevsha}"
|
30 | 22 |
|
31 |
| -list=$(cd ${LIB_ROOT} && git log ${prevsha}..HEAD --pretty=oneline --no-decorate | awk '{print $1}') |
| 23 | +newsha=$(cd ${ROOT} && git rev-parse rightlib) |
| 24 | +echo "Rightlib current commit sha: $newsha" |
| 25 | + |
| 26 | +list=$(cd ${ROOT} && git log ${prevsha}..rightlib --reverse --pretty=oneline --no-decorate | awk '{print $1}') |
32 | 27 | for sha in $list;do
|
33 | 28 | echo $sha
|
34 |
| - (cd ${MAIN_ROOT} && git --git-dir=${LIB_ROOT}/.git format-patch -k -1 --stdout $sha | git am -3 -k) |
| 29 | + (cd ${ROOT} && git cherry-pick $sha) |
35 | 30 | echo "---"
|
36 | 31 | done
|
37 | 32 |
|
|
0 commit comments