-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Turmio/incoming-linux
Incoming linux
- Loading branch information
Showing
9 changed files
with
232 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,12 @@ | ||
language: python | ||
language: python | ||
|
||
branches: | ||
only: | ||
- gh-pages | ||
- /.*/ | ||
|
||
install: true | ||
|
||
script: | ||
- chmod +x test/hg/bash/test-incoming.sh | ||
- ./test/hg/bash/test-incoming.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
|
||
ON_NEW=$1 | ||
ON_EXISTING=$2 | ||
ON_CLOSED=$3 | ||
|
||
REPO=`echo $(echo "$HG_URL" | sed "s/^file://g")` | ||
|
||
#get branch | ||
BRANCH=`hg log --rev $HG_NODE --template "{branch}\n"` | ||
#first commit to branch | ||
FIRST=`hg log -r "min(branch($BRANCH))" --template "{node}\n"` | ||
#is closed | ||
CLOSED=`hg log -r "closed() and branch($BRANCH)" --template "{node}\n" | awk 'NR==1'` | ||
|
||
if [ "$HG_NODE" = "$FIRST" ]; then | ||
CMD="$ON_NEW $BRANCH $HG_NODE" | ||
eval $CMD | ||
elif [ "$HG_NODE" = "$CLOSED" ]; then | ||
CMD="$ON_CLOSED $BRANCH $HG_NODE" | ||
eval $CMD | ||
else | ||
CMD="$ON_EXISTING $BRANCH $HG_NODE" | ||
eval $CMD | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
|
||
if [ -z "$1" ]; then | ||
echo "Cannot add hook because repository is not defined" | ||
exit 1 | ||
fi | ||
|
||
if [ -z "$2" ]; then | ||
echo "Cannot add hook because hook is not defined" | ||
exit 1 | ||
fi | ||
|
||
|
||
SCRIPT_PATH=$(dirname `which $0`) | ||
REPO=$1 | ||
|
||
HGRC="$SCRIPT_PATH/$REPO/.hg/hgrc" | ||
CURRENT=`pwd` | ||
ABSOLUTE=$(cd $SCRIPT_PATH; pwd) | ||
HOOKPATH=$(cd $ABSOLUTE/../../../src/hg/bash; pwd) | ||
HOOK=$HOOKPATH/$2.sh | ||
|
||
cd $CURRENT | ||
|
||
if [ ! -f $HGRC ]; then | ||
touch $HGRC | ||
fi | ||
|
||
echo "">> $HGRC | ||
echo "[hooks]">> $HGRC | ||
echo "$2 = $HOOK \"$3\" \"$4\" \"$5\"">> $HGRC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/sh | ||
if [ -z "$1" ]; then | ||
echo "Cannot commit change to branch because repository is not defined" | ||
exit 1 | ||
fi | ||
|
||
if [ -z "$2" ]; then | ||
echo "Cannot commit change to branch because file is not defined" | ||
exit 1 | ||
fi | ||
|
||
if [ ! -f "$1/$2" ]; then | ||
touch $1/$2 | ||
fi | ||
|
||
echo "text" >> $1/$2 | ||
hg add -R $1 $1/* | ||
hg commit -R $1 --config ui.username=test -m "changed file from $0" | ||
hg push -R $1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
SCRIPT_PATH=$(dirname `which $0`) | ||
echo "Cleaning repositories" | ||
if [ ! -z "$1" ]; then | ||
rm -r $SCRIPT_PATH/$1 | ||
else | ||
echo "Initial repository name was not defined" | ||
fi | ||
|
||
if [ ! -z "$2" ]; then | ||
rm -r $SCRIPT_PATH/$2 | ||
else | ||
echo "Clone repository name was not defined" | ||
fi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/sh | ||
|
||
if [ -z "$1" ]; then | ||
echo "Cannot close branch because repository is not defined" | ||
exit 1 | ||
fi | ||
|
||
hg commit -R $1 --config ui.username=test --close-branch -m "closed" | ||
hg push -R $1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
if [ -z "$1" ]; then | ||
echo "Initial repository name was not defined" | ||
exit 1 | ||
fi | ||
|
||
if [ -z "$2" ]; then | ||
echo "Clone repository name was not defined" | ||
exit 1 | ||
fi | ||
|
||
SCRIPT_PATH=$(dirname `which $0`) | ||
|
||
hg init $SCRIPT_PATH/$1 | ||
hg clone $SCRIPT_PATH/$1 $SCRIPT_PATH/$2 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
#!/bin/bash | ||
|
||
checkReturnCode() { | ||
if [ $1 -eq 1 ]; then | ||
eval $2 | ||
echo "FAILURE" | ||
exit 1 | ||
fi | ||
} | ||
|
||
REPO1=repository1 | ||
REPO2=repository2 | ||
SCRIPT_PATH=$(dirname `which $0`) | ||
ABSOLUTE=$(cd $SCRIPT_PATH; pwd) | ||
NEWBRANCH=$ABSOLUTE/newbranch | ||
EXISTING=$ABSOLUTE/existing | ||
CLOSED=$ABSOLUTE/closed | ||
RESULT=0 | ||
CLEANUP="source $SCRIPT_PATH/clean-repos.sh $REPO1 $REPO2; rm $NEWBRANCH; rm $EXISTING; rm $CLOSED" | ||
|
||
source $ABSOLUTE/init-repos.sh $REPO1 $REPO2 | ||
ret_code=$? | ||
checkReturnCode $ret_code $CLEANUP | ||
|
||
WRITE_RESULTS=$ABSOLUTE/write-file.sh | ||
|
||
NP="$WRITE_RESULTS $NEWBRANCH" | ||
NE="$WRITE_RESULTS $EXISTING" | ||
NC="$WRITE_RESULTS $CLOSED" | ||
source $SCRIPT_PATH/add-hook.sh $REPO1 incoming "$NP" "$NE" "$NC" | ||
ret_code=$? | ||
checkReturnCode $ret_code $CLEANUP | ||
|
||
|
||
source $SCRIPT_PATH/change-file.sh $ABSOLUTE/$REPO2 "file" | ||
ret_code=$? | ||
checkReturnCode $ret_code $CLEANUP | ||
|
||
source $SCRIPT_PATH/change-file.sh $ABSOLUTE/$REPO2 "file" | ||
ret_code=$? | ||
checkReturnCode $ret_code $CLEANUP | ||
|
||
source $SCRIPT_PATH/close-branch.sh $ABSOLUTE/$REPO2 | ||
ret_code=$? | ||
checkReturnCode $ret_code $CLEANUP | ||
|
||
EXPECTED_NEW=("default") | ||
EXPECTED_EXISTING=("default") | ||
EXPECTED_CLOSED=("default") | ||
I=0 | ||
while IFS='' read -r line || [[ -n "$line" ]]; do | ||
linearr=($line) | ||
if [ "${linearr[0]}" != "${EXPECTED_NEW[$I]}" ]; then | ||
RESULT=1 | ||
fi | ||
let "I++" | ||
done < "$NEWBRANCH" | ||
if [! $i -eq ${EXPECTED_NEW[@]} ]; then | ||
RESULT=1 | ||
fi | ||
I=0 | ||
while IFS='' read -r line || [[ -n "$line" ]]; do | ||
linearr=($line) | ||
|
||
if [ "${linearr[0]}" != "${EXPECTED_EXISTING[$I]}" ]; then | ||
RESULT=1 | ||
fi | ||
let "I++" | ||
done < "$EXISTING" | ||
|
||
if [! $i -eq ${EXPECTED_EXISTING[@]} ]; then | ||
RESULT=1 | ||
fi | ||
|
||
I=0 | ||
while IFS='' read -r line || [[ -n "$line" ]]; do | ||
linearr=($line) | ||
|
||
if [ "${linearr[0]}" != "${EXPECTED_CLOSED[$I]}" ]; then | ||
RESULT=1 | ||
fi | ||
let "I++" | ||
done < "$CLOSED" | ||
|
||
if [! $i -eq ${EXPECTED_CLOSED[@]} ]; then | ||
RESULT=1 | ||
fi | ||
|
||
eval $CLEANUP | ||
if [ $RESULT -eq 1 ]; then | ||
echo "FAILURE" | ||
else | ||
echo "SUCCESS" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
if [ -z "$1" ]; then | ||
echo File was not defined | ||
fi | ||
|
||
if [ ! -f "$1" ]; then | ||
touch "$1" | ||
fi | ||
|
||
echo $2 $3 >> $1 |