blob: 8fa98966133f519866ff7467330af6e0e167cbc6 [file] [log] [blame]
#!/usr/bin/env bash
#*******************************************************************************
# Copyright (c) 2016 IBM Corporation and others.
#
# This program and the accompanying materials
# are made available under the terms of the Eclipse Public License 2.0
# which accompanies this distribution, and is available at
# https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# David Williams - initial API and implementation
#*******************************************************************************
GITCOMMIT=$( git rev-parse HEAD )
#GITDATE=$( git log -1 --format="%H%n%aD" --date=short )
# we go to a lot of trouble here, just to get
# short form, in prettiest way, using git commands
# as much a possible, instead of heuristic parsing.
git symbolic-ref --quiet HEAD >/dev/null
if (( $? == 0 ))
then
GITBRANCH=$( git rev-parse --abbrev-ref HEAD )
else
GITBRANCH='[Not on a branch]'
fi
GITTAG=$( git describe --abbrev=0 --exact-match --contains --tags $GITCOMMIT )
#echo "GITTAG: $GITTAG"
SHORT_TAG=${GITTAG##*/}
#echo "SHORT_TAG: $SHORT_TAG"
#echo "pwd: ${PWD}"
REPONAME=${PWD##*/}
case "$REPONAME" in
eclipse.platform*)
REPOROOT="platform";;
eclipse.jdt*)
REPOROOT="jdt";;
eclipse.pde*)
REPOROOT="pde";;
rt.equinox*)
REPOROOT="equinox";;
*)
echo "WARNING: unrecognized reponame pattern for $REPONAME";;
esac
#echo "REPOROOT: $REPOROOT"
#echo "reponame: ${REPONAME}"
#echo "git_dir: $GIT_DIR"
# git ls-remote http://www.kernel.org/pub/scm/git/git.git master pu rc
# git://git.eclipse.org/gitroot/platform/eclipse.platform.releng.aggregator.git
REMOTETAG=$( git ls-remote --tags git://git.eclipse.org/gitroot/${REPOROOT}/${REPONAME}.git $SHORT_TAG )
if [[ -z "${REMOTETAG}" ]]
then
REMOTETAG='[No tag in remote (canonical) repository]'
else
REMOTETAG=${REMOTETAG##*/}
fi
#echo "REMOTETAG: $REMOTETAG"
printf " %s \t%s \t%s \t%s \t%s \n" "$REPONAME $GITCOMMIT $GITBRANCH $SHORT_TAG $REMOTETAG"