3 # Script to be used by other git scripts, and provide a single place
4 # that lists our supported branches. To change which branches are
5 # supported, look at the end of the file that says 'edit here'.
7 SCRIPT_NAME
=$
(basename "$0")
11 echo "$SCRIPT_NAME [-h] [-l|-s|-b|-m] [-R|-M]"
14 echo " -h: show this help text"
16 echo " -l: list the active tor branches (default)"
17 echo " -s: list the suffixes to be used with the active tor branches"
18 echo " -b: write bash code setting WORKTREE to an array of ( branch path ) arrays"
19 echo " -m: write bash code setting WORKTREE to an array of"
20 echo " ( branch parent path suffix parent_suffix ) arrays"
22 echo " -R: omit release branches."
23 echo " -M: omit maint branches."
26 # list : just a list of branch names.
27 # branch_path : For git-setup-dirs.sh and git-pull-all.sh
28 # suffix: write a list of suffixes.
29 # merge: branch, upstream, path, suffix, upstream suffix.
31 skip_maint_branches
="no"
32 skip_release_branches
="no"
34 while getopts "hblmsRM" opt
; do
47 M
) skip_maint_branches
="yes"
49 R
) skip_release_branches
="yes"
51 *) echo "Unknown option"
63 # The name of the branch. (Supplied by caller) Ex: maint-0.4.3
66 # The name of the branch with no dots. Ex: maint-043
67 brname_nodots
="${brname//./}"
68 # The name of the branch with no dots, and _ instead of -. Ex: maint_043
69 brname_nodots_uscore
="${brname_nodots//-/_}"
70 # Name to use for a variable to represent the branch. Ex: MAINT_043
71 varname
="${brname_nodots_uscore^^}"
75 # suffix: a suffix to place at the end of branches we generate with respect
76 # to this branch. Ex: _043
78 # location: where the branch can be found.
80 if [[ "$brname" == "main" ]]; then
82 location
="\$GIT_PATH/\$TOR_MASTER_NAME"
83 elif [[ "$brname" =~ ^maint-
]]; then
84 suffix
="_${brname_nodots#maint-}"
85 location
="\$GIT_PATH/\$TOR_WKT_NAME/$brname"
87 if [[ "$skip_maint_branches" = "yes" ]]; then
90 elif [[ "$brname" =~ ^release-
]]; then
91 suffix
="_r${brname_nodots#release-}"
92 location
="\$GIT_PATH/\$TOR_WKT_NAME/$brname"
94 if [[ "$skip_release_branches" = "yes" ]]; then
98 echo "Unrecognized branch type '${brname}'" >&2
102 all_branch_vars
+=("$varname")
104 # Now emit the per-branch information
105 if [[ "$mode" == "branch_path" ]]; then
106 echo "${varname}=( \"$brname\" \"$location\" )"
107 elif [[ "$mode" == "merge" ]]; then
108 echo "${varname}=( \"$brname\" \"$prev_maint_branch\" \"$location\" \"$suffix\" \"$prev_maint_suffix\" )"
109 elif [[ "$mode" == "list" ]]; then
111 elif [[ "$mode" == "suffix" ]]; then
114 echo "unknown mode $mode" >&2
118 if [[ "$is_maint" == "yes" ]]; then
119 prev_maint_branch
="$brname"
120 prev_maint_suffix
="$suffix"
125 if [[ "$mode" == branch_path
]] ||
[[ "$mode" == merge
]]; then
127 for v
in "${all_branch_vars[@]}"; do
131 elif [[ "$mode" == list
]] ||
[[ "$mode" == suffix
]]; then
135 echo "unknown mode $mode" >&2
140 # ==============================
142 # ==============================
143 # List of all branches. These must be in order, from oldest to newest, with
144 # maint before release.