Code indexing in gitaly is broken and leads to code not being visible to the user. We work on the issue with highest priority.

Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
gen_OPALrevision 918 B
#!/bin/bash
#
# create/rewrite 'src/OPALrevision.h'
#

print () {
    echo '#define GIT_VERSION '\"$1\" > src/OPALrevision-new.h
    if [[ -e  src/OPALrevision.h ]] && cmp -s src/OPALrevision.h src/OPALrevision-new.h; then
        rm src/OPALrevision-new.h
    else
        mv src/OPALrevision-new.h src/OPALrevision.h
    fi
}

# if git(1) is not in $PATH
if ! which -a git &> /dev/null; then
    if  [[ -e  src/OPALrevision.h ]]; then
        # do nothing if file exist
        exit 0
    else
        # otherwise create file
        print unknown
        exit $?
    fi
fi

# if we are in a work-tree
if git rev-parse --is-inside-work-tree &> /dev/null; then
    # create/rewrite file
    revision=$(git rev-parse HEAD)
    print ${revision}
    exit $?
fi

# if we are not in a work tree and the file does not exist
if [[ ! -e  src/OPALrevision.h ]]; then
    # create file
    print unknown
    exit $?
fi

exit 0