mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
scripts: Make the git scripts show usage messages
All of the git scripts now have usage messages on: * a new -h option, and * usage errors. Closes 31677.
This commit is contained in:
+53
-21
@@ -1,17 +1,39 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
##################################
|
||||
# User configuration (change me) #
|
||||
##################################
|
||||
SCRIPT_NAME=`basename $0`
|
||||
|
||||
# The general setup that is suggested here is:
|
||||
#
|
||||
# GIT_PATH = /home/<user>/git/
|
||||
# ... where the git repository directories resides.
|
||||
# TOR_MASTER_NAME = "tor"
|
||||
# ... which means that tor.git was cloned in /home/<user>/git/tor
|
||||
# TOR_WKT_NAME = "tor-wkt"
|
||||
# ... which means that the tor worktrees are in /home/<user>/git/tor-wkt
|
||||
function usage()
|
||||
{
|
||||
echo "$SCRIPT_NAME [-h] [-n]"
|
||||
echo
|
||||
echo " arguments:"
|
||||
echo " -h: show this help text"
|
||||
echo " -n: dry run mode"
|
||||
echo " (default: run commands)"
|
||||
echo
|
||||
echo " env vars:"
|
||||
echo " required:"
|
||||
echo " TOR_FULL_GIT_PATH: where the git repository directories reside."
|
||||
echo " You must set this env var, we recommend \$HOME/git/"
|
||||
echo " (default: fail if this env var is not set;"
|
||||
echo " current: $GIT_PATH)"
|
||||
echo
|
||||
echo " optional:"
|
||||
echo " TOR_MASTER: the name of the directory containing the tor.git clone"
|
||||
echo " The tor master git directory is \$GIT_PATH/\$TOR_MASTER"
|
||||
echo " (default: tor; current: $TOR_MASTER_NAME)"
|
||||
echo " TOR_WKT_NAME: the name of the directory containing the tor"
|
||||
echo " worktrees. The tor worktrees are:"
|
||||
echo " \$GIT_PATH/\$TOR_WKT_NAME/{maint-*,release-*}"
|
||||
echo " (default: tor-wkt; current: $TOR_WKT_NAME)"
|
||||
echo " we recommend that you set these env vars in your ~/.profile"
|
||||
}
|
||||
|
||||
#################
|
||||
# Configuration #
|
||||
#################
|
||||
|
||||
# Don't change this configuration - set the env vars in your .profile
|
||||
|
||||
# Where are all those git repositories?
|
||||
GIT_PATH=${TOR_FULL_GIT_PATH:-"FULL_PATH_TO_GIT_REPOSITORY_DIRECTORY"}
|
||||
@@ -88,10 +110,30 @@ WORKTREE=(
|
||||
)
|
||||
COUNT=${#WORKTREE[@]}
|
||||
|
||||
#######################
|
||||
# Argument processing #
|
||||
#######################
|
||||
|
||||
# Controlled by the -n option. The dry run option will just output the command
|
||||
# that would have been executed for each worktree.
|
||||
DRY_RUN=0
|
||||
|
||||
while getopts "hn" opt; do
|
||||
case "$opt" in
|
||||
h) usage
|
||||
exit 0
|
||||
;;
|
||||
n) DRY_RUN=1
|
||||
echo " *** DRY DRUN MODE ***"
|
||||
;;
|
||||
*)
|
||||
echo
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
#############
|
||||
# Constants #
|
||||
#############
|
||||
@@ -195,16 +237,6 @@ function fetch_tor_github
|
||||
# Entry point #
|
||||
###############
|
||||
|
||||
while getopts "n" opt; do
|
||||
case "$opt" in
|
||||
n) DRY_RUN=1
|
||||
echo " *** DRY DRUN MODE ***"
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# First, fetch tor-github.
|
||||
goto_repo "$ORIGIN_PATH"
|
||||
fetch_tor_github
|
||||
|
||||
Reference in New Issue
Block a user