Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
gitlab-mirrors
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wonko
gitlab-mirrors
Commits
c8e5665c
Commit
c8e5665c
authored
11 years ago
by
Sam Gleske
Browse files
Options
Downloads
Patches
Plain Diff
authors-file path resolution works
parent
e6cc2398
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
add_mirror.sh
+31
-7
31 additions, 7 deletions
add_mirror.sh
with
31 additions
and
7 deletions
add_mirror.sh
+
31
−
7
View file @
c8e5665c
...
...
@@ -8,10 +8,9 @@ set -e
#Include all user options and dependencies
git_mirrors_dir
=
"
$(
dirname
"
${
0
}
"
)
"
cd
"
${
git_mirrors_dir
}
"
.
"config.sh"
.
"lib/VERSION"
.
"lib/functions.sh"
.
"
${
git_mirrors_dir
}
/config.sh"
.
"
${
git_mirrors_dir
}
/lib/VERSION"
.
"
${
git_mirrors_dir
}
/lib/functions.sh"
PROGNAME
=
"
${
0
##*/
}
"
PROGVERSION
=
"
${
VERSION
}
"
...
...
@@ -63,7 +62,7 @@ EOF
}
#Short options are one letter. If an argument follows a short opt then put a colon (:) after it
SHORTOPTS
=
"hvm:p:"
LONGOPTS
=
"help,version,git,svn,mirror:,project-name:"
LONGOPTS
=
"help,version,git,svn,mirror:,project-name:
,authors-file:
"
ARGS
=
$(
getopt
-s
bash
--options
"
${
SHORTOPTS
}
"
--longoptions
"
${
LONGOPTS
}
"
--name
"
${
PROGNAME
}
"
--
"
$@
"
)
eval set
--
"
$ARGS
"
while
true
;
do
...
...
@@ -92,6 +91,10 @@ while true; do
mirror
=
"
${
2
}
"
shift
2
;;
--authors-file
)
authors_file
=
"
${
2
}
"
shift
2
;;
--
)
shift
break
...
...
@@ -136,6 +139,12 @@ function preflight() {
red_echo
" option."
1>&2
STATUS
=
1
fi
if
[
!
-z
"
${
authors_file
}
"
-a
!
-f
"
${
authors_file
}
"
]
;
then
red_echo
-n
"Specified "
yellow_echo
-n
"--authors-file"
red_echo
" does not exist!"
STATUS
=
1
fi
return
${
STATUS
}
}
...
...
@@ -158,6 +167,15 @@ elif [ -d "${repo_dir}/${gitlab_namespace}/${project_name}" ];then
red_echo
"Error:
\"
${
repo_dir
}
/
${
gitlab_namespace
}
\"
exists already. Aborting command."
1>&2
exit
1
fi
#Resolve the $authors_file path because of changing working directories
#/home/gitmirror/mirror-management/Mirrors/gitlab-mirrors/gitlab-mirrors/../authors_files/systems_authors_maps.txt
if
[
!
-z
"
${
authors_file
}
"
]
;
then
if
!
echo
"
${
authors_file
}
"
|
grep
'^/'
&> /dev/null
;
then
authors_file
=
"
${
PWD
}
/
${
authors_file
}
"
authors_file
=
"
$(
echo
${
authors_file
}
|
sed
's#/./#/#g'
)
"
fi
fi
cd
"
${
git_mirrors_dir
}
"
#Set up project creation options based on config.sh to be passed to create manage_gitlab_project.py
CREATE_OPTS
=
""
...
...
@@ -201,11 +219,11 @@ if ${git};then
#create a mirror
echo
"Creating mirror from
${
mirror
}
"
cd
"
${
repo_dir
}
/
${
gitlab_namespace
}
"
git clone
--mirror
${
mirror
}
"
${
project_name
}
"
git clone
--mirror
"
${
mirror
}
"
"
${
project_name
}
"
cd
"
${
project_name
}
"
#add the gitlab remote
echo
"Adding gitlab remote to project."
git remote add gitlab
${
gitlab_remote
}
git remote add gitlab
"
${
gitlab_remote
}
"
git config
--add
remote.gitlab.push
'+refs/heads/*:refs/heads/*'
git config
--add
remote.gitlab.push
'+refs/tags/*:refs/tags/*'
#Check the initial repository into gitlab
...
...
@@ -218,4 +236,10 @@ elif ${svn};then
#create a mirror
echo
"Creating mirror from
${
mirror
}
"
cd
"
${
repo_dir
}
/
${
gitlab_namespace
}
"
if
[
!
-z
"
${
authors_file
}
"
]
;
then
echo
"
${
authors_file
}
"
#git svn clone ${git_svn_additional_options} --authors-file="${authors_file}" "${mirror}" "${project_name}"
fi
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