Skip to content
This repository has been archived by the owner. It is now read-only.

Commit

Permalink
Make links clickable in gitlog output of publication diff script
Browse files Browse the repository at this point in the history
  • Loading branch information
Rhys Smith committed Aug 17, 2016
1 parent bac1ab2 commit 907ea4d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 20 deletions.
6 changes: 4 additions & 2 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1545,8 +1545,10 @@
<then>
<exec executable="bash" failonerror="true" outputproperty="diff.between.publications">
<arg value="${utilities.dir}/diff-between-publications.sh"/>
<arg value="${shared.ws.dir}/${git.repo.project.data}"/>
<arg value="${shared.ws.dir}/${git.repo.project.products}"/>
<arg value="${shared.ws.dir}"/>
<arg value="${git.repo.group}"/>
<arg value="${git.repo.project.data}"/>
<arg value="${git.repo.project.products}"/>
</exec>
<SLACK.send conf="${tools.slacktee}/conf/aggr-ant.conf" colour="good"
message="${diff.between.publications}"/>
Expand Down
40 changes: 22 additions & 18 deletions utilities/diff-between-publications.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,50 @@
# the differences since the last.
#
# Expects the following to be provided as arguments:
# * Absolute path to data repository
# * Absolute path to products repository
# * Absolute path to shared workspace directory
# * Git project's group name
# * Git data repository's name
# * Git products repository's name
#
# Assumes the data repository's master branch is currently checked out.
#

# Fail if $1 and $2 aren't provided.
if [[ -z $1 && -z $2 ]]; then
echo "usage: diff-between-publications.sh <path to data repository> <path to products repository>"
# Fail if $1, $2, $3, and $4 aren't provided.
if [[ -z $1 && -z $2 && -z $3 && -z $4 ]]; then
echo "usage: diff-between-publications.sh <path to shared workspace> <git group name> <git data repository name> <git products repository name>"
exit 1
fi

# Get the input
repodata=$1
repoproducts=$2
sharedwsdir=$1
repogroup=$2
repodata=$3
repoproducts=$4

# =====
# = First of all, we need to calculate some stuff.
# =====

# Figure out name of the latest tag and the previous tag.
# These point to the latest, and previous, publication.
currenttag=$(git --work-tree=$repoproducts --git-dir=$repoproducts/.git tag | tail -n 1)
previoustag=$(git --work-tree=$repoproducts --git-dir=$repoproducts/.git tag | tail -n 2 | head -n 1)
currenttag=$(git --work-tree=$sharedwsdir/$repoproducts --git-dir=$sharedwsdir/$repoproducts/.git tag | tail -n 1)
previoustag=$(git --work-tree=$sharedwsdir/$repoproducts --git-dir=$sharedwsdir/$repoproducts/.git tag | tail -n 2 | head -n 1)

# Calculate current member count (the final awk is for Mac compatibility, since wc on Mac outputs leading spaces)
membercount=$(grep 'Member ID' $repodata/members/members.xml | wc -l | awk '{print $1}')
membercount=$(grep 'Member ID' $sharedwsdir/$repodata/members/members.xml | wc -l | awk '{print $1}')

# Calculate current entities count (UK only)
entitycountuk=$(grep 'registrationAuthority="http://ukfederation.org.uk"' $repoproducts/aggregates/ukfederation-metadata.xml | wc -l | awk '{print $1}')
entitycountuk=$(grep 'registrationAuthority="http://ukfederation.org.uk"' $sharedwsdir/$repoproducts/aggregates/ukfederation-metadata.xml | wc -l | awk '{print $1}')

# Calculate current entities count (total, including all imported entities)
entitycounttotal=$(grep '<EntityDescriptor' $repoproducts/aggregates/ukfederation-metadata.xml | wc -l | awk '{print $1}')
entitycounttotal=$(grep '<EntityDescriptor' $sharedwsdir/$repoproducts/aggregates/ukfederation-metadata.xml | wc -l | awk '{print $1}')

# Calculate size of current aggregate, in bytes and MB
currentaggregatesize=$(cat $repoproducts/aggregates/ukfederation-metadata.xml | wc -c)
currentaggregatesize=$(cat $sharedwsdir/$repoproducts/aggregates/ukfederation-metadata.xml | wc -c)
currentaggregatesizemb=$(echo "scale=2;$currentaggregatesize/1024/1024" | bc )

# Calculate size of previous aggregate
previousaggregatesize=$(git --work-tree=$repoproducts --git-dir=$repoproducts/.git show $previoustag:aggregates/ukfederation-metadata.xml | wc -c)
previousaggregatesize=$(git --work-tree=$sharedwsdir/$repoproducts --git-dir=$sharedwsdir/$repoproducts/.git show $previoustag:aggregates/ukfederation-metadata.xml | wc -c)
previousaggregatesizemb=$(echo "scale=2;$previousaggregatesize/1024/1024" | bc )

# Calculate difference in size between current and previous in both absolute and percentage terms
Expand All @@ -54,10 +58,10 @@ aggregatesizediffpc=$(echo "scale=5;$aggregatesizediff/$previousaggregatesize" |
# -> First, calculate date/time of latest publication (epoch) in products repo
# -> Next, calculate date/time of previous publication (epoch) in products repo
# -> Finally, get a git log between those two dates (epoch) in data repo
currenttagdate=$(git --work-tree=$repoproducts --git-dir=$repoproducts/.git log -1 $currenttag --format=%ct)
previoustagdate=$(git --work-tree=$repoproducts --git-dir=$repoproducts/.git log -1 $previoustag --format=%ct)
gitlog=$(git --work-tree=$repodata --git-dir=$repodata/.git log --format="%h %an %s" --after=$previoustagdate --before=$currenttagdate)
gitlognumentries=$(git --work-tree=$repodata --git-dir=$repodata/.git log --format="%h %an %s" --after=$previoustagdate --before=$currenttagdate | wc -l | awk '{print $1}')
currenttagdate=$(git --work-tree=$sharedwsdir/$repoproducts --git-dir=$sharedwsdir/$repoproducts/.git log -1 $currenttag --format=%ct)
previoustagdate=$(git --work-tree=$sharedwsdir/$repoproducts --git-dir=$sharedwsdir/$repoproducts/.git log -1 $previoustag --format=%ct)
gitlog=$(git --work-tree=$sharedwsdir/$repodata --git-dir=$sharedwsdir/$repodata/.git log --format="<https://repo.infr.ukfederation.org.uk/$repogroup/$repodata/commit/%h|%h %an %s>" --after=$previoustagdate --before=$currenttagdate)
gitlognumentries=$(git --work-tree=$sharedwsdir/$repodata --git-dir=$sharedwsdir/$repodata/.git log --format="%h" --after=$previoustagdate --before=$currenttagdate | wc -l | awk '{print $1}')

# =====
# = Now we're ready to output the message
Expand Down

0 comments on commit 907ea4d

Please sign in to comment.