...
 
Commits (254)
/build/
/.gradle
/.nb-gradle*
/.trackdown
/roadmap.md
/issues.md
usage-template.gzip.base64.txt
#
# Copyright 2019 Martin Goellnitz
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
image: provocon/gitlabci-gradle-java
before_script:
- export GRADLE_USER_HOME=/tmp/.gradle
stages:
- trackdown
build:
stage: trackdown
script: apk update ; apk add jq file curl mercurial git bash bash-completion ; gradle build
artifacts:
paths:
- build/distributions/*
expire_in: 5 days
name: ${CI_BUILD_STAGE}
cache:
paths:
- /tmp/.gradle/caches/
- /tmp/.gradle/wrapper/
This diff is collapsed.
This diff is collapsed.
#!/bin/bash
#
# Copyright 2015-2019 Martin Goellnitz
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
DIR=`dirname $0`
. $DIR/trackdown-lib.sh
CWD=`pwd`
windUp trackdown
TDBASE=`pwd`
VCS=`test -d .hg && echo hg || echo git`
TDCONFIG=$TDBASE/.trackdown/config
echo "TrackDown-$VCS: Base directory $TDBASE"
cd $CWD
checkTrackdown
discoverIssues
# Prefix for links to online commit descriptions
PREFIX=`grep prefix= $TDCONFIG|cut -d '=' -f 2`
# echo "ISSUES $ISSUES"
if [ $VCS = "hg" ] ; then
AUTHOR=`hg log -l 1 --template "{person(author)}\n"`
DATE=`hg log -l 1 --template "{localdate(date)|date}\n"`
LINE=`hg log -l 1 --template "{desc}\n"|grep \#`
HASH=`hg log -l 1 --template "{node}\n"`
fi
if [ $VCS = "git" ] ; then
AUTHOR=`git log -n 1 --format=%an`
DATE=`git log -n 1 --format=%aD|cut -d '+' -f 1|sed -e 's/\ $//g'`
LINE=`git log -n 1 --format=%s|grep \#`
HASH=`git log -n 1 --format="%H"`
fi
STATUS=""
if [ ! -z "$LINE" ] ; then
echo "Line: $LINE"
ID=`echo $LINE|sed -e 's/.*#\([0-9a-zA-Z,]*\).*/\1/g'`
echo "ID: $ID"
MARKER=`echo $LINE|grep -i "refs \#$ID"`
if [ ! -z "$MARKER" ] ; then
STATUS="in progress"
fi
MARKER=`echo $LINE|grep -i "fixes \#$ID"`
if [ ! -z "$MARKER" ] ; then
STATUS="resolved"
fi
MARKER=`echo $LINE|grep -i "resolves \#$ID"`
if [ ! -z "$MARKER" ] ; then
STATUS="resolved"
fi
MARKER=`echo $LINE|grep -i "resolve \#$ID"`
if [ ! -z "$MARKER" ] ; then
STATUS="resolved"
fi
fi
echo "TrackDown: $ID $STATUS"
if [ ! -z "$STATUS" ] ; then
for TID in `echo "$ID"|sed -e 's/,/\ /g'`; do
HASID=`grep "^\#\#\ ${TID}" $ISSUES`
if [ ! -z "$HASID" ] ; then
echo "TrackDown: Issue $TID"
sed -i.remove -e "s/##\ $TID\ \(.*\)\ (.*)/## $TID \1/g" $ISSUES
sed -i.remove -e "s/##\ $TID\ \(.*\)/## $TID \1 ($STATUS)/g" $ISSUES
rm $ISSUES.remove
ISLAST=`grep -n "^\#\#\ " $ISSUES|grep -A1 "${TID}.*$STATUS" |tail -1|grep $TID`
# echo "last: $ISLAST"
if [ -z "$ISLAST" ] ; then
SECTION=`grep -n "^\#\#\ " $ISSUES|grep -A1 "${TID}.*$STATUS"|tail -1|cut -d ':' -f 1`
LINES=`cat $ISSUES|wc -l`
# echo "SECTION $SECTION - LINES $LINES"
FILE=$ISSUES.remove
head -$[ $SECTION - 1 ] $ISSUES >>$FILE
else
FILE=$ISSUES
echo "" >>$FILE
fi
if [ -z "$PREFIX" ] ; then
echo "$AUTHOR / ${DATE} (${HASH})" >>$FILE
else
echo "$AUTHOR / ${DATE} [${HASH}](${PREFIX}${HASH})" >>$FILE
fi
echo "" >>$FILE
if [ $VCS = "hg" ] ; then
hg log -l 1 --template " {desc}\n" >>$FILE
fi
if [ $VCS = "git" ] ; then
git log -n 1 --format=" %s" >>$FILE
BODY=`git log -n 1 --format="%b"`
if [ ! -z "$BODY" ] ; then
git log -n 1 --format=" %b" >>$FILE
fi
fi
if [ -z "$ISLAST" ] ; then
echo "" >>$ISSUES.remove
tail -$[ $LINES - $SECTION + 1 ] $ISSUES >>$ISSUES.remove
mv $ISSUES.remove $ISSUES
fi
else
echo "TrackDown: ID $TID not found in issues collection"
fi
done
writeRoadmap
AUTOCOMMIT=`grep autocommit=true $TDCONFIG`
# echo "AUTOCOMMIT: $AUTOCOMMIT"
if [ ! -z "$AUTOCOMMIT" ] ; then
WD=`pwd`
TRACKDOWN=`dirname $ISSUES`
# TODO: WHy do we re-discover the VCS here?
VCS=`test -d $TRACKDOWN/.hg && echo hg || echo git`
echo "TrackDown: committing with $VCS in $TRACKDOWN"
( cd $TRACKDOWN ; ${VCS} commit -m "Committed for issue(s) #$ID" issues.md roadmap.md > /dev/null)
AUTOPUSH=`grep autopush=true $TDCONFIG`
# echo "AUTOPUSH: $AUTOPUSH"
if [ ! -z "$AUTOPUSH" ] ; then
echo "TrackDown: pushing"
( cd $TRACKDOWN ; ${VCS} pull ; ${VCS} push > /dev/null )
fi
fi
else
writeRoadmap
fi
#!/bin/bash
#
# Copyright 2015-2018 Martin Goellnitz
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# wind up the directory tree until we find a hidden folder of the given name $1
function windUp {
while [ `pwd` != "/" -a ! -d .$1 ] ; do
cd ..
done
}
# $1 message to issue when not given $2 parameter to check
function bailOnZero {
if [ -z "$2" ] ; then
echo $1
exit
fi
}
# Exit if trackdown is not initialized
function checkTrackdown {
if [ ! -f $TDCONFIG ] ; then
echo "Project not initialized for trackdown use."
exit
fi
}
# Exit if jq is not installed
function checkJq {
if [ `jq 2>&1|wc -l` = 0 ] ; then
echo "To use this functionality, jq must be installed."
exit
fi
}
# Discover issues collection file from setup
function discoverIssues {
if [ -z "$ISSUES" ] ; then
ISSUES=`test -f $TDCONFIG && grep location= $TDCONFIG|cut -d '=' -f 2`
if [ -z "$ISSUES" ] ; then
test -d $TDBASE/.git && ISSUES=".git/trackdown/issues.md"
test -d $TDBASE/.hg && ISSUES=".hg/trackdown/issues.md"
fi
ESCAPEDBASE=`echo $TDBASE|sed -e 's/\//\\\_xxxxx_\//g'|sed -e 's/_xxxxx_//g'`
ISSUES=`echo $ISSUES|sed -e "s/^\([a-zA-Z0-9\.]\)/$ESCAPEDBASE\/\1/g"`
fi
if [ ! -f $ISSUES ] ; then
echo "No issue collection file found. Are we in a TrackDown context?"
exit
fi
}
# Prevent mirror setup to occur repeatedly
function preventRepeatedMirrorInit {
MIRROR=`test -f $TDCONFIG && grep mirror.type= $TDCONFIG|cut -d '=' -f 2`
if [ ! -z $MIRROR ] ; then
echo "Mirror setup already done in this repository with type $MIRROR."
exit
fi
}
# Discovers the VCS in use and sets up ignore file suppport variables
function ignoreFileHelper {
if [ -d $TDBASE/.git ] ; then
IGNOREFILE="$TDBASE/.gitignore"
IFBEGIN="/"
IFEND=""
fi
if [ -d $TDBASE/.hg ] ; then
IGNOREFILE="$TDBASE/.hgignore"
IFBEGIN="^"
IFEND="\$"
fi
if [ ! -z "$IGNOREFILE" ] ; then
CHECK=`grep -s .trackdown $IGNOREFILE|wc -l`
if [ $CHECK = 0 ] ; then
echo "${IFBEGIN}.trackdown${IFEND}" >> $IGNOREFILE
fi
fi
}
# Do common setup steps for collection for mirror type $1
function setupCollectionReference {
COLLECTION=$1-issues.md
test ! -d $TDBASE/.trackdown && mkdir $TDBASE/.trackdown
echo "autocommit=false" > $TDCONFIG
echo "autopush=false" >> $TDCONFIG
echo "location=$COLLECTION" >> $TDCONFIG
ignoreFileHelper
if [ ! -z "$IGNOREFILE" ] ; then
CHECK=`grep -s $COLLECTION $IGNOREFILE|wc -l`
if [ $CHECK = 0 ] ; then
echo "${IFBEGIN}$COLLECTION${IFEND}" >> $IGNOREFILE
fi
CHECK=`grep -s roadmap.md $IGNOREFILE|wc -l`
if [ $CHECK = 0 ] ; then
echo "${IFBEGIN}roadmap.md${IFEND}" >> $IGNOREFILE
fi
fi
echo "mirror.type=$1" >> $TDCONFIG
touch $TDBASE/$COLLECTION
}
# check if export result file $1 exists. Bails otherwise...
function checkExport {
if [ ! -f $1 ] ; then
echo "JSON export file $1 not found. Export seemed to have failed..."
exit
fi
}
# Create issue collection header with title $1 in issue collection file
function issueCollectionHeader {
test -z "$2" && echo -n "" > $ISSUES
echo "# $1" >>$ISSUES
echo "" >>$ISSUES
echo "" >>$ISSUES
echo "[Roadmap](roadmap)" >>$ISSUES
}
# Generate a roadmap from the issue collection
function roadmap {
echo "# Roadmap"
echo ""
IC=`basename $ISSUES .md`
for rr in `grep -A2 "^\#\#\ " $ISSUES|grep "^\*[A-Za-z0-9][A-Za-z0-9\._\ -]*\*"|cut -d '*' -f 2|sort|uniq|sed -e 's/\ /__/g'` ; do
r=`echo $rr|sed -e 's/__/ /g'`
TOTAL=`grep -B2 "^\*$r\*" $ISSUES|grep "^\#\#\ "|sed -e 's/^\#\#\ /\#\#\# /g'|wc -l`
RESOLVED=`grep -B2 "^\*$r\*" $ISSUES|grep "^\#\#\ "|sed -e 's/^\#\#\ /\#\#\# /g'|grep -i '(resolved)'|wc -l`
PROGRESS=`grep -B2 "^\*$r\*" $ISSUES|grep "^\#\#\ "|sed -e 's/^\#\#\ /\#\#\# /g'|grep -i '(in progress)'|wc -l`
RESPERC=$[$RESOLVED * 100 / $TOTAL]
PROPERC=$[$PROGRESS * 100 / $TOTAL]
RESTPERC=$[ 100 - $PROPERC - $RESPERC ]
echo "## ${r}:"
echo ""
if [ $RESPERC -gt 0 ] ; then
echo -n "![$RESPERC%](https://di.9f8.de/$[ $RESPERC * 7 ]x30/000000/FFFFFF.png&text=$RESPERC%25)"
fi
if [ $PROPERC -gt 0 ] ; then
echo -n "![$PROPERC%](https://di.9f8.de/$[ $PROPERC * 7 ]x30/606060/FFFFFF.png&text=$PROPERC%25)"
fi
if [ $RESTPERC -gt 0 ] ; then
echo -n "![$RESTPERC%](https://di.9f8.de/$[ $RESTPERC * 7 ]x30/eeeeee/808080.png&text=$RESTPERC%25)"
fi
echo ""
echo ""
echo "$RESPERC% completed ($RESOLVED/$TOTAL) - $PROPERC% in progress ($PROGRESS/$TOTAL)"
echo ""
grep -B2 "^\*$r\*" $ISSUES|grep "^\#\#\ "|sed -e 's/^\#\#\ /* /g'|awk '{print $NF,$0}'| sort | cut -f2- -d' '
echo ""
done
}
# Write the roadmap to the roadmap file
function writeRoadmap {
ROADMAP=`dirname $ISSUES`/roadmap.md
roadmap > $ROADMAP
}
This diff is collapsed.
/*
*
* Copyright 2015-2018 Martin Goellnitz
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
// Use the Java plugin to to get the sourceSets defined
apply plugin: 'distribution'
apply plugin: 'java-base'
version = '1.1-SNAPSHOT'
sourceSets {
main {
resources {
srcDir 'bin'
}
}
test {
resources {
srcDir 'test'
}
}
}
distributions {
main {
contents {
from 'README.md'
from 'bin'
// into 'usr/local/bin'
}
}
}
check.doFirst {
exec {
commandLine "mkdir", "-p", "$buildDir/test/.trackdown"
}
def tests = fileTree('test') {
include '**/*.sh'
exclude '**/shelltest.sh'
}
tests.each { file ->
// print "$file \n"
exec {
commandLine "$file"
}
}
}
task encodeMessage(type:Exec) {
workingDir "$projectDir"
commandLine 'bash', '-c', \
"cat usage-template.txt |gzip -9c|base64|sed -e 's/\$/ \\\\/g' > usage-template.gzip.base64.txt"
}
autocommit=false
autopush=false
location=bitbucket-issues.md
mirror.type=bitbucket
prefix=https://bitbucket.org/backendzeit/markdown-demo/commits/
bitbucket.user=backendzeit
bitbucket.project=backendzeit/markdown-demo
me=
^.trackdown$
^bitbucket-issues.md$
^roadmap.md$
#!/bin/bash
#
# Copyright 2016 Martin Goellnitz
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# include test "framework"
MYDIR=`dirname $0`
source $MYDIR/shelltest.sh
# setup test
before
mkdir -p .hg
mkdir -p .git
# test setup variants
OUTPUT=`$CWD/bin/trackdown.sh bitbucket|tail -1`
# echo "$OUTPUT"
assertEquals "Unexpected bitbucket setup output" "$OUTPUT" "No project name given as the first parameter"
OUTPUT=`$CWD/bin/trackdown.sh bitbucket markdown-demo|tail -1`
assertEquals "Unexpected bitbucket setup output" "$OUTPUT" "No username given as the second parameter"
OUTPUT=`$CWD/bin/trackdown.sh bitbucket markdown-demo backendzeit|tail -1`
assertEquals "Unexpected bitbucket setup output" "$OUTPUT" "Setting up TrackDown to mirror markdown-demo as backendzeit from bitbucket.org"
assertExists "Config file missing" .trackdown/config
assertExists "Issue collection file missing" bitbucket-issues.md
assertExists "VCS ignore file missing" .hgignore
DIFF=`diff -u $MYDIR/bitbucketmirror.config .trackdown/config`
assertEquals "Unexpected bitbucket mirror configuration" "$DIFF" ""
DIFF=`diff -u $MYDIR/bitbucketmirror.ignore .hgignore`
assertEquals "Unexpected bitbucket ignore file" "$DIFF" ""
OUTPUT=`$CWD/bin/trackdown.sh bitbucket markdown-demo mgoellnitz|tail -1`
assertEquals "Unexpected bitbucket setup output" "$OUTPUT" "Mirror setup already done in this repository with type bitbucket."
# cleanup test
after
autocommit=false
autopush=false
location=gitea-issues.md
mirror.type=gitea
prefix=https://codeberg.org/backendzeit/markdown-demo/commit/
gitea.url=https://codeberg.org
gitea.project=backendzeit/markdown-demo
gitea.key=k
^.trackdown$
^gitea-issues.md$
^roadmap.md$
#!/bin/bash
#
# Copyright 2016-2019 Martin Goellnitz
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# include test "framework"
MYDIR=`dirname $0`
source $MYDIR/shelltest.sh
# setup test
before
# Must be done with Mercurial as the DVCS to avoid trouble with surrounding trackdown git
mkdir -p .hg
# test setup variants
OUTPUT=`$CWD/bin/trackdown.sh gitea|tail -1`
# echo "$OUTPUT"
assertEquals "Unexpected gitea setup output" "$OUTPUT" "No api token given as the first parameter"
OUTPUT=`$CWD/bin/trackdown.sh gitea k|tail -1`
assertEquals "Unexpected gitea setup output" "$OUTPUT" "No project name given as the second parameter"
OUTPUT=`$CWD/bin/trackdown.sh gitea k backendzeit/markdown-demo|tail -1`
assertEquals "Unexpected gitea setup output" "$OUTPUT" "Setting up TrackDown to mirror from backendzeit/markdown-demo on https://codeberg.org"
assertExists "Config file missing" .trackdown/config
assertExists "Issue collection file missing" gitea-issues.md
assertExists "VCS ignore file missing" .hgignore
DIFF=`diff -u $MYDIR/giteamirror.config .trackdown/config`
assertEquals "Unexpected gitea mirror configuration" "$DIFF" ""
DIFF=`diff -u $MYDIR/giteamirror.ignore .hgignore`
assertEquals "Unexpected gitea ignore file" "$DIFF" ""
OUTPUT=`$CWD/bin/trackdown.sh gitea markdown-demo mgoellnitz|tail -1`
assertEquals "Unexpected gitea setup output" "$OUTPUT" "Mirror setup already done in this repository with type gitea."
# cleanup test
after
autocommit=false
autopush=false
location=github-issues.md
mirror.type=github
prefix=https://github.com/mgoellnitz/markdown-demo/commit/
github.owner=mgoellnitz
github.project=markdown-demo
github.key=k
^.trackdown$
^github-issues.md$
^roadmap.md$
#!/bin/bash
#
# Copyright 2016-2018 Martin Goellnitz
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# include test "framework"
MYDIR=`dirname $0`
source $MYDIR/shelltest.sh
# setup test
before
mkdir -p .hg
OUTPUT=`$CWD/bin/trackdown.sh mirror|tail -1`
assertEquals "Unexpected uninitialized mirror output" "$OUTPUT" "Project not initialized for trackdown use."
# test setup variants
export GITHUB_COM_TOKEN=
OUTPUT=`$CWD/bin/trackdown.sh github|tail -1`
# echo "$OUTPUT"
assertEquals "Unexpected github setup output" "$OUTPUT" "No api token given as the first parameter"
OUTPUT=`$CWD/bin/trackdown.sh github k|tail -1`
assertEquals "Unexpected github setup output" "$OUTPUT" "No project name given as the second parameter"
OUTPUT=`$CWD/bin/trackdown.sh github k markdown-demo|tail -1`
assertEquals "Unexpected github setup output" "$OUTPUT" "No username given as the third parameter"
OUTPUT=`$CWD/bin/trackdown.sh github k markdown-demo mgoellnitz|tail -1`
assertEquals "Unexpected github setup output" "$OUTPUT" "Setting up TrackDown to mirror markdown-demo owned by mgoellnitz from github.com"
assertExists "Config file missing" .trackdown/config
assertExists "Issue collection file missing" github-issues.md
assertExists "VCS ignore file missing" .hgignore
DIFF=`diff -u $MYDIR/githubmirror.config .trackdown/config`
assertEquals "Unexpected github mirror configuration" "$DIFF" ""
DIFF=`diff -u $MYDIR/githubmirror.ignore .hgignore`
assertEquals "Unexpected github ignore file" "$DIFF" ""
OUTPUT=`$CWD/bin/trackdown.sh github k markdown-demo mgoellnitz|tail -1`
assertEquals "Unexpected github setup output" "$OUTPUT" "Mirror setup already done in this repository with type github."
# cleanup test
after
autocommit=false
autopush=false
location=gitlab-issues.md
mirror.type=gitlab
gitlab.url=https://gitlab.com
gitlab.project=
gitlab.key=k
/.trackdown
/gitlab-issues.md
/roadmap.md
#!/bin/bash
#
# Copyright 2016-2018 Martin Goellnitz
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# include test "framework"
MYDIR=`dirname $0`
source $MYDIR/shelltest.sh
# setup test
before
# Must be done with Mercurial as the DVCS to avoid trouble with surrounding trackdown git
mkdir -p .hg
# test setup variants
OUTPUT=`$CWD/bin/trackdown.sh gitlab|tail -1`
# echo "$OUTPUT"
assertEquals "Unexpected gitlab setup output" "$OUTPUT" "No api token given as the first parameter"
OUTPUT=`$CWD/bin/trackdown.sh gitlab k|tail -1`
assertEquals "Unexpected gitlab setup output" "$OUTPUT" "No project name given as the second parameter"
OUTPUT=`$CWD/bin/trackdown.sh gitlab k backendzeit/markdown-demo|tail -1`
assertEquals "Unexpected gitlab setup output" "$OUTPUT" "Cannot fetch project ID for backendzeit/markdown-demo on https://gitlab.com"
## TODO: Cannot test all this without TOKEN
# assertEquals "Unexpected gitlab setup output" "$OUTPUT" "Setting up TrackDown to mirror from backendzeit/markdown-demo () on https://gitlab.com"
# assertExists "Config file missing" .trackdown/config
# assertExists "Issue collection file missing" gitlab-issues.md
# assertExists "VCS ignore file missing" .gitignore
# DIFF=`diff -u $MYDIR/gitlabmirror.config .trackdown/config`
# assertEquals "Unexpected gitlab mirror configuration" "$DIFF" ""
# DIFF=`diff -u $MYDIR/gitlabmirror.ignore .gitignore`
# assertEquals "Unexpected gitlab ignore file" "$DIFF" ""
# OUTPUT=`$CWD/bin/trackdown.sh gitlab markdown-demo mgoellnitz|tail -1`
# assertEquals "Unexpected gitlab setup output" "$OUTPUT" "Mirror setup already done in this repository with type gitlab."
# cleanup test
after
#!/bin/bash
#
# Copyright 2016 Martin Goellnitz
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# include test "framework"
MYDIR=`dirname $0`
source $MYDIR/shelltest.sh
# setup test
before
git init
git config --local user.name "Mr Tester"
git config --local user.email "test@provocon.eu"
cp -r $CWD/README.md .
cp -r $CWD/bin/t*sh .
# test trackdown init
OUTPUT=`$CWD/bin/trackdown.sh init|tail -1`
# echo "$OUTPUT"
assertEquals "Unexpected init output" "$OUTPUT" "GIT repository missing commits. Exiting."
git add README.md
git commit -m "First commit" README.md
OUTPUT=`$CWD/bin/trackdown.sh init|tail -1`
assertEquals "Unexpected init output" "$OUTPUT" " create mode 100644 roadmap.md"
OUTPUT=`$CWD/bin/trackdown.sh use|tail -1`
assertEquals "Unexpected use output" "$OUTPUT" "prepare local"
echo "" >> issues.md
echo "## FIRST issue" >> issues.md
echo "" >> issues.md
echo "*1.0*" >> issues.md
echo "" >> issues.md
echo "## LAST issue" >> issues.md
echo "" >> issues.md
echo "*1.0*" >> issues.md
echo "" >> issues.md
OUTPUT=`cat issues.md|wc -l`
assertEquals "Unexpected issue collection size" "$OUTPUT" "10"
git add trackdown.sh
OUTPUT=`git commit -m "refs #FIRST" trackdown.sh|tail -3|head -1`
# assertEquals "Unexpected commit hook output" "$OUTPUT" "prepare local"
OUTPUT=`grep "## FIRST" issues.md`
assertEquals "Unexpected issue collection content" "$OUTPUT" "## FIRST issue (in progress)"
OUTPUT=`cat issues.md|wc -l`
assertEquals "Unexpected issue collection size" "$OUTPUT" "14"
OUTPUT=`$CWD/bin/trackdown.sh copy 1.0|wc -l`
assertEquals "Unexpected output" "$OUTPUT" "1"
assertExists "Generated milestone file missing" .git/trackdown/1.0.md
assertExists "Generated remainder file missing" .git/trackdown/1.0-issues.md
OUTPUT=`cat .git/trackdown/1.0.md|wc -l`
assertEquals "Unexpected milestone file size" "$OUTPUT" "14"
OUTPUT=`cat .git/trackdown/1.0-issues.md|wc -l`
assertEquals "Unexpected remainder file size" "$OUTPUT" "2"
# cleanup test
after
#!/bin/bash
#
# Copyright 2016-2019 Martin Goellnitz
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# include test "framework"
MYDIR=`dirname $0`
source $MYDIR/shelltest.sh
# setup test
before
hg init
cp -r $CWD/README.md .
cp -r $CWD/bin/t*sh .
# test trackdown init
OUTPUT=`$CWD/bin/trackdown.sh init|tail -1`
# echo "$OUTPUT"
assertEquals "Unexpected init output" "$OUTPUT" "Mercurial repository missing commits. Exiting."
hg add README.md
hg commit -m "First commit" README.md
OUTPUT=`$CWD/bin/trackdown.sh init|tail -1`
assertEquals "Unexpected init output" "$OUTPUT" "1 files updated, 0 files merged, 2 files removed, 0 files unresolved"
OUTPUT=`$CWD/bin/trackdown.sh use|tail -1`
assertEquals "Unexpected use output" "$OUTPUT" "2 files updated, 0 files merged, 0 files removed, 0 files unresolved"
echo "" >> issues.md
echo "## FIRST issue" >> issues.md
echo "" >> issues.md
echo "*1.0*" >> issues.md
echo "" >> issues.md
echo "## LAST issue" >> issues.md
echo "" >> issues.md
echo "*1.0*" >> issues.md
echo "" >> issues.md
hg add trackdown.sh
OUTPUT=`hg commit -m "refs #FIRST" trackdown.sh|tail -3|head -1`
assertEquals "Unexpected commit hook output" "$OUTPUT" "adding file changes"
OUTPUT=`grep "## FIRST" issues.md`
assertEquals "Unexpected issue collection content" "$OUTPUT" "## FIRST issue (in progress)"
OUTPUT=`cat issues.md|wc -l`
assertEquals "Unexpected issue collection size" "$OUTPUT" "14"
# cleanup test
after
autocommit=false
autopush=false
location=redmine-issues.md
mirror.type=redmine
redmine.url=https://redmine.org
redmine.project=markdown-demo
redmine.key=k
^.trackdown$
^redmine-issues.md$
^roadmap.md$
#!/bin/bash
#
# Copyright 2016 Martin Goellnitz
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# include test "framework"
MYDIR=`dirname $0`
source $MYDIR/shelltest.sh
# setup test
before
mkdir -p .hg
# test setup variants
OUTPUT=`$CWD/bin/trackdown.sh redmine|tail -1`
# echo "$OUTPUT"
assertEquals "Unexpected redmine setup output" "$OUTPUT" "No api key given as the first parameter"
OUTPUT=`$CWD/bin/trackdown.sh redmine k|tail -1`
assertEquals "Unexpected redmine setup output" "$OUTPUT" "No project name given as the second parameter"
OUTPUT=`$CWD/bin/trackdown.sh redmine k markdown-demo|tail -1`
assertEquals "Unexpected redmine setup output" "$OUTPUT" "No redmine instance base url given as the third parameter"
OUTPUT=`$CWD/bin/trackdown.sh redmine k markdown-demo https://redmine.org|tail -1`
assertEquals "Unexpected redmine setup output" "$OUTPUT" "Setting up TrackDown to mirror from markdown-demo on https://redmine.org"
assertExists "Config file missing" .trackdown/config
assertExists "Issue collection file missing" redmine-issues.md
assertExists "VCS ignore file missing" .hgignore
DIFF=`diff -u $MYDIR/redminemirror.config .trackdown/config`
assertEquals "Unexpected redmine mirror configuration" "$DIFF" ""
DIFF=`diff -u $MYDIR/redminemirror.ignore .hgignore`
assertEquals "Unexpected redmine ignore file" "$DIFF" ""
OUTPUT=`$CWD/bin/trackdown.sh redmine k markdown-demo https://redmine.org|tail -1`
assertEquals "Unexpected redmine setup output" "$OUTPUT" "Mirror setup already done in this repository with type redmine."
# cleanup test
after
#!/bin/bash
#
# Copyright 2016 Martin Goellnitz
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
function before {
CWD=`pwd`
TEST=`basename $0 .sh`
rm -rf build/test/$TEST
mkdir -p build/test/$TEST
cd build/test/$TEST
echo "Executing test '$TEST'"
}
function after {
cd $CWD
}
# assert that variable $2 has value $3, outputs message $1 otherwise
function assertEquals {
if [ "$2" != "$3" ] ; then
echo "$1: '$2' - expected '$3'"
pwd
exit 1
fi
}
# assert that file $2 exists, outputs message $1 otherwise
function assertExists {
if [ ! -f $2 ] ; then
echo "$1: $2"
pwd
exit 1
fi
}
#!/bin/bash
#
# Copyright 2016-2018 Martin Goellnitz
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# include test "framework"
source `dirname $0`/shelltest.sh
# setup test
before
# test number of lines in usage message
USAGE=`$CWD/bin/trackdown.sh|wc -l`
assertEquals "Unexpected usage output" $USAGE 58
# test if every command section in the script has a usage hint
$CWD/bin/trackdown.sh|grep ^trackdown.sh|cut -d ' ' -f 2|sort > usages.txt
grep CMD..= $CWD/bin/trackdown.sh|cut -d '"' -f 4|sort > commands.txt
DIFF=`diff -u usages.txt commands.txt`
assertEquals "Command missing or surplus usage hint" "$DIFF" ""
# cleanup test
after
Usage:
CMD roadmap [collection file]
Print roadmap
CMD ls v [collection file]
List issues for version v
CMD copy v [collection file]
Copy the notes for all issues for version v to a file name v.md
CMD mine [me] [collection file]
List issues which are marked to be mine
CMD issues [collection file]
List all potential issues
CMD use [collection file]
Setup clone for issue tracking (optionally with non-default file)
CMD update
Update repository clone to the latest git commit hook
CMD init
Init issue tracking within GIT or Mercurial branch
CMD mirror
Sync with reviously setup tracking master
(gitlab, github, bitbucket.org, redmine, gogs, gitea, pikacode - needs jq)
CMD remote c i p
Issue remote command c on issue i with parameter p on remote mirroring source system
CMD github k [p [o]]
Setup github mirroring project p of owner o with given apikey k.
(needs jq) - Values default to cloned project you're in.
CMD gitlab k p [u]
Setup gitlab mirroring project p with given apikey k and gitlab base url u.
(needs jq) - Values default to cloned project you're in.
CMD bitbucket [[t/]p [u[:c]]]
Setup bitbucket.org mirroring project p (in team t) with for user u and (app password c)
(needs jq) - Values default to cloned project you're in.
CMD gitea k [p [u]]
setup gitea (or gogs) mirroring project p with given apikey k and gitea/codeberg/pikacode/gogs base url u
(needs jq) - Values default to cloned project you're in.
CMD redmine k p u
setup redmine mirroring project p with given apikey k and redmine base url u.
(needs jq)
CMD status
Show brief information about the GIT or Mercurial state of the issue collection branch or directory
CMD sync
Synchronize the remote repository with the TrackDown issues and roadmap for Mercurial or GIT