diff --git a/README.md b/README.md index 9c3309077a771ce49ddbc43f7ca837cd2038b699..319004e1c69dcc4ace4d81191316b8011c5726ed 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/add_mirror.sh b/add_mirror.sh index 361f1d1bf5fb960deb40fcc17537498121241c3c..c0a688ae1a0583dd216d34a199207b891be99604 100755 --- a/add_mirror.sh +++ b/add_mirror.sh @@ -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 diff --git a/docs/management.md b/docs/management.md index c7419a0e72faf09be958b79d4dbda2589b58fbc5..6d31ee28158349c0cb77336d04a73d4cf70e1a7e 100644 --- a/docs/management.md +++ b/docs/management.md @@ -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 diff --git a/docs/prerequisites.md b/docs/prerequisites.md index 0721ed2dd1735ea18bb1ba181f805f81482ecc5f..5f26c7f7be855c991c85866226bdd23954512f6d 100644 --- a/docs/prerequisites.md +++ b/docs/prerequisites.md @@ -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