Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Tor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Benjamin J. Thompson
Tor
Commits
1371d29e
Commit
1371d29e
authored
5 years ago
by
David Goulet
Browse files
Options
Downloads
Plain Diff
Merge branch 'tor-github/pr/1489'
parents
a76b7cd8
384fe647
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
changes/ticket32347
+7
-0
7 additions, 0 deletions
changes/ticket32347
scripts/git/git-setup-dirs.sh
+47
-2
47 additions, 2 deletions
scripts/git/git-setup-dirs.sh
with
54 additions
and
2 deletions
changes/ticket32347
0 → 100644
+
7
−
0
View file @
1371d29e
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.
This diff is collapsed.
Click to expand it.
scripts/git/git-setup-dirs.sh
+
47
−
2
View file @
1371d29e
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment