diff options
author | David Goulet <dgoulet@torproject.org> | 2019-11-14 10:37:14 -0500 |
---|---|---|
committer | David Goulet <dgoulet@torproject.org> | 2019-11-14 10:37:14 -0500 |
commit | 1371d29e5b29e157993a790cd51016d0316df7da (patch) | |
tree | c27ca6f57fa4438fe6b0f61c8b47af6616ea42cf | |
parent | a76b7cd8b5da9951e5e446846ef4e3d9ec6b1453 (diff) | |
parent | 384fe64786de571713a304fd1fc1325e11d093fc (diff) | |
download | tor-1371d29e5b29e157993a790cd51016d0316df7da.tar.gz tor-1371d29e5b29e157993a790cd51016d0316df7da.zip |
Merge branch 'tor-github/pr/1489'
-rw-r--r-- | changes/ticket32347 | 7 | ||||
-rwxr-xr-x | scripts/git/git-setup-dirs.sh | 49 |
2 files changed, 54 insertions, 2 deletions
diff --git a/changes/ticket32347 b/changes/ticket32347 new file mode 100644 index 0000000000..076efe8b42 --- /dev/null +++ b/changes/ticket32347 @@ -0,0 +1,7 @@ + o Minor features (git scripts): + - Make git-setup-dirs.sh create a master symlink in the worktree directory. + Closes ticket 32347. + - Add TOR_EXTRA_CLONE_ARGS to git-setup-dirs.sh for git clone + customisation. Closes ticket 32347. + - Add TOR_EXTRA_REMOTE_* to git-setup-dirs.sh for a custom extra remote. + Closes ticket 32347. diff --git a/scripts/git/git-setup-dirs.sh b/scripts/git/git-setup-dirs.sh index 384c488995..b7a37a04eb 100755 --- a/scripts/git/git-setup-dirs.sh +++ b/scripts/git/git-setup-dirs.sh @@ -40,6 +40,16 @@ function usage() echo " (current: $GITHUB_PULL)" echo " TOR_GITHUB_PUSH: the tor-github remote push URL" echo " (current: $GITHUB_PUSH)" + echo " TOR_EXTRA_CLONE_ARGS: extra arguments to git clone" + echo " (current: $TOR_EXTRA_CLONE_ARGS)" + echo " TOR_EXTRA_REMOTE_NAME: the name of an extra remote" + echo " This remote is not pulled by this script or git-pull-all.sh." + echo " This remote is not pushed by git-push-all.sh." + echo " (current: $TOR_EXTRA_REMOTE_NAME)" + echo " TOR_EXTRA_REMOTE_PULL: the extra remote pull URL." + echo " (current: $TOR_EXTRA_REMOTE_PULL)" + echo " TOR_EXTRA_REMOTE_PUSH: the extra remote push URL" + echo " (current: $TOR_EXTRA_REMOTE_PUSH)" echo " we recommend that you set these env vars in your ~/.profile" } @@ -254,6 +264,25 @@ function make_directory fi } +# Create a symlink from the first argument to the second argument +# If the link already exists: fail if $USE_EXISTING is 0, otherwise skip. +function make_symlink +{ + local cmd="ln -s '$1' '$2'" + printf " %s Creating symlink from %s to %s..." "$MARKER" "$1" "$2" + local check_cmd="[ ! -e '$2' ]" + msg=$( eval "$check_cmd" 2>&1 ) + if validate_ret_skip $? "File already exists."; then + return + fi + if [ $DRY_RUN -eq 0 ]; then + msg=$( eval "$cmd" 2>&1 ) + validate_ret $? "$msg" + else + printf "\\n %s\\n" "${IWTH}$cmd${CNRM}" + fi +} + # Go into the directory or repository, even if $DRY_RUN is non-zero. # If the directory does not exist, fail and log an error. # Otherwise, silently succeed. @@ -269,7 +298,7 @@ function goto_dir # If the directory already exists: fail if $USE_EXISTING is 0, otherwise skip. function clone_repo { - local cmd="git clone '$1' '$2'" + local cmd="git clone $TOR_EXTRA_CLONE_ARGS '$1' '$2'" printf " %s Cloning %s into %s..." "$MARKER" "$1" "$2" local check_cmd="[ ! -d '$2' ]" msg=$( eval "$check_cmd" 2>&1 ) @@ -491,6 +520,17 @@ set_tor_github_pr_fetch_config # Now fetch them all fetch_remote "tor-github" +# Extra remote +if [ "$TOR_EXTRA_REMOTE_NAME" ]; then + printf "%s Setting up remote %s\\n" "$MARKER" \ + "${BYEL}$TOR_EXTRA_REMOTE_NAME${CNRM}" + # Add remote + add_remote "$TOR_EXTRA_REMOTE_NAME" "$TOR_EXTRA_REMOTE_PULL" + set_remote_push "$TOR_EXTRA_REMOTE_NAME" "$TOR_EXTRA_REMOTE_PUSH" + # But leave it to the user to decide if they want to fetch it + #fetch_remote "$TOR_EXTRA_REMOTE_NAME" +fi + # Go over all configured worktree. for ((i=0; i<COUNT; i++)); do branch=${!WORKTREE[$i]:0:1} @@ -498,7 +538,12 @@ for ((i=0; i<COUNT; i++)); do printf "%s Handling branch %s\\n" "$MARKER" "${BYEL}$branch${CNRM}" # We cloned the repository, and master is the default branch - if [ "$branch" != "master" ]; then + if [ "$branch" = "master" ]; then + if [ "$TOR_MASTER_NAME" != "master" ]; then + # Set up a master link in the worktree directory + make_symlink "$repo_path" "$GIT_PATH/$TOR_WKT_NAME/master" + fi + else # git makes worktree directories if they don't exist add_worktree "origin/$branch" "$repo_path" fi |