@@ -47,47 +47,27 @@ function cli_patch_kernel_run() {
47
47
obtain_kernel_git_info_and_makefile # this populates GIT_INFO_KERNEL and sets KERNEL_GIT_SHA1 readonly global
48
48
# </prepare the git sha1>
49
49
50
- declare ymd vendor_lc target_repo_url summary_url
51
- ymd=" $( date +%Y%m%d) "
52
- # lowercase ${VENDOR} and replace spaces with underscores
53
- vendor_lc=" $( tr ' [:upper:]' ' [:lower:]' <<< " ${VENDOR}" | tr ' ' ' _' ) -next"
54
- target_branch=" ${vendor_lc} -${LINUXFAMILY} -${KERNEL_MAJOR_MINOR} -${ymd}${PUSH_BRANCH_POSTFIX:- " " } "
55
- target_repo_url=" git@github.com:${PUSH_TO_REPO:- " ${PUSH_TO_USER:- " rpardini" } /${PUSH_TO_REPO:- " linux" } " } .git"
56
- summary_url=" https://${PUSH_TO_USER:- " rpardini" } .github.io/${PUSH_TO_REPO:- " linux" } /${target_branch} .html"
57
-
58
- declare -a push_command
59
- push_command=(git -C " ${SRC} /cache/git-bare/kernel" push " --force" " --verbose"
60
- " ${target_repo_url} "
61
- " kernel-${LINUXFAMILY} -${KERNEL_MAJOR_MINOR} :${target_branch} " )
50
+ # prepare push details, if set
51
+ declare target_repo_url target_branch do_push=" no"
52
+ declare -a push_command=()
53
+ determine_git_push_details " ${LINUXFAMILY} -${KERNEL_MAJOR_MINOR} " # fills in the above; parameter is the branch name
62
54
63
55
# Prepare the host and build kernel; without using standard build
64
56
prepare_host # This handles its own logging sections, and is possibly interactive.
65
57
compile_kernel # This handles its own logging sections.
66
58
67
59
display_alert " Done patching kernel" " ${BRANCH} - ${LINUXFAMILY} - ${KERNEL_MAJOR_MINOR} " " cachehit"
68
60
69
- declare do_push=" no"
70
- if git -C " ${SRC} " remote get-url origin & > /dev/null; then
71
- declare src_origin_url
72
- src_origin_url=" $( git -C " ${SRC} " remote get-url origin | xargs echo -n) "
73
-
74
- declare prefix=" git@github.com:${PUSH_TO_USER:- " rpardini" } /" # @TODO refactor var
75
- # if the src_origin_url begins with the prefix
76
- if [[ " ${src_origin_url} " == " ${prefix} " * ]]; then
77
- do_push=" yes"
78
- fi
79
- fi
80
-
81
- display_alert " Git push command: " " ${push_command[*]} " " info"
82
61
if [[ " ${do_push} " == " yes" ]]; then
83
- display_alert " Pushing to ${target_branch} " " ${target_repo_url} " " info"
62
+ display_alert " Pushing kernel to Git branch ${target_branch} " " ${target_repo_url} " " info"
84
63
git_ensure_safe_directory " ${SRC} /cache/git-bare/kernel"
85
- # @TODO: do NOT allow shallow trees here, we need the full history to be able to push
86
- GIT_SSH_COMMAND= " ssh -o GlobalKnownHostsFile=/dev/null -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no " " ${push_command[@]} "
87
- display_alert " Done pushing to ${target_branch} " " ${summary_url} " " info "
64
+ push_command=(git -C " ${SRC} /cache/git-bare/kernel " push " --force " " --verbose " " ${target_repo_url} " " kernel- ${LINUXFAMILY} - ${KERNEL_MAJOR_MINOR} : ${target_branch} " )
65
+ display_alert " Git push command: " " ${push_command[*]} " " info "
66
+ execute_git_push
88
67
fi
89
68
90
- display_alert " Summary URL (after push & gh-pages deploy): " " ${summary_url} " " info"
69
+ return 0
70
+
91
71
}
92
72
93
73
# # Similar stuff as kernel, but for u-boot.
@@ -108,6 +88,11 @@ function cli_patch_uboot_run() {
108
88
[[ " ${GIT_INFO_UBOOT[SHA1]} " =~ ^[0-9a-f]{40}$ ]] || exit_with_error " SHA1 is not sane: '${GIT_INFO_UBOOT[SHA1]} '"
109
89
# </prepare the git sha1>
110
90
91
+ # prepare push details, if set
92
+ declare target_repo_url target_branch do_push=" no"
93
+ declare -a push_command=()
94
+ determine_git_push_details " ${BOARD} -${BRANCH} " # fills in the above; parameter is the branch name
95
+
111
96
# Prepare the host
112
97
prepare_host # This handles its own logging sections, and is possibly interactive.
113
98
@@ -123,4 +108,39 @@ function cli_patch_uboot_run() {
123
108
LOG_SECTION=" patch_uboot_target" do_with_logging patch_uboot_target
124
109
125
110
display_alert " Done patching u-boot" " ${BRANCH} - ${LINUXFAMILY} - ${BOOTSOURCE} #${BOOTBRANCH} " " cachehit"
111
+
112
+ if [[ " ${do_push} " == " yes" ]]; then
113
+ display_alert " Pushing u-boot to Git branch ${target_branch} " " ${target_repo_url} " " info"
114
+ git_ensure_safe_directory " ${SRC} /cache/git-bare/u-boot"
115
+ push_command=(git -C " ${SRC} /cache/git-bare/u-boot" push " --force" " --verbose" " ${target_repo_url} " " u-boot-${BRANCH} -${BOARD} :${target_branch} " )
116
+ display_alert " Git push command: " " ${push_command[*]} " " info"
117
+ execute_git_push
118
+ fi
119
+
120
+ }
121
+
122
+ function determine_git_push_details() {
123
+ if [[ -n " ${PUSH_TO_GITHUB} " ]]; then
124
+ PUSH_TO_REPO=" git@github.com:${PUSH_TO_GITHUB} .git"
125
+ display_alert " Will push to GitHub" " ${PUSH_TO_REPO} " " info"
126
+ fi
127
+
128
+ if [[ -n " ${PUSH_TO_REPO} " ]]; then
129
+ do_push=" yes"
130
+ declare ymd vendor_lc
131
+ ymd=" $( date +%Y%m%d) "
132
+ vendor_lc=" $( tr ' [:upper:]' ' [:lower:]' <<< " ${VENDOR}" | tr ' ' ' _' ) " # lowercase ${VENDOR} and replace spaces with underscores
133
+ target_branch=" ${vendor_lc} -${1} -${ymd}${PUSH_BRANCH_POSTFIX:- " " } "
134
+ target_repo_url=" ${PUSH_TO_REPO} "
135
+ display_alert " Will push to Git" " ${target_repo_url} branch ${target_branch} " " info"
136
+ else
137
+ display_alert " Will NOT push to Git" " use PUSH_TO_GITHUB=org/repo or PUSH_TO_REPO=<url> to push" " info"
138
+ fi
139
+ }
140
+
141
+ function execute_git_push() {
142
+ display_alert " Pushing to ${target_branch} " " ${target_repo_url} " " info"
143
+ # @TODO: do NOT allow shallow trees here, we need the full history to be able to push
144
+ GIT_SSH_COMMAND=" ssh -o GlobalKnownHostsFile=/dev/null -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" " ${push_command[@]} "
145
+ display_alert " Done pushing to ${target_branch} " " ${target_repo_url} " " info"
126
146
}
0 commit comments