#!/bin/sh -e
# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# Outputs a version string with the specified prefix.

if [ ! "$#" = 1 ]; then
    echo "Usage: ${0##*/} VERSION" 1>&2
    exit 1
fi

source=''

# Get the branch from git
githead="`dirname "$0"`/../.git/HEAD"
if [ -f "$githead" ]; then
    source="`cut -d/ -f3 "$githead"`"
    source="${source:+"~"}$source"
fi

VERSION="$1-%Y%m%d%H%M%S$source"

exec date "+$VERSION"

#!/bin/sh -e
# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# Outputs a version string with the specified prefix.

if [ ! "$#" = 1 ]; then
    echo "Usage: ${0##*/} VERSION" 1>&2
    exit 1
fi

source=''

# Get the branch from git
git="`dirname "$0"`/../.git"
if [ -f "$git/HEAD" ]; then
    source="`cut -d/ -f3 "$git/HEAD"`"
    if [ -n "$source" ]; then
        if [ -f "$git/refs/heads/$source" ]; then
            source="$source:`head -c 8 "$git/refs/heads/$source"`"
        fi
        source="~$source"
    fi
fi

VERSION="$1-%Y%m%d%H%M%S$source"

exec date "+$VERSION"

Include the git commit as well in the version string.
Include the git commit as well in the version string.
