You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/09/20 19:38:48 UTC
svn commit: r1809073 - in /sling/trunk/tooling/scm/scripts: README.md
migrate-to-git.sh
Author: rombert
Date: Wed Sep 20 19:38:48 2017
New Revision: 1809073
URL: http://svn.apache.org/viewvc?rev=1809073&view=rev
Log:
SLING-3987 - move from Subversion to Git
Split the migrate-to-git.sh script to have multiple steps and add
a basic README.
Added:
sling/trunk/tooling/scm/scripts/README.md
Modified:
sling/trunk/tooling/scm/scripts/migrate-to-git.sh
Added: sling/trunk/tooling/scm/scripts/README.md
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/scm/scripts/README.md?rev=1809073&view=auto
==============================================================================
--- sling/trunk/tooling/scm/scripts/README.md (added)
+++ sling/trunk/tooling/scm/scripts/README.md Wed Sep 20 19:38:48 2017
@@ -0,0 +1,27 @@
+SCM Tooling
+====
+
+Git migration helpers
+---
+
+The workflow for migrating from Subversion to Git is the following:
+
+1. Generate the list of repository candidates
+
+ $ ./tooling/scm/scripts/gen-repo-candidates.sh > repo-candidates.txt
+
+2. Create the remote repositories using the ASF self-service git tool
+
+ $ ./tooling/scm/scripts/migrate-to-git.sh -r < repo-candidates.txt
+
+Creating a repository can take up to one hour, so do this well in advance
+
+3. Extract the modules in individual repositories
+
+ $ ./tooling/scm/scripts/migrate-to-git.sh -r < repo-candidates.txt
+
+Also validate that the repositories created using step 2 are now live.
+
+4. Push the local changes to the remote repositories
+
+ $ ./tooling/scm/scripts/migrate-to-git.sh -p < repo-candidates.txt
Modified: sling/trunk/tooling/scm/scripts/migrate-to-git.sh
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/scm/scripts/migrate-to-git.sh?rev=1809073&r1=1809072&r2=1809073&view=diff
==============================================================================
--- sling/trunk/tooling/scm/scripts/migrate-to-git.sh (original)
+++ sling/trunk/tooling/scm/scripts/migrate-to-git.sh Wed Sep 20 19:38:48 2017
@@ -21,6 +21,17 @@ prefixes='bundles/extensions/ bundles/ c
git_repo_location='../sling-modules'
git_src_location='../sling-modules-src'
+function usage {
+ echo "Usage: $0 [-p|-c] < repo-list.txt"
+ echo ""
+ echo " -r : provision the Remote repositories"
+ echo " -c : Convert the Repositories locally"
+ echo " -p : Push local repositories to remote"
+ echo ""
+ echo "The repo-list.txt file can be generated using the "
+ echo "$(dirname $0)/gen-repo-candidates.sh script"
+}
+
if [ ! -f check_staged_release.sh ]; then
echo "Please run this script from the root of the Sling SVN repository"
exit 1
@@ -35,7 +46,22 @@ if [ ! -d ${git_src_location} ]; then
echo "Done!"
fi
-for module in $(./tooling/scm/scripts/gen-repo-candidates.sh); do
+# validate CLI
+if [ $# -ne 1 ]; then
+ usage
+ exit -1
+fi
+
+case "$1" in
+ "-r") echo "Provisioning remote repositories" ;;
+ "-c") echo "Converting local repositories";;
+ "-p") echo "Pushing local repositories to remove";;
+ *)
+ usage
+ exit -1
+esac
+
+while read -r module; do
module_orig=$module
@@ -47,60 +73,66 @@ for module in $(./tooling/scm/scripts/ge
repo_name="sling-${artifactId}" # add TLP prefix
- echo "---- Preparing to migrate $module_orig to $repo_name ---"
-
- status=$(curl -s -o /dev/null -I -w "%{http_code}" https://git-wip-us.apache.org/repos/asf?p=${repo_name})
+ echo "---- Preparing to process $module_orig as $repo_name ---"
- if [ $status = "404" ]; then
- echo "Repository not found, will create";
- elif [ $status = "200" ] ;then
- echo "Repository exists, skipping";
- else
- echo "Unhandled HTTP status code ${status}, aborting"
- exit 1
- fi
-
- if [ ! -d ${git_repo_location}/${repo_name}/.git ]; then
- echo "Converting from SVN to Git..."
-
- # create the initial repo
- git clone --no-hardlinks ${git_src_location} ${git_repo_location}/${repo_name}
+ if [ $1 == "-c" ]; then
+
+ if [ ! -d ${git_repo_location}/${repo_name}/.git ]; then
+ echo "Converting from SVN to Git..."
+
+ # create the initial repo
+ git clone --no-hardlinks ${git_src_location} ${git_repo_location}/${repo_name}
+ pushd ${git_repo_location}/${repo_name}
+
+ # make sure we don't push to the incorrect repo and also remove make sure
+ # we don't keep references to the remote repo
+ git remote rm origin
+
+ # rename trunk to master
+ git branch -m trunk master
+
+ # Remove everything except the path belonging to the module
+ git filter-branch --subdirectory-filter ${module_orig}
+
+ # remove unrelated tags
+ for tag in $(git tag); do
+ if [[ $tag != ${artifactId}* ]]; then
+ git tag -d ${tag}
+ fi
+ done
+
+ # cleanup and compaction
+ git for-each-ref --format="%(refname)" refs/original/ | xargs -n1 git update-ref -d
+ git reflog expire --expire=now --all
+ git repack -Ad
+ git gc --aggressive --prune=now
+ popd
+ echo "Complete!"
+ else
+ echo "Already converted"
+ fi
+
+ elif [ $1 == "-r" ]; then
+ status=$(curl -s -o /dev/null -I -w "%{http_code}" https://git-wip-us.apache.org/repos/asf?p=${repo_name})
+
+ if [ $status = "404" ]; then
+ echo "Repository not found, will create";
+ elif [ $status = "200" ] ;then
+ echo "Repository exists, skipping";
+ else
+ echo "Unhandled HTTP status code ${status}, aborting"
+ exit 1
+ fi
+
+
+ # TODO - create the repository using the ASF self-service tool
+ # curl --netrc 'https://reporeq.apache.org/ss.lua'
+ echo "Creating GIT repository ..."
+ exit 254 # unimplemented
+ else # -p
pushd ${git_repo_location}/${repo_name}
-
- # make sure we don't push to the incorrect repo and also remove make sure
- # we don't keep references to the remote repo
- git remote rm origin
-
- # rename trunk to master
- git branch -m trunk master
-
- # Remove everything except the path belonging to the module
- git filter-branch --subdirectory-filter ${module_orig}
-
- # remove unrelated tags
- for tag in $(git tag); do
- if [[ $tag != ${artifactId}* ]]; then
- git tag -d ${tag}
- fi
- done
-
- # cleanup and compaction
- git for-each-ref --format="%(refname)" refs/original/ | xargs -n1 git update-ref -d
- git reflog expire --expire=now --all
- git repack -Ad
- git gc --aggressive --prune=now
+ git remote add origin https://git-wip-us.apache.org/repos/asf/${repo_name}.git
+ git push -u origin master
popd
- echo "Complete!"
- else
- echo "Already converted"
fi
-
-
- # TODO - create the repository using the ASF self-service tool
- echo "Creating GIT repository ..."
- exit 254 # unimplemented
-
- cd ${git_repo_location}/${repo_name}
- git remote add origin https://git-wip-us.apache.org/repos/asf/${repo_name}.git
- git push -u origin master
done