xref: /JGit/tools/version.sh (revision fc5fc70e2e8cc8e3ef493e130c3227ef83400f80)
16f06be9bSShawn O. Pearce#!/bin/sh
26f06be9bSShawn O. Pearce# Copyright (C) 2009, Google Inc.
36f06be9bSShawn O. Pearce# and other copyright owners as documented in the project's IP log.
46f06be9bSShawn O. Pearce#
56f06be9bSShawn O. Pearce# This program and the accompanying materials are made available
66f06be9bSShawn O. Pearce# under the terms of the Eclipse Distribution License v1.0 which
76f06be9bSShawn O. Pearce# accompanies this distribution, is reproduced below, and is
86f06be9bSShawn O. Pearce# available at http://www.eclipse.org/org/documents/edl-v10.php
96f06be9bSShawn O. Pearce#
106f06be9bSShawn O. Pearce# All rights reserved.
116f06be9bSShawn O. Pearce#
126f06be9bSShawn O. Pearce# Redistribution and use in source and binary forms, with or
136f06be9bSShawn O. Pearce# without modification, are permitted provided that the following
146f06be9bSShawn O. Pearce# conditions are met:
156f06be9bSShawn O. Pearce#
166f06be9bSShawn O. Pearce# - Redistributions of source code must retain the above copyright
176f06be9bSShawn O. Pearce#   notice, this list of conditions and the following disclaimer.
186f06be9bSShawn O. Pearce#
196f06be9bSShawn O. Pearce# - Redistributions in binary form must reproduce the above
206f06be9bSShawn O. Pearce#   copyright notice, this list of conditions and the following
216f06be9bSShawn O. Pearce#   disclaimer in the documentation and/or other materials provided
226f06be9bSShawn O. Pearce#   with the distribution.
236f06be9bSShawn O. Pearce#
246f06be9bSShawn O. Pearce# - Neither the name of the Eclipse Foundation, Inc. nor the
256f06be9bSShawn O. Pearce#   names of its contributors may be used to endorse or promote
266f06be9bSShawn O. Pearce#   products derived from this software without specific prior
276f06be9bSShawn O. Pearce#   written permission.
286f06be9bSShawn O. Pearce#
296f06be9bSShawn O. Pearce# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
306f06be9bSShawn O. Pearce# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
316f06be9bSShawn O. Pearce# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
326f06be9bSShawn O. Pearce# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
336f06be9bSShawn O. Pearce# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
346f06be9bSShawn O. Pearce# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
356f06be9bSShawn O. Pearce# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
366f06be9bSShawn O. Pearce# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
376f06be9bSShawn O. Pearce# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
386f06be9bSShawn O. Pearce# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
396f06be9bSShawn O. Pearce# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
406f06be9bSShawn O. Pearce# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
416f06be9bSShawn O. Pearce# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
426f06be9bSShawn O. Pearce
436f06be9bSShawn O. Pearce
44*fc5fc70eSShawn O. Pearce# Update all pom.xml with new build number
456f06be9bSShawn O. Pearce#
466f06be9bSShawn O. Pearce# TODO(spearce) This should be converted to some sort of
476f06be9bSShawn O. Pearce# Java based Maven plugin so its fully portable.
486f06be9bSShawn O. Pearce#
496f06be9bSShawn O. Pearce
506f06be9bSShawn O. Pearcecase "$1" in
516f06be9bSShawn O. Pearce--snapshot=*)
526f06be9bSShawn O. Pearce	V=$(echo "$1" | perl -pe 's/^--snapshot=//')
536f06be9bSShawn O. Pearce	if [ -z "$V" ]
546f06be9bSShawn O. Pearce	then
556f06be9bSShawn O. Pearce		echo >&2 "usage: $0 --snapshot=0.n.0"
566f06be9bSShawn O. Pearce		exit 1
576f06be9bSShawn O. Pearce	fi
586f06be9bSShawn O. Pearce	case "$V" in
596f06be9bSShawn O. Pearce	*-SNAPSHOT) : ;;
606f06be9bSShawn O. Pearce	*) V=$V-SNAPSHOT ;;
616f06be9bSShawn O. Pearce	esac
626f06be9bSShawn O. Pearce	;;
636f06be9bSShawn O. Pearce
646f06be9bSShawn O. Pearce--release)
656f06be9bSShawn O. Pearce	V=$(git describe HEAD) || exit
666f06be9bSShawn O. Pearce	;;
676f06be9bSShawn O. Pearce
686f06be9bSShawn O. Pearce*)
696f06be9bSShawn O. Pearce	echo >&2 "usage: $0 {--snapshot=0.n.0 | --release}"
706f06be9bSShawn O. Pearce	exit 1
716f06be9bSShawn O. Pearceesac
726f06be9bSShawn O. Pearce
736f06be9bSShawn O. Pearcecase "$V" in
746f06be9bSShawn O. Pearcev*) V=$(echo "$V" | perl -pe s/^v//) ;;
756f06be9bSShawn O. Pearceesac
766f06be9bSShawn O. Pearce
776f06be9bSShawn O. Pearcecase "$V" in
786f06be9bSShawn O. Pearce*-SNAPSHOT)
796f06be9bSShawn O. Pearce	POM_V=$V
806f06be9bSShawn O. Pearce	;;
816f06be9bSShawn O. Pearce*-[1-9]*-g[0-9a-f]*)
826f06be9bSShawn O. Pearce	POM_V=$(echo "$V" | perl -pe 's/-(\d+-g.*)$/.$1/')
836f06be9bSShawn O. Pearce	;;
846f06be9bSShawn O. Pearce*)
856f06be9bSShawn O. Pearce	POM_V=$V
866f06be9bSShawn O. Pearce	;;
876f06be9bSShawn O. Pearceesac
886f06be9bSShawn O. Pearce
896f06be9bSShawn O. Pearceperl -pi -e '
906f06be9bSShawn O. Pearce	if ($ARGV ne $old_argv) {
916f06be9bSShawn O. Pearce		$seen_version = 0;
926f06be9bSShawn O. Pearce		$old_argv = $ARGV;
936f06be9bSShawn O. Pearce	}
946f06be9bSShawn O. Pearce	if (!$seen_version) {
956f06be9bSShawn O. Pearce		$seen_version = 1 if
96*fc5fc70eSShawn O. Pearce		s{<(version)>.*</\1>}{<${1}>'"$POM_V"'</${1}>};
976f06be9bSShawn O. Pearce	}
986f06be9bSShawn O. Pearce	' $(git ls-files | grep pom.xml)
996f06be9bSShawn O. Pearce
1006f06be9bSShawn O. Pearcegit diff
101