diff --git a/build-tools/branching/create_branches_and_tags.sh b/build-tools/branching/create_branches_and_tags.sh index 85dc8f8c..c71eadbd 100755 --- a/build-tools/branching/create_branches_and_tags.sh +++ b/build-tools/branching/create_branches_and_tags.sh @@ -1,7 +1,7 @@ #!/bin/bash # -# Copyright (c) 2020-2021 Wind River Systems, Inc. +# Copyright (c) 2020-2022 Wind River Systems, Inc. # # SPDX-License-Identifier: Apache-2.0 # @@ -39,6 +39,11 @@ usage () { echo " Create a branch and a tag in all listed projects, and all" echo " projects hosted by all listed remotes. Lists are comma separated." echo "" + echo " [ --exclude-projects= ]" + echo "" + echo " Do not branch the list of projects. Used in conjunction with" + echo " --remotes to branch everything from a remote minus a few projects." + echo "" echo "gitreview options:" echo " Update any .gitreview files in branched projects." echo "" @@ -77,8 +82,9 @@ usage () { echo "" } -TEMP=$(getopt -o h --long remotes:,projects:,branch:,tag:,manifest,manifest-file:,lock-down,hard-lock-down,soft-lock-down,default-revision,gitreview-default,gitreview-project,gitreview-host:,gitreview-port:,safe-gerrit-host:,lock-down-exclude-remotes:,lock-down-exclude-projects:,help -n 'create_branches_and_tags.sh' -- "$@") +TEMP=$(getopt -o h --long remotes:,projects:,exclude-projects:,branch:,tag:,manifest,manifest-file:,lock-down,hard-lock-down,soft-lock-down,default-revision,gitreview-default,gitreview-project,gitreview-host:,gitreview-port:,safe-gerrit-host:,lock-down-exclude-remotes:,lock-down-exclude-projects:,help -n 'create_branches_and_tags.sh' -- "$@") if [ $? -ne 0 ]; then + echo_stderr "ERROR: getopt failure" usage exit 1 fi @@ -95,6 +101,7 @@ GITREVIEW_CHANGE=0 SET_DEFAULT_REVISION=0 remotes="" projects="" +exclude_projects="" ld_exclude_remotes="" ld_exclude_projects="" branch="" @@ -109,6 +116,7 @@ while true ; do -h|--help) HELP=1 ; shift ;; --remotes) remotes+=$(echo "$2 " | tr ',' ' '); shift 2;; --projects) projects+=$(echo "$2 " | tr ',' ' '); shift 2;; + --exclude-projects) exclude_projects+=$(echo "$2 " | tr ',' ' '); shift 2;; --lock-down-exclude-remotes) ld_exclude_remotes+=$(echo "$2 " | tr ',' ' '); shift 2;; --lock-down-exclude-projects) ld_exclude_projects+=$(echo "$2 " | tr ',' ' '); shift 2;; --branch) branch=$2; shift 2;; @@ -287,7 +295,7 @@ if [ $MANIFEST -eq 1 ]; then fi fi -for project in $projects $ld_exclude_projects; do +for project in $projects $exclude_projects $ld_exclude_projects; do if ! repo_is_project $project; then echo_stderr "Invalid project: $project" echo_stderr "Valid projects are: $(repo_project_list | tr '\n' ' ')" @@ -318,11 +326,25 @@ if [ "$projects" == "" ] && [ "$remotes" == "" ]; then projects="$(repo_project_list)" fi +if [ "$projects" != "" ] && [ "$exclude_projects" != "" ]; then + for project in $exclude_projects; do + projects=$(echo $projects | sed -e "s# $project # #" -e "s#^$project ##" -e "s# $project\$##" -e "s#^$project\$##") + done +fi + if [ "$projects" == "" ]; then echo_stderr "No projects found" exit 1 fi +echo "List of projects to be branched" +echo "===============================" +for project in $projects; do + echo $project +done +echo "===============================" +echo + # Provide a default tag name if not otherwise provided if [ "$tag" == "" ]; then tag="v$branch" diff --git a/build-tools/branching/create_tags.sh b/build-tools/branching/create_tags.sh index 57897d4e..a8f1a2e5 100755 --- a/build-tools/branching/create_tags.sh +++ b/build-tools/branching/create_tags.sh @@ -1,7 +1,7 @@ #!/bin/bash # -# Copyright (c) 2020-2021 Wind River Systems, Inc. +# Copyright (c) 2020-2022 Wind River Systems, Inc. # # SPDX-License-Identifier: Apache-2.0 # @@ -34,6 +34,11 @@ usage () { echo " Create a branch and a tag in all listed projects, and all" echo " projects hosted by all listed remotes. Lists are comma separated." echo "" + echo " [ --exclude-projects= ]" + echo "" + echo " Do not branch the list of projects. Used in conjunction with" + echo " --remotes to branch everything from a remote minus a few projects." + echo "" echo "manifest options:" echo " [ --manifest ]" echo " Modify the current repo manifest to specify the" @@ -62,8 +67,9 @@ usage () { echo "" } -TEMP=$(getopt -o h --long remotes:,projects:,tag:,manifest,manifest-file:,manifest-prefix:,lock-down,hard-lock-down,soft-lock-down,default-revision,safe-gerrit-host:,lock-down-exclude-remotes:,lock-down-exclude-projects:,help -n 'create_tags.sh' -- "$@") +TEMP=$(getopt -o h --long remotes:,projects:,exclude-projects:,tag:,manifest,manifest-file:,manifest-prefix:,lock-down,hard-lock-down,soft-lock-down,default-revision,safe-gerrit-host:,lock-down-exclude-remotes:,lock-down-exclude-projects:,help -n 'create_tags.sh' -- "$@") if [ $? -ne 0 ]; then + echo_stderr "ERROR: getopt failure" usage exit 1 fi @@ -75,6 +81,7 @@ LOCK_DOWN=0 SET_DEFAULT_REVISION=0 remotes="" projects="" +exclude_projects="" ld_exclude_remotes="" ld_exclude_projects="" tag="" @@ -89,6 +96,7 @@ while true ; do -h|--help) HELP=1 ; shift ;; --remotes) remotes+=$(echo "$2 " | tr ',' ' '); shift 2;; --projects) projects+=$(echo "$2 " | tr ',' ' '); shift 2;; + --exclude-projects) exclude_projects+=$(echo "$2 " | tr ',' ' '); shift 2;; --lock-down-exclude-remotes) ld_exclude_remotes+=$(echo "$2 " | tr ',' ' '); shift 2;; --lock-down-exclude-projects) ld_exclude_projects+=$(echo "$2 " | tr ',' ' '); shift 2;; --tag) tag=$2; shift 2;; @@ -101,9 +109,10 @@ while true ; do --default-revision) SET_DEFAULT_REVISION=1 ; shift ;; --safe-gerrit-host) safe_gerrit_hosts+=("$2") ; shift 2 ;; --) shift ; break ;; - *) usage; exit 1 ;; + *) echo "unknown option $1"; usage; exit 1 ;; esac done + git_set_safe_gerrit_hosts "${safe_gerrit_hosts[@]}" if [ $HELP -eq 1 ]; then @@ -142,7 +151,7 @@ if [ $MANIFEST -eq 1 ]; then fi fi -for project in $projects $ld_exclude_projects; do +for project in $projects $exclude_projects $ld_exclude_projects; do if ! repo_is_project $project; then echo_stderr "Invalid project: $project" echo_stderr "Valid projects are: $(repo_project_list | tr '\n' ' ')" @@ -172,11 +181,24 @@ if [ "$projects" == "" ] && [ "$remotes" == "" ]; then projects="$(repo_project_list)" fi +if [ "$projects" != "" ] && [ "$exclude_projects" != "" ]; then + for project in $exclude_projects; do + projects=$(echo $projects | sed -e "s# $project # #" -e "s#^$project ##" -e "s# $project\$##" -e "s#^$project\$##") + done +fi + if [ "$projects" == "" ]; then echo_stderr "No projects found" exit 1 fi +echo "List of projects to be tagged" +echo "=============================" +for project in $projects; do + echo $project +done +echo "=============================" +echo echo "Finding subgits" SUBGITS=$(repo forall $projects -c 'echo '"$repo_root_dir"'/$REPO_PATH') diff --git a/build-tools/branching/push_branches_tags.sh b/build-tools/branching/push_branches_tags.sh index 49e5ee06..3d73bec3 100755 --- a/build-tools/branching/push_branches_tags.sh +++ b/build-tools/branching/push_branches_tags.sh @@ -1,7 +1,7 @@ #!/bin/bash # -# Copyright (c) 2020-2021 Wind River Systems, Inc. +# Copyright (c) 2020-2022 Wind River Systems, Inc. # # SPDX-License-Identifier: Apache-2.0 # @@ -22,12 +22,14 @@ source "${PUSH_BRANCHES_TAGS_SH_DIR}/../url_utils.sh" usage () { echo "push_branches_tags.sh --branch= [--tag=]" echo " [ --remotes= ] [ --projects= ]" + echo " [ --exclude-projects= ]" echo " [ --manifest [ --manifest-file= ] ]" echo " [ --bypass-gerrit] [--safe-gerrit-host=]" echo " [ --dry-run ]" echo "" echo "Push a pre-existing branch and tag into all listed projects, and all" - echo "projects hosted by all listed remotes. Lists are comma separated." + echo "projects hosted by all listed remotes, minus excluded projects." + echo "Lists are comma separated." echo "" echo "The branch name must be provided. The tag name can also be provided." echo "If the tag is omitted, one is automativally generate by adding the" @@ -43,8 +45,9 @@ usage () { echo "--dry-run will print out git push commands without executing them" } -TEMP=$(getopt -o h,n --long remotes:,projects:,branch:,tag:,bypass-gerrit,manifest,manifest-file:,safe-gerrit-host:,help,dry-run -n 'push_branches_tags.sh' -- "$@") +TEMP=$(getopt -o h,n --long remotes:,projects:,exclude-projects:,branch:,tag:,bypass-gerrit,manifest,manifest-file:,safe-gerrit-host:,help,dry-run -n 'push_branches_tags.sh' -- "$@") if [ $? -ne 0 ]; then + echo_stderr "ERROR: getopt failure" usage exit 1 fi @@ -56,6 +59,7 @@ BYPASS_GERRIT=0 DRY_RUN= remotes="" projects="" +excluded_projects="" branch="" tag="" manifest="" @@ -69,6 +73,7 @@ while true ; do --bypass-gerrit) BYPASS_GERRIT=1 ; shift ;; --remotes) remotes+=$(echo "$2 " | tr ',' ' '); shift 2;; --projects) projects+=$(echo "$2 " | tr ',' ' '); shift 2;; + --exclude-projects) excluded_projects+=$(echo "$2 " | tr ',' ' '); shift 2;; --branch) branch=$2; shift 2;; --tag) tag=$2; shift 2;; --manifest) MANIFEST=1 ; shift ;; @@ -123,7 +128,7 @@ if [ $MANIFEST -eq 1 ]; then \cp -f "${manifest}.save" "${manifest}" fi -for project in $projects; do +for project in $projects $excluded_projects; do if ! repo_is_project $project; then echo_stderr "Invalid project: $project" echo_stderr "Valid projects are: $(repo_project_list | tr '\n' ' ')" @@ -149,11 +154,25 @@ if [ "$projects" == "" ] && [ "$remotes" == "" ]; then projects="$(repo_project_list)" fi +if [ "$projects" != "" ] && [ "$exclude_projects" != "" ]; then + for project in $exclude_projects; do + projects=$(echo $projects | sed -e "s# $project # #" -e "s#^$project ##" -e "s# $project\$##" -e "s#^$project\$##") + done +fi + if [ "$projects" == "" ]; then echo_stderr "No projects found" exit 1 fi +echo "List of projects to be pushed" +echo "=============================" +for project in $projects; do + echo $project +done +echo "=============================" +echo + # Provide a default tag name if not otherwise provided if [ "$tag" == "" ]; then tag="v$branch" diff --git a/build-tools/branching/push_tags.sh b/build-tools/branching/push_tags.sh index 01ace224..f2deb9be 100755 --- a/build-tools/branching/push_tags.sh +++ b/build-tools/branching/push_tags.sh @@ -1,7 +1,7 @@ #!/bin/bash # -# Copyright (c) 2020-2021 Wind River Systems, Inc. +# Copyright (c) 2020-2022 Wind River Systems, Inc. # # SPDX-License-Identifier: Apache-2.0 # @@ -20,12 +20,14 @@ source "${PUSH_TAGS_SH_DIR}/../git-repo-utils.sh" usage () { echo "push_tags.sh --tag= [ --remotes= ] [ --projects= ]" + echo " [ --exclude-projects= ]" echo " [ --manifest [ --manifest-file= ] [--manifest-prefix ]]" echo " [ --bypass-gerrit ] [--safe-gerrit-host=]" echo " [ --dry-run ]" echo " " echo "Push a pre-existing git tag into all listed projects, and all projects" - echo "hosted by all listed remotes. Lists are comma separated." + echo "hosted by all listed remotes, minus excluded projects." + echo "Lists are comma separated." echo "" echo "A manifest push can also be requested." echo "" @@ -36,8 +38,9 @@ usage () { } -TEMP=$(getopt -o h,n --long remotes:,projects:,tag:,manifest,manifest-file:,manifest-prefix:,bypass-gerrit,safe-gerrit-host:,help,dry-run -n 'push_tags.sh' -- "$@") +TEMP=$(getopt -o h,n --long remotes:,projects:,exclude-projects:,tag:,manifest,manifest-file:,manifest-prefix:,bypass-gerrit,safe-gerrit-host:,help,dry-run -n 'push_tags.sh' -- "$@") if [ $? -ne 0 ]; then + echo_stderr "ERROR: getopt failure" usage exit 1 fi @@ -49,6 +52,7 @@ MANIFEST=0 BYPASS_GERRIT=0 remotes="" projects="" +excluded_projects="" tag="" manifest="" manifest_prefix="" @@ -63,6 +67,7 @@ while true ; do --bypass-gerrit) BYPASS_GERRIT=1 ; shift ;; --remotes) remotes+=$(echo "$2 " | tr ',' ' '); shift 2;; --projects) projects+=$(echo "$2 " | tr ',' ' '); shift 2;; + --exclude-projects) excluded_projects+=$(echo "$2 " | tr ',' ' '); shift 2;; --tag) tag=$2; shift 2;; --manifest) MANIFEST=1 ; shift ;; --manifest-file) repo_set_manifest_file "$2"; shift 2;; @@ -110,7 +115,7 @@ if [ $MANIFEST -eq 1 ]; then fi fi -for project in $projects; do +for project in $projects $excluded_projects; do if ! repo_is_project $project; then echo_stderr "Invalid project: $project" echo_stderr "Valid projects are: $(repo_project_list | tr '\n' ' ')" @@ -136,11 +141,24 @@ if [ "$projects" == "" ] && [ "$remotes" == "" ]; then projects="$(repo_project_list)" fi +if [ "$projects" != "" ] && [ "$exclude_projects" != "" ]; then + for project in $exclude_projects; do + projects=$(echo $projects | sed -e "s# $project # #" -e "s#^$project ##" -e "s# $project\$##" -e "s#^$project\$##") + done +fi + if [ "$projects" == "" ]; then echo_stderr "No projects found" exit 1 fi +echo "List of projects to be pushed" +echo "=============================" +for project in $projects; do + echo $project +done +echo "=============================" +echo echo "Finding subgits" SUBGITS=$(repo forall $projects -c 'echo '"$repo_root_dir"'/$REPO_PATH')