diff --git a/CHANGELOG.md b/CHANGELOG.md index 63545365267afbd8dcbdc5b47732298b66765993..f7c696488f939f429ee308a9273ce90429d64a8c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## v0.4.4 + +* Added Mercurial mirroring support. `add_mirror.sh` now has the `--hg` option when adding a repository. + +--- ## v0.4.3 * Added `no_create_set` option to `config.sh`. This option forces the user to always provide a remote for pushing repositories via the `--no-create` option in `add_mirror.sh`. diff --git a/README.md b/README.md index 2e2684dec0e5269baf2aee34d46d3859a69b0f12..0ca7ead272fd15d489138bb9628aa8da9fce6511 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ The [gitlab-mirrors](https://github.com/sag47/gitlab-mirrors) project is designe ## Features -* Mirror different types of repositories: Bazaar, git, subversion. +* Mirror different types of source repositories: Bazaar, Git, Mercurial, Subversion. Mirror all into git. * GitLab mirror adding. * When adding a mirror if the project doesn't exist in GitLab it will be auto-created. * Set project creation defaults (e.g. issues enabled, wiki enabled, etc.) diff --git a/add_mirror.sh b/add_mirror.sh index 5dce10741e3a2a0fcf9a4fea58b47160db950088..78bb85deb77f5ec0445b9748348addf63c08773f 100755 --- a/add_mirror.sh +++ b/add_mirror.sh @@ -24,6 +24,7 @@ PROGVERSION="${VERSION}" svn=false git=false bzr=false +hg=false project_name="" mirror="" force=false @@ -76,13 +77,15 @@ REPOSITORY TYPES: --git Mirror a git repository (must be explicitly set) + --hg Mirror a Mercurial repository (must be explicitly set) + --svn Mirror a SVN 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:n:p:" -LONGOPTS="help,version,force,git,svn,bzr,mirror:,no-create:,project-name:,authors-file:" +LONGOPTS="help,version,force,git,svn,bzr,hg,mirror:,no-create:,project-name:,authors-file:" ARGS=$(getopt -s bash --options "${SHORTOPTS}" --longoptions "${LONGOPTS}" --name "${PROGNAME}" -- "$@") eval set -- "$ARGS" while true; do @@ -107,6 +110,10 @@ while true; do bzr=true shift ;; + --hg) + hg=true + shift + ;; -f|--force) force=true set +e @@ -160,6 +167,10 @@ function preflight() { ((types += 1)) selected_types+=('--bzr') fi + if ${hg};then + ((types += 1)) + selected_types+=('--hg') + fi if [ "${types}" -eq "0" ];then red_echo -n "Must select at least one repository type. e.g. " yellow_echo "--git" @@ -428,6 +439,22 @@ elif ${bzr};then green_echo "Checking the mirror into gitlab." 1>&2 git push gitlab green_echo "All done!" 1>&2 +elif ${hg};then + #create a mirror + green_echo "Creating mirror from ${mirror}" 1>&2 + cd "${repo_dir}/${gitlab_namespace}" + git clone --mirror hg::"${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/prerequisites.md b/docs/prerequisites.md index 381b9112c3344271a6f9fef337aa286b8c474f6e..f2880bc49ad808eae87642315498a6784d7fa827 100644 --- a/docs/prerequisites.md +++ b/docs/prerequisites.md @@ -15,6 +15,10 @@ If you plan on mirroring BZR repositories then you'll need the following adition * [git-bzr-helper][8] +If you plan on mirroring Mercurial repositories then you'll need the following aditional options. + +* [git-hg-helper][9] + ### Required software install snippets #### python-gitlab @@ -48,8 +52,15 @@ Your git should now be located in `/usr/local/bin/git`. You should edit `/etc/p sudo -i -u gitmirror mkdir ~/bin wget https://raw.github.com/felipec/git/fc/master/git-remote-bzr.py -O ~/bin/git-remote-bzr - chmod 755 ~bin/git-remote-bzr + chmod 755 ~/bin/git-remote-bzr + +#### git-hg-helper + sudo -i -u gitmirror + sudo apt-get install python-rope + mkdir ~/bin + wget https://raw.github.com/felipec/git/fc/master/git-remote-hg.py -O ~/bin/git-remote-hg + chmod 755 ~/bin/git-remote-hg --- Next up is [Installation and Setup](installation.md). @@ -62,3 +73,4 @@ Next up is [Installation and Setup](installation.md). [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 +[9]: https://github.com/felipec/git/wiki/git-remote-hg diff --git a/lib/VERSION b/lib/VERSION index fd1e70512f7b8e6acbd5b00439b53fa8c816b993..7fc06da188d66f01d36683a978ff5694ad3abe08 100644 --- a/lib/VERSION +++ b/lib/VERSION @@ -1 +1 @@ -VERSION="v0.4.4pre" +VERSION="v0.4.4"