1#!/usr/bin/env bash 2 3# Copyright 2016 The Fuchsia Authors 4# Copyright (c) 2015 Travis Geiselbrecht 5# 6# Use of this source code is governed by a MIT-style 7# license that can be found in the LICENSE file or at 8# https://opensource.org/licenses/MIT 9 10GIT_REV="git-$(git rev-parse HEAD 2>/dev/null)" 11# Is there a .git or revision? 12if [ $? -eq 0 ]; then 13 if [ -n "$(git status --porcelain 2>/dev/null)" ]; then 14 GIT_REV+="-dirty" 15 fi 16else 17 GIT_REV="unknown" 18fi 19 20if [ $# -eq 1 ]; then 21 cat > "$1" <<END 22#ifndef __BUILDID_H 23#define __BUILDID_H 24#define ${GIT_REV} 25#endif 26END 27else 28 echo "${GIT_REV}" 29fi 30