Promote a provider to the main repo

This guide proposes a workflow to promote a provider to the main jclouds repository. The goals of these steps are:

It is inspired by this post but has sensible changes, so pay attention to detail when running the commands below.

Promotion example: Chef

To illustrate the process we'll see how the jclouds-chef repository can be merged. We want to merge it keeping the main repository structure, so we have to move:

To do this, there are several steps required.

Clone the repositories

cd /tmp
git clone https://git-wip-us.apache.org/repos/asf/jclouds.git
git clone https://git-wip-us.apache.org/repos/asf/jclouds-chef.git

Isolate each folder to promote to its own branch

First thing to do is to isolate each folder to be moved to its own branch, and also moving it to the directory where it will be placed once merged. This can be done using git filter-branch as follows:

# Make sure we don't commit accidentally the filtered branches
git remote rm origin

# Create a branch that only contains jclouds-chef/core
cd /tmp/jclouds-chef
git checkout -b only-core
git filter-branch --index-filter \
  'git ls-files -s | sed "s-\t\"*-&apis\/chef/-" | GIT_INDEX_FILE=$GIT_INDEX_FILE.new \
  git update-index --index-info && mv "$GIT_INDEX_FILE.new" "$GIT_INDEX_FILE"' --subdirectory-filter core/ -f HEAD
git clean -d -f

# Create a branch that only contains jclouds-chef/enterprise
git checkout master
git checkout -b only-enterprise
git filter-branch --index-filter \
  'git ls-files -s | sed "s-\t\"*-&providers\/enterprisechef/-" | GIT_INDEX_FILE=$GIT_INDEX_FILE.new \
  git update-index --index-info && mv "$GIT_INDEX_FILE.new" "$GIT_INDEX_FILE"' --subdirectory-filter enterprise/ -f HEAD
git clean -d -f

In the filter-branch command we are doing two things: filtering only the contents and history of the files in the directory specified by the subdirectory-filter parameter, and moving them to the folder where they will land once merged in the main repo (specified in the ugly sed command).

OSX users: In OSX, the <TAB> character in the sed command won't be recognized if you type the \t. You have to type it as described here.

Merge the branches into the main repo

At this point we have the jclouds-chef repo with two branches that contain each folder to be merged in the main repo, already with the right directory structure, and keeping the commit history. Now we just have to merge those branches into the main repo as follows:

cd /tmp/jclouds

# Add the repository with the filtered branches as a remote (the -f parameter will make git automatically fetch the branch info)
git remote add -f chef ../jclouds-chef/

# Merge the branches
git merge chef/only-core
git merge chef/only-enterprise

# Remove the remote, as it is no longer needed
git remote rm chef

And that's it! Now the main repository will have the jclouds-chef folders merged in the right directories, and every file should keep its commit history. Review the changes, and push!

PromoteProvider (last edited 2014-10-08 22:18:25 by IgnasiBarrera)