Files
git-upstream/functional-tests/060-test_drop.sh
Davide Guerri 24df2f38af Add drop and supersede commands
* supersede command allows the marking of commits as superceded by a
  set of upstream changes
* drop command allows the marking of commits that should be dropped

Both commands add git notes to a given sha1 in the upstream-merge
namespace (refs/notes/upstream-merge).
The notes are read by the import-upstream command during import and
the appropriate actions are then taken.

Add functional and unit tests for the two newly created commands.

JIRA: CICD-248
Change-Id: I6f69dd890af18e77a9affdb958afde1ec8b1cab8
2014-02-17 15:03:49 +00:00

105 lines
2.5 KiB
Bash
Executable File

#!/bin/bash
BASE_DIR=$(cd $(dirname $0); pwd -P)
# Include and run common test functions and initializations
source $BASE_DIR/libs/logging.lib
source $BASE_DIR/libs/utils.lib
REPO_NAME="empty-repo"
UPSTREAM_REPO=$(git rev-parse --show-toplevel)
TEST_BASE_REF="2c4bf67b5c416adfb162d9ca1fb4b0bf353fbb2a"
TEST_REBASE_REF="fd3524e1b7353cda228b6fb73c3a2d34a4fee4de"
SUCCESS_SHA1="b8c16b3dd8883d02b4b65882ad5467c9f5e7beb9 ?-"
function _common() {
prepare_for_hpgit $TEST_DIR $REPO_NAME $UPSTREAM_REPO $TEST_BASE_REF \
$TEST_NAME
pushd $TEST_DIR/$REPO_NAME >/dev/null
log DEBUG "Creating a local patches"
cat <<EOP | patch -tsp1 || return 1
diff --git a/setup.py b/setup.py
index 170ec46..251e1dd 100644
--- a/setup.py
+++ b/setup.py
@@ -28,6 +28,8 @@ setup(
version=version.version,
author="Darragh Bailey",
author_email="dbailey@hp.com",
+ maintainer="Davide Guerri",
+ maintainer_email="davide.guerri@hp.com",
description=("Tool supporting HPCloud git workflows."),
license="Proprietary",
keywords="git hpcloud workflow",
EOP
git commit -a -m "Add maintainer info" --quiet || return 1
cat <<EOP | patch -tsp1 || return 1
diff --git a/nothing b/nothing
new file mode 100644
index 0000000..9dafe9b
--- /dev/null
+++ b/nothing
@@ -0,0 +1 @@
+nothing
EOP
git add nothing
git commit -a -m "Add nothing" --quiet || return 1
git push -u origin master --quiet >/dev/null || return 1
git checkout master --quiet || return 1
log DEBUG "Rebasing local patches onto upstream version $TEST_REBASE_REF"
git branch import/$TEST_NAME-new $TEST_REBASE_REF --quiet || return 1
}
function test_new() {
log DEBUG "Starting $TEST_NAME::$FUNCNAME"
_common || return 1
local commit_sha1=$(git log -1 --format='%H')
git-hp drop $commit_sha1
git-hp import-upstream import/$TEST_NAME-new >/dev/null || return 1
git show --numstat | grep '0\s\s*1\s\s*nothing' >/dev/null
if [ "$?" -ne 0 ]; then
popd >/dev/null
return 1
fi
popd >/dev/null
}
function test_already_present() {
log DEBUG "Starting $TEST_NAME::$FUNCNAME"
_common || return 1
local commit_sha1=$(git log -1 --format='%H')
git-hp drop $commit_sha1
git-hp drop $commit_sha1 2>&1 | \
grep "Drop note has not been added as '$commit_sha1' already has one" \
>/dev/null
if [ "$?" -ne 0 ]; then
popd >/dev/null
return 1
fi
popd >/dev/null
}
TESTS="test_new test_already_present"
for test in $TESTS; do
$test && log INFO "$TEST_NAME::$test() passed." || \
log ERROR "$TEST_NAME::$test() failed!"
done