diff options
Diffstat (limited to 'tcwg-upstream2gerrit.sh')
-rwxr-xr-x | tcwg-upstream2gerrit.sh | 147 |
1 files changed, 0 insertions, 147 deletions
diff --git a/tcwg-upstream2gerrit.sh b/tcwg-upstream2gerrit.sh deleted file mode 100755 index 03c5b893..00000000 --- a/tcwg-upstream2gerrit.sh +++ /dev/null @@ -1,147 +0,0 @@ -#!/bin/bash - -set -ef -o pipefail - -# shellcheck source=jenkins-helpers.sh -. "$(dirname $0)"/jenkins-helpers.sh -convert_args_to_variables "$@" - -# Make shellcheck happy and workaround Jenkins not defining variables -# for empty arguments. -branch="${branch-master}" -patches="${patches-last}" -project="${project-gcc}" -squash="${squash-false}" -filter="${filter-false}" -verbose="${verbose-true}" - -# Jenkins doesn't define variables when parameter value is empty, -# so enable "set -u" only after above binding of variables. -set -u - -if $verbose; then set -x; fi - -rm -f pwclient -wget http://people.linaro.org/~maxim.kuvyrkov/pwclient/pwclient - -pwc="$(pwd)/pwclient" -chmod +x "$pwc" -sed -i -e "s#~/.pwclientrc#$(pwd)/pwclientrc#g" "$pwc" -cat > pwclientrc <<EOF -[options] -default=$project - -[$project] -url= https://patches-$project.linaro.org/xmlrpc/ -EOF - -last_id=$($pwc list -N 1 -f "%{id}") -if [ "$last_id" = "" ]; then - echo "ERROR: Cannot fetch last patch id." - exit 1 -fi - -patches=$(echo "$patches" | sed -e "s/last/$last_id/g") - -refdir=/home/tcwg-buildslave/snapshots-ref/$project.git -if ! [ -d $refdir/.git ]; then - refdir="" -fi - -clone_or_update_repo $project refs/heads/$branch https://git-us.linaro.org/toolchain/$project $refdir - -cd $project -cat > .gitreview <<EOF -[gerrit] -host=review.linaro.org -port=29418 -project=toolchain/$project -EOF -git review -s -rm .gitreview - -case "$project" in - "gcc") - # Attempt to apply patches to nested gcc/ directory if top-level - # fails. - try_dirs=". gcc" - ;; - *) try_dirs="." ;; -esac - -patch_file=$(mktemp) -# shellcheck disable=SC2064 -trap "rm -f $patch_file /tmp/mydiff.$$" EXIT - -count="0" -for patch in $patches; do - download_file=$($pwc get -p $project $patch | sed -e "s/Saved patch to //") - mv $download_file $patch_file - - res=0 - git reset --hard - git clean -df - if grep -q "diff --git" $patch_file; then - git am $patch_file || res=$? - if [ "$res" = "0" ]; then - git commit --amend --reset-author -C HEAD - else - git am --abort - fi - else - for dir in $try_dirs; do - pushd $dir - git reset --hard - git clean -df - patch -f -p0 < $patch_file || res=$? - if [ "$res" = "0" ]; then - git add . - git commit -m "Patch #$patch" - fi - popd - if [ "$res" = "0" ]; then - break - fi - done - fi - if [ "$res" != "0" ]; then - echo "ERROR: Cannot apply patch $patch" - exit 1 - fi - count=$(($count+1)) -done - -# Apply the filter once the patch series has been applied, to decide -# whether we actually want review and validation -keepit=true -if $filter; then - keepit=false - git diff HEAD~$count..HEAD > /tmp/mydiff.$$ - - # Keep commits impacting ARM or AArch64 - wanted1=0 - # Search the exact words arm, thumb or aarch64 - egrep '^[-+]' /tmp/mydiff.$$ | egrep -w -i 'arm|thumb|aarch64' || wanted1=$? - wanted2=0 - # Search the same strings with '_' prefix or suffix, excluding string with 'parm' - egrep '^[-+]' /tmp/mydiff.$$ | egrep -i '_arm|arm_|_thumb|thumb_|_aarch64|aarch64_' | grep -v -i 'parm' || wanted2=$? - if [ $wanted1 -eq 0 ] || [ $wanted2 -eq 0 ] - then - keepit=true - else - # We could keep commits from ARM, Linaro, or whitelist if we had a ChangeLog - echo "Cannot filter authors without a ChangeLog" - keepit=false - fi -fi - -if ! $keepit; then - echo "The filter decided to skip this patch" - exit 0 -fi - -if $squash; then - git reset --soft HEAD~$count - git commit -m "Patches: $patches" -fi -git review -y "$branch" |