Skip to content
Snippets Groups Projects
Commit 9e9e936b authored by Sam Gleske's avatar Sam Gleske
Browse files

Merge pull request #6 from agb80/bazzar

Bazaar support is added.  Thanks @agb80! 

There's a couple of modifications to the preflight check which need to be done but I know what they are and can do that pretty quickly.
parents 4dc4d000 3a3ea318
No related branches found
No related tags found
No related merge requests found
......@@ -51,6 +51,10 @@ Happy hacking!
Created by Sam Gleske under [MIT License](LICENSE).
## Contributors
Bzr support Agustín Cruz Lozano (atin81@gmail.com)
---
## References
......
......@@ -20,6 +20,7 @@ PROGVERSION="${VERSION}"
#Default script options
svn=false
git=false
bzr=false
project_name=""
mirror=""
force=false
......@@ -34,7 +35,7 @@ usage()
${PROGNAME} ${PROGVERSION} - MIT License by Sam Gleske
USAGE:
${PROGNAME} --git|--svn --project NAME --mirror URL [--authors-file FILE]
${PROGNAME} --git|--svn|--bzr --project NAME --mirror URL [--authors-file FILE]
DESCRIPTION:
This will add a git or SVN repository to be mirrored by GitLab. It
......@@ -63,12 +64,13 @@ DESCRIPTION:
--svn Mirror a SVN repository (must be explicitly set)
--bzr Mirror a Bazar repository (must be explicitly set)
EOF
}
#Short options are one letter. If an argument follows a short opt then put a colon (:) after it
SHORTOPTS="hvfm:p:"
LONGOPTS="help,version,force,git,svn,mirror:,project-name:,authors-file:"
LONGOPTS="help,version,force,git,svn,bzr,mirror:,project-name:,authors-file:"
ARGS=$(getopt -s bash --options "${SHORTOPTS}" --longoptions "${LONGOPTS}" --name "${PROGNAME}" -- "$@")
eval set -- "$ARGS"
while true; do
......@@ -89,6 +91,10 @@ while true; do
svn=true
shift
;;
--bzr)
bzr=true
shift
;;
-f|--force)
force=true
set +e
......@@ -131,11 +137,13 @@ function preflight() {
red_echo " options. Choose one or other." 1>&2
STATUS=1
fi
if ! ${git} && ! ${svn};then
if ! ${git} && ! ${svn} && ! ${bzr};then
red_echo -n "Must specify the " 1>&2
yellow_echo -n "--git" 1>&2
red_echo -n " or " 1>&2
yellow_echo -n "--svn" 1>&2
red_echo -n " or " 1>&2
yellow_echo -n "--bzr" 1>&2
red_echo " options." 1>&2
STATUS=1
fi
......@@ -347,6 +355,22 @@ elif ${svn};then
git push gitlab
git config --bool core.bare false
green_echo "All done!" 1>&2
elif ${bzr};then
#create a mirror
green_echo "Creating mirror from ${mirror}" 1>&2
cd "${repo_dir}/${gitlab_namespace}"
git clone bzr::"${mirror}" "${project_name}"
# cleaning repo
cd "${project_name}"
git gc --aggressive
#add the 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
green_echo "Checking the mirror into gitlab." 1>&2
git push gitlab
green_echo "All done!" 1>&2
else
red_echo "Something has gone very wrong. You should never see this message."
exit 1
......
......@@ -18,6 +18,12 @@ Create an SVN repository mirror.
The `--authors-file` option is an optional argument.
Create an BZR repository mirror.
su - gitmirror
cd gitlab-mirrors
./add_mirror.sh --bzr --project-name someproject --mirror lp:ubuntu/hello
### List all known mirrors
su - gitmirror
......
......@@ -11,6 +11,9 @@ If you plan on mirroring SVN repositories as well then you'll need the following
* [git-svn][7]
If you plan on mirroring BZR repositories then you'll need the following aditional options.
* [git-bzr-helper][8]
### Required software install snippets
python-gitlab
......@@ -45,3 +48,4 @@ Next up is [Installation and Setup](installation.md).
[5]: http://code.google.com/p/git-core/
[6]: http://git-scm.com/book/en/Getting-Started-Installing-Git
[7]: https://www.kernel.org/pub/software/scm/git/docs/git-svn.html
[8]: https://github.com/felipec/git/wiki/git-remote-bzr
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment