blob: c9523e0e7964726814f77a8495f90868273eaeae [file] [log] [blame]
Zack Williams12783ac2018-06-12 15:13:12 -07001#!/usr/bin/env bash
2
3# Copyright 2018-present Open Networking Foundation
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17# tagcollisionreject.sh
18# checks that there isn't an existing tag in the repo that has this tag
19
20set -eu -o pipefail
21
22NEW_VERSION=""
23
24# find the version string in the repo, read into NEW_VERSION
25# Add additional places NEW_VERSION could be found to this function
26function read_version {
27 if [ -f "VERSION" ]
28 then
29 NEW_VERSION=$(head -n1 "VERSION")
30 echo "New version: $NEW_VERSION"
31 else
32 echo "ERROR: No versioning file found!"
33 exit 1
34 fi
35}
36
37# check if the version is already a tag in git
38function is_git_tag_duplicated {
39 for existing_tag in $(git tag)
40 do
41 if [ "$NEW_VERSION" = "$existing_tag" ]
42 then
43 echo "ERROR: Duplicate tag: $existing_tag"
44 exit 2
45 fi
46 done
47}
48
49echo "Checking git repo with remotes:"
50git remote -v
51
52echo "Branches:"
53git branch -v
54
55echo "Existing git tags:"
56git tag -n
57
58read_version
59is_git_tag_duplicated
60
61exit 0
62