Skip to content

Instantly share code, notes, and snippets.

@d
Last active December 16, 2015 00:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save d/5349150 to your computer and use it in GitHub Desktop.
Save d/5349150 to your computer and use it in GitHub Desktop.
splitting mpgw
#!/usr/bin/env ruby
def execute(cmd)
stdout = `#{cmd}`
if $?.success?
return stdout
end
raise "execution of command \"#{cmd}\" failed. Status: #{$?}"
end
args = readline.split
revisions = args.values_at(* args.each_index.select(&:odd?)).uniq
if revisions.length == 2
# fast-forward-able
if execute("git merge-base #{revisions[0]} #{revisions[1]}").include? revisions[0]
revisions.shift
elsif execute("git merge-base #{revisions[1]} #{revisions[0]}").include? revisions[1]
revisions.pop
end
end
puts ['-p'].product(revisions).join(' ')
#!/bin/bash
set -u -x -e
if [ $# -ne 1 ]; then
echo "expected two arguments given $#"
exit 1
fi
CLONE_PATH=$1
if [[ ! -d $CLONE_PATH ]]; then
git clone "$(dirname $CLONE_PATH)/vcap-services" $CLONE_PATH
fi
SCRIPT_DIR=$(cd $(dirname $0) && pwd)
cd $CLONE_PATH
# package_cache and friends
git checkout origin/master -B filtered
INDEX_FILTER="git rm -r -f --cached --quiet --ignore-unmatch \$( git ls-tree --name-only \$GIT_COMMIT | egrep -v '^marketplace' )"
git filter-branch -f --prune-empty \
--index-filter "$INDEX_FILTER" \
--parent-filter $SCRIPT_DIR/parent-filter.rb
git branch -v
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment