|
3 | 3 | set -e |
4 | 4 | set -u |
5 | 5 |
|
6 | | -# this script prepares a branch of LoopWorkspace based on current local branch. |
7 | | -# It brings in the tip of all the submodule branches which should have just |
8 | | -# been updated with the manual download, import, review and finalize scripts. |
9 | | -# After all those PR are merged and the translation branches trimmed, |
10 | | -# the next step is to prepare the PR to update LoopWorkspace dev branch |
| 6 | +# this script prepares a PR for LoopWorkspace based on current local branch |
11 | 7 |
|
12 | 8 | source Scripts/define_common.sh |
13 | 9 |
|
14 | 10 | section_divider |
15 | | - |
16 | | -echo "You must be in the LoopWorkspace folder ready to bring in " |
17 | | -echo " all the latest versions of the submodules which were " |
18 | | -echo " just translated" |
19 | | -echo "" |
20 | | -echo "This script will prepare a PR to LoopWorkspace '${target_loopworkspace_branch}' branch" |
21 | | -echo "" |
22 | | -echo "1. If the branch name is not already '${translation_branch}', then" |
| 11 | +echo "You are running ${0}" |
| 12 | +echo " You must be in the LoopWorkspace folder ready to commit changes to" |
| 13 | +echo " tracked files in this clone, see 'git status' results below:" |
| 14 | +section_divider |
| 15 | +git status |
| 16 | +section_divider |
| 17 | +echo "This script will prepare a PR to LoopWorkspace '${TARGET_LOOPWORKSPACE_BRANCH}' branch" |
| 18 | +echo |
| 19 | +echo "1. If the local clone LoopWorkspace branch name is not already '${TRANSLATION_BRANCH}', then" |
23 | 20 | echo " that branch will be created and used for this PR" |
24 | | -echo "2. ./Scripts/update_submodule_refs.sh will be executed" |
25 | | -echo "3. The commit message in the ${message_file} will be used" |
26 | | -cat ${message_file} |
27 | | -echo "4. Once the PR is prepared, additional commits can be added as needed" |
| 21 | +echo "2. The commit message in the ${MESSAGE_FILE} will be used" |
| 22 | +cat ${MESSAGE_FILE} |
| 23 | +echo "3. Once the PR is prepared, additional commits can be added as needed" |
28 | 24 |
|
29 | | -section_divider |
| 25 | +continue_or_quit ${0} |
30 | 26 |
|
31 | | -echo "Enter y to proceed, any other character exits" |
32 | | -read query |
| 27 | +current_branch=$(git branch --show-current 2>/dev/null) |
| 28 | +echo "current_branch = $current_branch" |
33 | 29 |
|
34 | | -if [[ ${query} == "y" ]]; then |
| 30 | +if [[ "${current_branch}" == "${TRANSLATION_BRANCH}" ]]; then |
| 31 | + echo "already on $TRANSLATION_BRANCH, ok to continue" |
35 | 32 |
|
36 | | - current_branch=$(git branch --show-current 2>/dev/null) |
37 | | - echo "current_branch = $current_branch" |
| 33 | +elif [ -n "$(git branch --list "$TRANSLATION_BRANCH")" ]; then |
| 34 | + echo "Local branch '$TRANSLATION_BRANCH' exists." |
| 35 | + echo "You are on '$current_branch' and '$TRANSLATION_BRANCH' already exists" |
| 36 | + echo "quitting" |
| 37 | + exit 1 # exit with failure |
38 | 38 |
|
39 | | - if [[ "${current_branch}" == "${translation_branch}" ]]; then |
40 | | - echo "already on $translation_branch, ok to continue" |
41 | | - |
42 | | - elif [ -n "$(git branch --list "$translation_branch")" ]; then |
43 | | - echo "Local branch '$translation_branch' exists." |
44 | | - echo "You are on '$current_branch' and '$translation_branch' already exists" |
45 | | - echo "quitting" |
46 | | - exit 1 # exit with failure |
47 | | - |
48 | | - else |
49 | | - echo "Local branch $translation_branch does not exist," |
50 | | - echo "creating $translation_branch from the current branch, $current_branch." |
51 | | - git switch -c "${translation_branch}" |
52 | | - fi |
| 39 | +else |
| 40 | + echo "Local branch $TRANSLATION_BRANCH does not exist," |
| 41 | + echo "creating $TRANSLATION_BRANCH from the current branch, $current_branch." |
| 42 | + git switch -c "${TRANSLATION_BRANCH}" |
| 43 | +fi |
53 | 44 |
|
54 | | - section_divider |
| 45 | +continue_or_quit ${0} |
55 | 46 |
|
56 | | - ./Scripts/update_submodule_refs.sh |
| 47 | +# only create a PR if there are changes |
| 48 | +if git commit -a -F "${MESSAGE_FILE}"; then |
| 49 | + git push --set-upstream origin ${TRANSLATION_BRANCH} |
| 50 | + pr=$(gh pr create -B ${TARGET_LOOPWORKSPACE_BRANCH} --fill 2>&1 | grep http) |
| 51 | + echo "PR = $pr" |
| 52 | + open $pr |
57 | 53 |
|
58 | 54 | section_divider |
59 | | - |
60 | | - # only create a PR if there are changes |
61 | | - if git commit -a -F "${message_file}"; then |
62 | | - git push --set-upstream origin ${translation_branch} |
63 | | - pr=$(gh pr create -B ${target_loopworkspace_branch} --fill 2>&1 | grep http) |
64 | | - echo "PR = $pr" |
65 | | - open $pr |
66 | | - |
67 | | - section_divider |
68 | | - echo "After you review, ${pr}, get approvals and merge the PR" |
69 | | - echo " be sure to trim the '${translation_branch}' branch," |
70 | | - echo " and then run the export and upload scripts again from the updated '${target_loopworkspace_branch}' branch" |
71 | | - section_divider |
72 | | - |
73 | | - else |
74 | | - section_divider |
75 | | - echo "No changes were found, no PR created" |
76 | | - section_divider |
77 | | - fi |
| 55 | + echo "After you review, ${pr}, get approvals and merge the PR" |
| 56 | + echo " be sure to trim the '${TRANSLATION_BRANCH}' branch," |
| 57 | + echo " and then run the export and upload scripts again from the updated '${TARGET_LOOPWORKSPACE_BRANCH}' branch" |
| 58 | + section_divider |
78 | 59 |
|
79 | 60 | else |
80 | 61 | section_divider |
81 | | - echo "user opted to exit the script" |
| 62 | + echo "No changes were found, no PR created" |
82 | 63 | section_divider |
83 | 64 | fi |
0 commit comments