autorevision-1.22/0000755000076500000240000000000014003624437013043 5ustar dak180staffautorevision-1.22/AUTHORS.txt0000644000076500000240000000115214003624437014730 0ustar dak180staffdak180 Eric S. Raymond Paul Wise Mike Swanson Dmitry Marakasov Vlad Dennis Biringer Gunter Labes allevo Robert Tiemann Qiuwen Lu Jérôme Pouiller Joel C. Salomon yuanchuan vagrant Robert Wenner Hironori Ichimiya Andrei Nigmatulin autorevision-1.22/autorevision.asciidoc0000644000076500000240000002144513527773751017316 0ustar dak180staff= AUTOREVISION(1) = == NAME == autorevision - extract current-revision metadata from version-control repositories == SYNOPSIS == *autorevision* *-t* [*-o* [*-f*] ] [*-e* ] [*-U*] [*-C* ] [*-q*] *autorevision* *-s* [*-o* [*-f*] ] [*-e* ] [*-U*] [*-C* ] [*-q*] *autorevision* *-V* == DESCRIPTION == Extracts metadata about the head revision from your repository. This program is meant to be used by project build systems to extract properties that can be used in version strings. It can emit source files containing variable and macro definitions suitable for use with C, C++, Java, Mac info.plist, sh, Python, Perl and many other types of files (see below for the full list). The generated source is written to the standard output. This program can normally be called from anywhere within a repository copy. Under bzr the copy must be of a branch, not a full multibranch repository. Under Subversion it must be called under a repository checkout, not the repository itself. If you specify a cache file, then when *autorevision* is run where no repository can be recognized, the values from the cache file will be used instead. If a repository can be recognized, the cache is rewritten. This feature makes it possible for your build to run from an unpacked tarball that includes the cache file. === Valid Repository Types === *Git*: A version greater than 1.7.2.3 is recommended. *Mercurial*: A version greater than 1.6 is recommended. *Subversion*: Any production version. *Bazaar*: Any production version. === Valid Output Types === *clojure*:: A clojure source file setting clojure variables. *c*:: A C/C++ source file. + `autorevision_declr.h` in the contribs dir is provided for use with this output. *cmake*:: A cmake script file. *csharp*:: C# file with Autorevision class *h*:: A header file suitable for C/C++. *hpp*:: Alternate C++ header file with namespace. Namespace is assigned from VCS_BASENAME. *ini*:: A ini source file setting ini variables. *java*:: A Java source file setting class properties. *javaprop*:: A Java properties file (like ini); useful when META-INF is readable in Java. *js*:: A javascript source file setting javascript variables. *json*:: A JSON format file. *lua*:: A lua source file setting lua variables. *m4*:: An m4 source file defining m4 macros. *matlab*:: Matlab output. *octave*:: Octave output. *php*:: A PHP source file setting PHP variables. *pl*:: A Perl source file setting Perl variables (*`perl`* is an acceptable synonym). *py*:: A Python source file setting Python variables (*`python`* is an acceptable synonym). *rpm*:: A RPM spec file format setting spec file macros. *scheme*:: A scheme source file setting scheme variables. *sed*:: A sed script that replaces symbol names enclosed in @ symbols. It uses the | character as a separator in the sed commands. You can run it using `sed -f script.sed file-to-edit`. *sh*:: A text file suitable for including from a bash script. Will work with Ruby. *swift*:: A Swift source file setting Swift global constants. + Unless set *VCS_EXTRA* and any symbols that are missing because of repository support are set to `nil`. *tex*:: A TeX source file defining TeX macros. Note that the symbols are given different names since the underscore has a special meaning in TeX. For example, VCS_SHORT_HASH is renamed to \vcsShortHash. *xcode*:: A header like output for use with xcode to populate info.plist strings. === Valid Symbol Names === *VCS_TYPE*:: The repository type - "git", "hg", "bzr", or "svn". *VCS_BASENAME*:: The basename of the directory root. For most VCSes this will simply be the basename of the repository root directory. For Subversion, *autorevision* will attempt to navigate up though trunk, branches, and tags directories to find the actual root. *VCS_NUM*:: A count of revisions between the current one and the initial one; useful for reporting build numbers. *VCS_UUID*:: A universally unique identifier, generated from the root commit in git and hg; for svn it uses the supplied UUID. + For git we choose the oldest commit if there is more than one. + Not currently implemented for bzr. *VCS_DATE*:: The date of the most recent commit in true ISO-8601/RFC3339 format, including seconds. *VCS_BRANCH*:: The name of the branch of the commit graph that was selected when autoversion was run. + Under git, this will normally be the shortname of the current branch (the asterisked line in the output of "git branch") except that when the branch doesn't have a shortname it will be a full refspec. + Under hg the feature that is called 'branches' is actually a sort of graph coloring (multiple heads can have the same branch name) so this symbol is filled with the current bookmark if it exists, with the current branch name as a fallback. + Under Subversion this will normally be either 'trunk' or the basename of some branch or tag subdirectory, depending on where *autoversion* was run. + Under bzr, this is the nick of the branch you are on. *VCS_TAG*:: The name of the most recent tag ancestral to the current commit. + Empty under Subversion. *VCS_TAG_OPENPGP*:: The fingerprint OpenPGP of the key that that signed the current tag. + Blank if the current tag is not signed or if no tags exist. + Currently only implemented for git. *VCS_TICK*:: A count of commits since most recent tag ancestral to the current commit or an alias of *VCS_NUM* if there are no prior tags. + Empty under Subversion. *VCS_EXTRA*:: A symbol set aside specifically to be set by the user through the environment or via scripts. + Additionally, the name of this symbol may be customized as well. ('See *-e* for more info.') *VCS_ACTION_STAMP*:: An "action stamp" consists of an RFC3339 timestamp in Zulu time, followed by an exclamation point, followed by an RFC822 address (technically, an "addr-spec" as defined in 6.1). + For svn the second part is simply the author name. + Not currently implemented for bzr. *VCS_FULL_HASH*:: A full unique identifier for the current revision. *VCS_COMMIT_OPENPGP*:: The fingerprint OpenPGP of the key that that signed the current revision. + Blank if the current revision is not signed. + Currently only implemented for git. *VCS_SHORT_HASH*:: A shortened version of *VCS_FULL_HASH*, but *VCS_FULL_HASH* if it cannot be shortened. *VCS_WC_MODIFIED*:: Set to `1` if the current working directory has been modified and `0` if not. If the output language has native Boolean literals, true will mean modified and false unmodified. The C/C++ output is left as numeric so the preprocessor can test it. + 'Untracked files are not ignored; see *`-U`* for details.' == OPTIONS == *-t* '':: Sets the output type. It is required unless *`-s`* is specified; both *`-t`* and *`-s`* cannot be used in the same invocation. *-s* '':: Changes the reporting behavior; instead of emitting a symbol file to stdout, only the value of that individual symbol will be reported. It is required unless *`-t`* is specified; both *`-t`* and *`-s`* cannot be used in the same invocation. *-o* '':: Sets the name of the cache file. *-e* '':: Sets the output name of *VCS_EXTRA* + Defaults to `VCS_EXTRA`. *-f*:: Forces the use of cache data even when in a repo; useful for speeding up subsequent runs if more than one output format is needed. *-U*:: Causes untracked files to be checked when determining if the working copy is modified 'for Subversion only'. While this is the default behavior for all other repository types, it is off by default for Subversion because of speed concerns. *-C* '':: Change working directory to given path. This allows autorevision to extract metadata from repositories found at a specific path to support VPATH or out-of-source builds. *-q*:: Silence warnings. *-V*:: Emits the autorevision version and exits. == BUGS == The bzr extractor is not very well tested. When a git repo is actually a git-svn remote, this tool tries to do the right thing and return a Subversion revision. The bug is that the detector code for this case is somewhat unreliable; you will get the hash instead if your configuration doesn't use svn-remote.svn.url. Nested repositories, particularly repositories of different types, _may_ result in incorrect and unintended behavior. Unpacking a tarball into a repository _will_ result in incorrect and unintended behavior. == Notes == Development of autorevision is carried out at https://github.com/Autorevision/autorevision HTML rendered docs and usage examples can be found at https://autorevision.github.io/ == AUTHORS == dak180 : concept, bash/C/C++/XCode/PHP/ini support, git and hg extraction. + Eric S. Raymond : Python/Perl/lua/m4 support, svn and bzr extraction, git-svn support, CLI design, man page. + See AUTHORS.txt for a full list in order of number of contributions. autorevision-1.22/autorevision.cache0000644000076500000240000000105214003624405016550 0ustar dak180staff# Generated by autorevision - do not hand-hack! VCS_TYPE="git" VCS_BASENAME="autorevision" VCS_UUID="da2830f81fec4c6ebce8ebf23f35b0e6b066c149" VCS_NUM="448" VCS_DATE="2021-01-25T20:20:59Z" VCS_BRANCH="master" VCS_TAG="v/1.22" VCS_TAG_OPENPGP="A16E4FE1BFE882DE9D6E28AD0044B6E72C414317" VCS_TICK="0" VCS_EXTRA="" VCS_ACTION_STAMP="2021-01-25T20:20:59Z!dak180@users.sourceforge.net" VCS_FULL_HASH="71e9cd60c05c8c3fa4395f2dc719c9461ca4c90c" VCS_COMMIT_OPENPGP="A16E4FE1BFE882DE9D6E28AD0044B6E72C414317" VCS_SHORT_HASH="71e9cd6" VCS_WC_MODIFIED="0" # end autorevision-1.22/autorevision.sh0000755000076500000240000011262514003623512016131 0ustar dak180staff#!/bin/sh # Copyright (c) 2012 - 2021 dak180 and contributors. See # https://opensource.org/licenses/mit-license.php or the included # COPYING.md for licence terms. # # autorevision - extracts metadata about the head version from your # repository. # shellcheck disable=SC2154,SC2236,SC2030,SC2031 # Usage message. arUsage() { tee >&2 << EOF usage: autorevision {-t output-type | -s symbol} [-o cache-file [-f] ] [-e name] [-U] [-C path] [-q] [-V] Options include: -t output-type = specify output type -s symbol = specify symbol output -o cache-file = specify cache file location -f = force the use of cache data -e name = set a different output name for VCS_EXTRA -U = check for untracked files in svn -C path = change to path before working on repository -q = Silence warnings -V = emit version and exit -? = help message The following are valid output types: c = C/C++ file clojure = clojure file cmake = CMake script file csharp = CSharp properties file h = Header for use with c/c++ hpp = Alternate C++ header strings with namespace ini = INI file java = Java file javaprop = Java properties file js = javascript file json = JSON file lua = Lua file m4 = m4 file matlab = matlab file octave = octave file php = PHP file pl = Perl file py = Python file rpm = rpm file scheme = scheme file sed = sed script sh = Bash sytax swift = Swift file tex = (La)TeX file xcode = Header useful for populating info.plist files The following are valid symbols: VCS_TYPE VCS_BASENAME VCS_UUID VCS_NUM VCS_DATE VCS_BRANCH VCS_TAG VCS_TAG_OPENPGP VCS_TICK VCS_EXTRA VCS_FULL_HASH VCS_COMMIT_OPENPGP VCS_SHORT_HASH VCS_WC_MODIFIED VCS_ACTION_STAMP EOF exit 1 } # Config ARVERSION="&&ARVERSION&&" while getopts ":t:o:s:e:C:VfqU" OPTION; do case "${OPTION}" in t) AFILETYPE="${OPTARG}" ;; o) CACHEFILE="${OPTARG}" ;; f) CACHEFORCE="1" ;; s) VAROUT="${OPTARG}" ;; e) EXTRA_NAME="${OPTARG}" ;; C) CHANGE_TO_DIR="${OPTARG}" ;; U) UNTRACKEDFILES="1" ;; q) WARNHIDE="1" ;; V) echo "autorevision ${ARVERSION}" exit 0 ;; ?) # If an unknown flag is used (or -?): arUsage ;; esac done if [ ! -z "${VAROUT}" ] && [ ! -z "${AFILETYPE}" ]; then # If both -s and -t are specified: echo "error: Improper argument combination." 1>&2 exit 1 elif [ -z "${VAROUT}" ] && [ -z "${AFILETYPE}" ]; then # If neither -s or -t are specified: arUsage elif [ -z "${CACHEFILE}" ] && [ "${CACHEFORCE}" = "1" ]; then # If -f is specified without -o: arUsage elif [ ! -f "${CACHEFILE}" ] && [ "${CACHEFORCE}" = "1" ]; then # If we are forced to use the cache but it does not exist. echo "error: Cache forced but no cache found." 1>&2 exit 1 fi # Only use the local keyword if it is there (ksh we are looking at # you). if [ "$(command -v local 2> /dev/null)" = "local" ]; then LOCAL="local" elif [ "$(command -v typeset 2> /dev/null)" = "typeset" ]; then LOCAL="typeset" else LOCAL="" fi #check if needed software is installed commands="sed cut grep wc tail basename dirname tee getopts tr cmp" for command in ${commands}; do if ! command -v "${command}" > /dev/null 2>&1; then echo "${command} is missing, please install" exit 100 fi done # Make sure that the path we are given is one we can source # (dash, we are looking at you). if [ ! -z "${CACHEFILE}" ] && ! echo "${CACHEFILE}" | grep -q '^\.*/'; then CACHEFILE="./${CACHEFILE}" fi GENERATED_HEADER="Generated by autorevision - do not hand-hack!" : "${EXTRA_NAME:="VCS_EXTRA"}" : "${WARNHIDE:="0"}" # Functions to extract data from different repo types. # For git repos # shellcheck disable=SC2039,SC2164,SC2155 gitRepo() { ${LOCAL} oldPath="$(pwd)" cd "$(git rev-parse --show-toplevel)" VCS_TYPE="git" VCS_BASENAME="$(basename "$(pwd)")" ${LOCAL} currentRev="$(git rev-parse HEAD)" VCS_UUID="$(git rev-list --max-parents=0 --date-order --reverse "${currentRev}" 2>/dev/null | sed -n 1p)" if [ -z "${VCS_UUID}" ]; then VCS_UUID="$(git rev-list --topo-order "${currentRev}" | tail -n 1)" fi # Is the working copy clean? test -z "$(git status --untracked-files=normal --porcelain)" VCS_WC_MODIFIED="${?}" # Enumeration of changesets VCS_NUM="$(git rev-list --count "${currentRev}" 2>/dev/null)" if [ -z "${VCS_NUM}" ]; then if [ ! "${WARNHIDE}" = "1" ]; then echo "warning: Counting the number of revisions may be slower due to an outdated git version less than 1.7.2.3. If something breaks, please update it." 1>&2 fi VCS_NUM="$(git rev-list HEAD | wc -l)" fi # This may be a git-svn remote. If so, report the Subversion revision. if [ -z "$(git config svn-remote.svn.url 2>/dev/null)" ]; then # The full revision hash VCS_FULL_HASH="$(git rev-parse "${currentRev}")" # The short hash VCS_SHORT_HASH="$(git rev-parse --short "${currentRev}")" else # The git-svn revision number VCS_FULL_HASH="$(git svn find-rev "${currentRev}")" VCS_SHORT_HASH="${VCS_FULL_HASH}" fi # Get the current revision's signing key. VCS_COMMIT_OPENPGP="$(git verify-commit --raw "${currentRev}" 2>&1 | grep "VALIDSIG" | cut -d ' ' -f 12)" # Current branch VCS_BRANCH="$(git rev-parse --symbolic-full-name --verify "$(git name-rev --name-only --no-undefined --exclude='refs/tags/*' "${currentRev}" 2>/dev/null)" 2>/dev/null | sed -e 's:refs/heads/::' | sed -e 's:refs/::')" # Cache the description ${LOCAL} DESCRIPTION="$(git describe --long --tags "${currentRev}" 2>/dev/null)" # Current or last tag ancestor (empty if no tags) VCS_TAG="$(echo "${DESCRIPTION}" | sed -e "s:-g${VCS_SHORT_HASH}\$::" -e 's:-[0-9]*$::')" if [ ! -z "${VCS_TAG}" ]; then # Determine if the tag is annotated. ${LOCAL} tagType="$(git for-each-ref --format='%(objecttype)' "$(git rev-parse --symbolic-full-name --verify "${VCS_TAG}")")" if [ ! "${tagType}" = "tag" ]; then # Let the user know if the current tag is not annotated. if [ ! "${WARNHIDE}" = "1" ]; then echo "note: The most recent tag is not annotated; if it is intended to be a release you may want to fix this." 1>&2 fi else # You cannot have a signed tag that is not annotated. VCS_TAG_OPENPGP="$(git verify-tag --raw "${VCS_TAG}" 2>&1 | grep "VALIDSIG" | cut -d ' ' -f 12)" fi fi # Distance to last tag or an alias of VCS_NUM if there is no tag if [ ! -z "${DESCRIPTION}" ]; then VCS_TICK="$(echo "${DESCRIPTION}" | sed -e "s:${VCS_TAG}-::" -e "s:-g${VCS_SHORT_HASH}::")" else VCS_TICK="${VCS_NUM}" fi # Date of the current commit VCS_DATE="$(TZ=UTC git show -s --date=iso-strict-local --pretty=format:%cd "${currentRev}" 2>/dev/null | sed -e 's|+00:00|Z|')" if [ -z "${VCS_DATE}" ]; then if [ ! "${WARNHIDE}" = "1" ]; then echo "warning: Action stamps require git version 2.7+." 1>&2 fi VCS_DATE="$(git log -1 --pretty=format:%ci "${currentRev}" | sed -e 's: :T:' -e 's: ::' -e 's|+00:00|Z|')" ${LOCAL} ASdis="1" fi # Action Stamp if [ -z "${ASdis}" ]; then VCS_ACTION_STAMP="${VCS_DATE}!$(git show -s --pretty=format:%cE "${currentRev}")" else VCS_ACTION_STAMP="" fi cd "${oldPath}" } # For hg repos # shellcheck disable=SC2039,SC2164 hgRepo() { ${LOCAL} oldPath="$(pwd)" cd "$(hg root)" VCS_TYPE="hg" VCS_BASENAME="$(basename "$(pwd)")" VCS_UUID="$(hg log -r "0" -l 1 --template '{node}\n')" # Is the working copy clean? test -z "$(hg status -duram)" VCS_WC_MODIFIED="${?}" # Enumeration of changesets VCS_NUM="$(hg id -n | tr -d '+')" # The full revision hash VCS_FULL_HASH="$(hg log -r "${VCS_NUM}" -l 1 --template '{node}\n')" # The short hash VCS_SHORT_HASH="$(hg id -i | tr -d '+')" # Current bookmark (bookmarks are roughly equivalent to git's branches) # or branch if no bookmark VCS_BRANCH="$(hg id -B | cut -d ' ' -f 1)" # Fall back to the branch if there are no bookmarks if [ -z "${VCS_BRANCH}" ]; then VCS_BRANCH="$(hg id -b)" fi # Current or last tag ancestor (excluding auto tags, empty if no tags) VCS_TAG="$(hg log -r "${VCS_NUM}" -l 1 --template '{latesttag}\n' 2>/dev/null | sed -e 's:qtip::' -e 's:tip::' -e 's:qbase::' -e 's:qparent::' -e "s:$(hg --config 'extensions.color=' --config 'extensions.mq=' --color never qtop 2>/dev/null)::" | cut -d ' ' -f 1)" # Distance to last tag or an alias of VCS_NUM if there is no tag if [ ! -z "${VCS_TAG}" ]; then VCS_TICK="$(hg log -r "${VCS_NUM}" -l 1 --template '{latesttagdistance}\n' 2>/dev/null)" else VCS_TICK="${VCS_NUM}" fi # Date of the current commit VCS_DATE="$(hg log -r "${VCS_NUM}" -l 1 --template '{date|isodatesec}\n' 2>/dev/null | sed -e 's: :T:' -e 's: ::' -e 's|+00:00|Z|')" # Action Stamp VCS_ACTION_STAMP="$(TZ=UTC hg log -r "${VCS_NUM}" -l 1 --template '{date|localdate|rfc3339date}\n' 2>/dev/null | sed -e 's|+00:00|Z|')!$(hg log -r "${VCS_NUM}" -l 1 --template '{author|email}\n' 2>/dev/null)" cd "${oldPath}" } # For bzr repos # shellcheck disable=SC2039,SC2164 bzrRepo() { ${LOCAL} oldPath="$(pwd)" cd "$(bzr root)" VCS_TYPE="bzr" VCS_BASENAME="$(basename "$(pwd)")" # Currently unimplemented because more investigation is needed. VCS_UUID="" # Is the working copy clean? bzr version-info --custom --template='{clean}\n' | grep -q '1' VCS_WC_MODIFIED="${?}" # Enumeration of changesets VCS_NUM="$(bzr revno)" # The full revision hash VCS_FULL_HASH="$(bzr version-info --custom --template='{revision_id}\n')" # The short hash VCS_SHORT_HASH="${VCS_NUM}" # Nick of the current branch VCS_BRANCH="$(bzr nick)" # Current or last tag ancestor (excluding auto tags, empty if no tags) VCS_TAG="$(bzr tags --sort=time | sed '/?$/d' | tail -n1 | cut -d ' ' -f1)" # Distance to last tag or an alias of VCS_NUM if there is no tag if [ ! -z "${VCS_TAG}" ]; then VCS_TICK="$(bzr log --line -r "tag:${VCS_TAG}.." | tail -n +2 | wc -l | sed -e 's:^ *::')" else VCS_TICK="${VCS_NUM}" fi # Date of the current commit VCS_DATE="$(bzr version-info --custom --template='{date}\n' | sed -e 's: :T:' -e 's: ::')" # Action Stamp # Currently unimplemented because more investigation is needed. VCS_ACTION_STAMP="" cd "${oldPath}" } # For svn repos # shellcheck disable=SC2039,SC2164,SC2155 svnRepo() { ${LOCAL} oldPath="$(pwd)" VCS_TYPE="svn" case "$(pwd)" in /*trunk*|/*branches*|/*tags*) ${LOCAL} fn="$(pwd)" while [ "$(basename "${fn}")" != 'trunk' ] && [ "$(basename "${fn}")" != 'branches' ] && [ "$(basename "${fn}")" != 'tags' ] && [ "$(basename "${fn}")" != '/' ]; do ${LOCAL} fn="$(dirname "${fn}")" done ${LOCAL} fn="$(dirname "${fn}")" if [ "${fn}" = '/' ]; then VCS_BASENAME="$(basename "$(pwd)")" else VCS_BASENAME="$(basename "${fn}")" fi ;; *) VCS_BASENAME="$(basename "$(pwd)")" ;; esac VCS_UUID="$(svn info --xml | sed -n -e 's:::' -e 's:::p')" # Cache svnversion output ${LOCAL} SVNVERSION="$(svnversion)" # Is the working copy clean? echo "${SVNVERSION}" | grep -q "M" case "${?}" in 0) VCS_WC_MODIFIED="1" ;; 1) if [ ! -z "${UNTRACKEDFILES}" ]; then # `svnversion` does not detect untracked files and `svn status` is really slow, so only run it if we really have to. if [ -z "$(svn status)" ]; then VCS_WC_MODIFIED="0" else VCS_WC_MODIFIED="1" fi else VCS_WC_MODIFIED="0" fi ;; esac # Enumeration of changesets VCS_NUM="$(echo "${SVNVERSION}" | cut -d : -f 1 | sed -e 's:M::' -e 's:S::' -e 's:P::')" # The full revision hash VCS_FULL_HASH="${SVNVERSION}" # The short hash VCS_SHORT_HASH="${VCS_NUM}" # Current branch case "$(pwd)" in /*trunk*|/*branches*|/*tags*) ${LOCAL} lastbase="" ${LOCAL} fn="$(pwd)" while : do base="$(basename "${fn}")" if [ "${base}" = 'trunk' ]; then VCS_BRANCH='trunk' break elif [ "${base}" = 'branches' ] || [ "${base}" = 'tags' ]; then VCS_BRANCH="${lastbase}" break elif [ "${base}" = '/' ]; then VCS_BRANCH="" break fi ${LOCAL} lastbase="${base}" ${LOCAL} fn="$(dirname "${fn}")" done ;; *) VCS_BRANCH="" ;; esac # Current or last tag ancestor (empty if no tags). But "current # tag" can't be extracted reliably because Subversion doesn't # have tags the way other VCSes do. VCS_TAG="" VCS_TICK="" # Date of the current commit VCS_DATE="$(svn info --xml | sed -n -e 's:::' -e 's:::p')" # Action Stamp VCS_ACTION_STAMP="${VCS_DATE}!$(svn log --xml -l 1 -r "${VCS_SHORT_HASH}" | sed -n -e 's:::' -e 's:::p')" cd "${oldPath}" } # Functions to output data in different formats. # For bash output # First in list because it is used by autorevision shOutput() { tee << EOF # ${GENERATED_HEADER} VCS_TYPE="${VCS_TYPE}" VCS_BASENAME="${VCS_BASENAME}" VCS_UUID="${VCS_UUID}" VCS_NUM="${VCS_NUM}" VCS_DATE="${VCS_DATE}" VCS_BRANCH="${VCS_BRANCH}" VCS_TAG="${VCS_TAG}" VCS_TAG_OPENPGP="${VCS_TAG_OPENPGP}" VCS_TICK="${VCS_TICK}" ${EXTRA_NAME}="${VCS_EXTRA}" VCS_ACTION_STAMP="${VCS_ACTION_STAMP}" VCS_FULL_HASH="${VCS_FULL_HASH}" VCS_COMMIT_OPENPGP="${VCS_COMMIT_OPENPGP}" VCS_SHORT_HASH="${VCS_SHORT_HASH}" VCS_WC_MODIFIED="${VCS_WC_MODIFIED}" # end EOF } # For source C output cOutput() { tee << EOF /* ${GENERATED_HEADER} */ const char *VCS_TYPE = "${VCS_TYPE}"; const char *VCS_BASENAME = "${VCS_BASENAME}"; const char *VCS_UUID = "${VCS_UUID}"; const int VCS_NUM = ${VCS_NUM}; const char *VCS_DATE = "${VCS_DATE}"; const char *VCS_BRANCH = "${VCS_BRANCH}"; const char *VCS_TAG = "${VCS_TAG}"; const char *VCS_TAG_OPENPGP = "${VCS_TAG_OPENPGP}"; const int VCS_TICK = ${VCS_TICK}; const char *${EXTRA_NAME} = "${VCS_EXTRA}"; const char *VCS_ACTION_STAMP = "${VCS_ACTION_STAMP}"; const char *VCS_FULL_HASH = "${VCS_FULL_HASH}"; const char *VCS_COMMIT_OPENPGP = "${VCS_COMMIT_OPENPGP}"; const char *VCS_SHORT_HASH = "${VCS_SHORT_HASH}"; const int VCS_WC_MODIFIED = ${VCS_WC_MODIFIED}; /* end */ EOF } # For Cmake output cmakeOutput() { tee << EOF # ${GENERATED_HEADER} set(VCS_TYPE ${VCS_TYPE}) set(VCS_BASENAME ${VCS_BASENAME}) set(VCS_UUID ${VCS_UUID}) set(VCS_NUM ${VCS_NUM}) set(VCS_DATE ${VCS_DATE}) set(VCS_BRANCH ${VCS_BRANCH}) set(VCS_TAG ${VCS_TAG}) set(VCS_TAG_OPENPGP ${VCS_TAG_OPENPGP}) set(VCS_TICK ${VCS_TICK}) set(${EXTRA_NAME} ${VCS_EXTRA}) set(VCS_ACTION_STAMP ${VCS_ACTION_STAMP}) set(VCS_FULL_HASH ${VCS_FULL_HASH}) set(VCS_COMMIT_OPENPGP ${VCS_COMMIT_OPENPGP}) set(VCS_SHORT_HASH ${VCS_SHORT_HASH}) set(VCS_WC_MODIFIED ${VCS_WC_MODIFIED}) # end EOF } # For header output hOutput() { tee << EOF /* ${GENERATED_HEADER} */ #ifndef AUTOREVISION_H #define AUTOREVISION_H #define VCS_TYPE "${VCS_TYPE}" #define VCS_BASENAME "${VCS_BASENAME}" #define VCS_UUID "${VCS_UUID}" #define VCS_NUM ${VCS_NUM} #define VCS_DATE "${VCS_DATE}" #define VCS_BRANCH "${VCS_BRANCH}" #define VCS_TAG "${VCS_TAG}" #define VCS_TAG_OPENPGP "${VCS_TAG_OPENPGP}" #define VCS_TICK ${VCS_TICK} #define ${EXTRA_NAME} "${VCS_EXTRA}" #define VCS_ACTION_STAMP "${VCS_ACTION_STAMP}" #define VCS_FULL_HASH "${VCS_FULL_HASH}" #define VCS_COMMIT_OPENPGP "${VCS_COMMIT_OPENPGP}" #define VCS_SHORT_HASH "${VCS_SHORT_HASH}" #define VCS_WC_MODIFIED ${VCS_WC_MODIFIED} #endif /* end */ EOF } # A header output for use with xcode to populate info.plist strings xcodeOutput() { tee << EOF /* ${GENERATED_HEADER} */ #ifndef AUTOREVISION_H #define AUTOREVISION_H #define VCS_TYPE ${VCS_TYPE} #define VCS_BASENAME ${VCS_BASENAME} #define VCS_UUID ${VCS_UUID} #define VCS_NUM ${VCS_NUM} #define VCS_DATE ${VCS_DATE} #define VCS_BRANCH ${VCS_BRANCH} #define VCS_TAG ${VCS_TAG} #define VCS_TAG_OPENPGP ${VCS_TAG_OPENPGP} #define VCS_TICK ${VCS_TICK} #define ${EXTRA_NAME} ${VCS_EXTRA} #define VCS_ACTION_STAMP ${VCS_ACTION_STAMP} #define VCS_FULL_HASH ${VCS_FULL_HASH} #define VCS_COMMIT_OPENPGP ${VCS_COMMIT_OPENPGP} #define VCS_SHORT_HASH ${VCS_SHORT_HASH} #define VCS_WC_MODIFIED ${VCS_WC_MODIFIED} #endif /* end */ EOF } # For Swift output swiftOutput() { case "${VCS_WC_MODIFIED}" in 0) VCS_WC_MODIFIED="false" ;; 1) VCS_WC_MODIFIED="true" ;; esac # For values that may not exist depending on the type of repo we # have read from, set them to `nil` when they are empty. if [ -z "${VCS_UUID}" ]; then VCS_UUID="nil" else VCS_UUID="\"${VCS_UUID}\"" fi if [ -z "${VCS_TAG}" ]; then VCS_TAG="nil" else VCS_TAG="\"${VCS_TAG}\"" fi if [ -z "${VCS_TAG_OPENPGP}" ]; then VCS_TAG_OPENPGP="nil" else VCS_TAG_OPENPGP="\"${VCS_TAG_OPENPGP}\"" fi : "${VCS_TICK:="nil"}" if [ -z "${VCS_EXTRA}" ]; then VCS_EXTRA="nil" else VCS_EXTRA="\"${VCS_EXTRA}\"" fi if [ -z "${VCS_ACTION_STAMP}" ]; then VCS_ACTION_STAMP="nil" else VCS_ACTION_STAMP="\"${VCS_ACTION_STAMP}\"" fi if [ -z "${VCS_COMMIT_OPENPGP}" ]; then VCS_COMMIT_OPENPGP="nil" else VCS_COMMIT_OPENPGP="\"${VCS_COMMIT_OPENPGP}\"" fi tee << EOF /* ${GENERATED_HEADER} */ let VCS_TYPE = "${VCS_TYPE}" let VCS_BASENAME = "${VCS_BASENAME}" let VCS_UUID: String? = ${VCS_UUID} let VCS_NUM: Int = ${VCS_NUM} let VCS_DATE = "${VCS_DATE}" let VCS_BRANCH: String = "${VCS_BRANCH}" let VCS_TAG: String? = ${VCS_TAG} let VCS_TAG_OPENPGP: String? = ${VCS_TAG_OPENPGP} let VCS_TICK: Int? = ${VCS_TICK} let ${EXTRA_NAME}: String? = ${VCS_EXTRA} let VCS_ACTION_STAMP: String? = ${VCS_ACTION_STAMP} let VCS_FULL_HASH: String = "${VCS_FULL_HASH}" let VCS_COMMIT_OPENPGP: String? = ${VCS_COMMIT_OPENPGP} let VCS_SHORT_HASH: String = "${VCS_SHORT_HASH}" let VCS_WC_MODIFIED: Bool = ${VCS_WC_MODIFIED} /* end */ EOF } # For Python output pyOutput() { case "${VCS_WC_MODIFIED}" in 0) VCS_WC_MODIFIED="False" ;; 1) VCS_WC_MODIFIED="True" ;; esac tee << EOF # ${GENERATED_HEADER} VCS_TYPE = "${VCS_TYPE}" VCS_BASENAME = "${VCS_BASENAME}" VCS_UUID = "${VCS_UUID}" VCS_NUM = ${VCS_NUM} VCS_DATE = "${VCS_DATE}" VCS_BRANCH = "${VCS_BRANCH}" VCS_TAG = "${VCS_TAG}" VCS_TAG_OPENPGP = "${VCS_TAG_OPENPGP}" VCS_TICK = ${VCS_TICK} ${EXTRA_NAME} = "${VCS_EXTRA}" VCS_ACTION_STAMP = "${VCS_ACTION_STAMP}" VCS_FULL_HASH = "${VCS_FULL_HASH}" VCS_COMMIT_OPENPGP = "${VCS_COMMIT_OPENPGP}" VCS_SHORT_HASH = "${VCS_SHORT_HASH}" VCS_WC_MODIFIED = ${VCS_WC_MODIFIED} # end EOF } # For Perl output plOutput() { tee << EOF # ${GENERATED_HEADER} \$VCS_TYPE = '${VCS_TYPE}'; \$VCS_BASENAME = '${VCS_BASENAME}'; \$VCS_UUID = '${VCS_UUID}'; \$VCS_NUM = ${VCS_NUM}; \$VCS_DATE = '${VCS_DATE}'; \$VCS_BRANCH = '${VCS_BRANCH}'; \$VCS_TAG = '${VCS_TAG}'; \$VCS_TAG_OPENPGP = '${VCS_TAG_OPENPGP}'; \$VCS_TICK = ${VCS_TICK}; \$${EXTRA_NAME} = '${VCS_EXTRA}'; \$VCS_ACTION_STAMP = '${VCS_ACTION_STAMP}'; \$VCS_FULL_HASH = '${VCS_FULL_HASH}'; \$VCS_COMMIT_OPENPGP = '${VCS_COMMIT_OPENPGP}'; \$VCS_SHORT_HASH = '${VCS_SHORT_HASH}'; \$VCS_WC_MODIFIED = ${VCS_WC_MODIFIED}; # end 1; EOF } # For lua output luaOutput() { case "${VCS_WC_MODIFIED}" in 0) VCS_WC_MODIFIED="false" ;; 1) VCS_WC_MODIFIED="true" ;; esac tee << EOF -- ${GENERATED_HEADER} VCS_TYPE = "${VCS_TYPE}" VCS_BASENAME = "${VCS_BASENAME}" VCS_UUID = "${VCS_UUID}" VCS_NUM = ${VCS_NUM} VCS_DATE = "${VCS_DATE}" VCS_BRANCH = "${VCS_BRANCH}" VCS_TAG = "${VCS_TAG}" VCS_TAG_OPENPGP = "${VCS_TAG_OPENPGP}" VCS_TICK = ${VCS_TICK} ${EXTRA_NAME} = "${VCS_EXTRA}" VCS_ACTION_STAMP = "${VCS_ACTION_STAMP}" VCS_FULL_HASH = "${VCS_FULL_HASH}" VCS_COMMIT_OPENPGP = "${VCS_COMMIT_OPENPGP}" VCS_SHORT_HASH = "${VCS_SHORT_HASH}" VCS_WC_MODIFIED = ${VCS_WC_MODIFIED} -- end EOF } # For php output phpOutput() { case "${VCS_WC_MODIFIED}" in 0) VCS_WC_MODIFIED="false" ;; 1) VCS_WC_MODIFIED="true" ;; esac tee << EOF "${VCS_TYPE}", "VCS_BASENAME" => "${VCS_BASENAME}", "VCS_UUID" => "${VCS_UUID}", "VCS_NUM" => ${VCS_NUM}, "VCS_DATE" => "${VCS_DATE}", "VCS_BRANCH" => "${VCS_BRANCH}", "VCS_TAG" => "${VCS_TAG}", "VCS_TAG_OPENPGP" => "${VCS_TAG_OPENPGP}", "VCS_TICK" => ${VCS_TICK}, "${EXTRA_NAME}" => "${VCS_EXTRA}", "VCS_ACTION_STAMP" => "${VCS_ACTION_STAMP}", "VCS_FULL_HASH" => "${VCS_FULL_HASH}", "VCS_COMMIT_OPENPGP" => "${VCS_COMMIT_OPENPGP}", "VCS_SHORT_HASH" => "${VCS_SHORT_HASH}", "VCS_WC_MODIFIED" => ${VCS_WC_MODIFIED} ); # end ?> EOF } # For ini output iniOutput() { case "${VCS_WC_MODIFIED}" in 0) VCS_WC_MODIFIED="false" ;; 1) VCS_WC_MODIFIED="true" ;; esac tee << EOF ; ${GENERATED_HEADER} [VCS] VCS_TYPE = "${VCS_TYPE}" VCS_BASENAME = "${VCS_BASENAME}" VCS_UUID = "${VCS_UUID}" VCS_NUM = ${VCS_NUM} VCS_DATE = "${VCS_DATE}" VCS_BRANCH = "${VCS_BRANCH}" VCS_TAG = "${VCS_TAG}" VCS_TAG_OPENPGP = "${VCS_TAG_OPENPGP}" VCS_TICK = ${VCS_TICK} ${EXTRA_NAME} = "${VCS_EXTRA}" VCS_ACTION_STAMP = "${VCS_ACTION_STAMP}" VCS_FULL_HASH = "${VCS_FULL_HASH}" VCS_COMMIT_OPENPGP = "${VCS_COMMIT_OPENPGP}" VCS_SHORT_HASH = "${VCS_SHORT_HASH}" VCS_WC_MODIFIED = ${VCS_WC_MODIFIED} ; end EOF } # For javascript output jsOutput() { case "${VCS_WC_MODIFIED}" in 1) VCS_WC_MODIFIED="true" ;; 0) VCS_WC_MODIFIED="false" ;; esac tee << EOF /** ${GENERATED_HEADER} */ var autorevision = { VCS_TYPE: "${VCS_TYPE}", VCS_BASENAME: "${VCS_BASENAME}", VCS_UUID: "${VCS_UUID}", VCS_NUM: ${VCS_NUM}, VCS_DATE: "${VCS_DATE}", VCS_BRANCH: "${VCS_BRANCH}", VCS_TAG: "${VCS_TAG}", VCS_TAG_OPENPGP: "${VCS_TAG_OPENPGP}", VCS_TICK: ${VCS_TICK}, ${EXTRA_NAME}: "${VCS_EXTRA}", VCS_ACTION_STAMP: "${VCS_ACTION_STAMP}", VCS_FULL_HASH: "${VCS_FULL_HASH}", VCS_COMMIT_OPENPGP: "${VCS_COMMIT_OPENPGP}", VCS_SHORT_HASH: "${VCS_SHORT_HASH}", VCS_WC_MODIFIED: ${VCS_WC_MODIFIED} }; /** Node.js compatibility */ if (typeof module !== 'undefined') { module.exports = autorevision; } /** end */ EOF } # For JSON output jsonOutput() { case "${VCS_WC_MODIFIED}" in 1) VCS_WC_MODIFIED="true" ;; 0) VCS_WC_MODIFIED="false" ;; esac tee << EOF { "_comment": "${GENERATED_HEADER}", "VCS_TYPE": "${VCS_TYPE}", "VCS_BASENAME": "${VCS_BASENAME}", "VCS_UUID": "${VCS_UUID}", "VCS_NUM": ${VCS_NUM}, "VCS_DATE": "${VCS_DATE}", "VCS_BRANCH":"${VCS_BRANCH}", "VCS_TAG": "${VCS_TAG}", "VCS_TAG_OPENPGP": "${VCS_TAG_OPENPGP}", "VCS_TICK": ${VCS_TICK}, "${EXTRA_NAME}": "${VCS_EXTRA}", "VCS_ACTION_STAMP": "${VCS_ACTION_STAMP}", "VCS_FULL_HASH": "${VCS_FULL_HASH}", "VCS_COMMIT_OPENPGP": "${VCS_COMMIT_OPENPGP}", "VCS_SHORT_HASH": "${VCS_SHORT_HASH}", "VCS_WC_MODIFIED": ${VCS_WC_MODIFIED} } EOF } # For Java output javaOutput() { case "${VCS_WC_MODIFIED}" in 1) VCS_WC_MODIFIED="true" ;; 0) VCS_WC_MODIFIED="false" ;; esac tee << EOF /* ${GENERATED_HEADER} */ public class autorevision { public static final String VCS_TYPE = "${VCS_TYPE}"; public static final String VCS_BASENAME = "${VCS_BASENAME}"; public static final String VCS_UUID = "${VCS_UUID}"; public static final long VCS_NUM = ${VCS_NUM}; public static final String VCS_DATE = "${VCS_DATE}"; public static final String VCS_BRANCH = "${VCS_BRANCH}"; public static final String VCS_TAG = "${VCS_TAG}"; public static final String VCS_TAG_OPENPGP = "${VCS_TAG_OPENPGP}"; public static final long VCS_TICK = ${VCS_TICK}; public static final String ${EXTRA_NAME} = "${VCS_EXTRA}"; public static final String VCS_ACTION_STAMP = "${VCS_ACTION_STAMP}"; public static final String VCS_FULL_HASH = "${VCS_FULL_HASH}"; public static final String VCS_COMMIT_OPENPGP = "${VCS_COMMIT_OPENPGP}"; public static final String VCS_SHORT_HASH = "${VCS_SHORT_HASH}"; public static final boolean VCS_WC_MODIFIED = ${VCS_WC_MODIFIED}; } EOF } csharpOutput() { case "${VCS_WC_MODIFIED}" in 1) VCS_WC_MODIFIED="true" ;; 0) VCS_WC_MODIFIED="false" ;; esac if [ "${EXTRA_NAME}" = "VCS_EXTRA" ]; then EXTRA_NAME="VcsExtra" fi tee << EOF /* ${GENERATED_HEADER} */ namespace AutoRevision { public class VersionInfo { public static string VcsType = "${VCS_TYPE}"; public static string VcsBasename = "${VCS_BASENAME}"; public static string VcsUuid = "${VCS_UUID}"; public static string VcsNum = "${VCS_NUM}"; public static string VcsDate = "${VCS_DATE}"; public static string VcsBranch = "${VCS_DATE}"; public static string VcsTag = "${VCS_TAG}"; public static string VcsTagOpenpgp = "${VCS_TAG_OPENPGP}"; public static string VcsTick = "${VCS_TICK}"; public static string ${EXTRA_NAME} = "${VCS_EXTRA}"; public static string VcsActionStamp = "${VCS_ACTION_STAMP}"; public static string VcsFullHash = "${VCS_FULL_HASH}"; public static string VcsCommitOpenpgp = "${VCS_COMMIT_OPENPGP}"; public static string VcsShortHash = "${VCS_SHORT_HASH}"; public static string VcsWcModified = "${VCS_WC_MODIFIED}"; } } EOF } # For Java properties output javapropOutput() { case "${VCS_WC_MODIFIED}" in 1) VCS_WC_MODIFIED="true" ;; 0) VCS_WC_MODIFIED="false" ;; esac tee << EOF # ${GENERATED_HEADER} VCS_TYPE=${VCS_TYPE} VCS_BASENAME=${VCS_BASENAME} VCS_UUID=${VCS_UUID} VCS_NUM=${VCS_NUM} VCS_DATE=${VCS_DATE} VCS_BRANCH=${VCS_BRANCH} VCS_TAG=${VCS_TAG} VCS_TAG_OPENPGP=${VCS_TAG_OPENPGP} VCS_TICK=${VCS_TICK} ${EXTRA_NAME}=${VCS_EXTRA} VCS_ACTION_STAMP=${VCS_ACTION_STAMP} VCS_FULL_HASH=${VCS_FULL_HASH} VCS_COMMIT_OPENPGP=${VCS_COMMIT_OPENPGP} VCS_SHORT_HASH=${VCS_SHORT_HASH} VCS_WC_MODIFIED=${VCS_WC_MODIFIED} EOF } # For m4 output m4Output() { tee << EOF dnl ${GENERATED_HEADER} define(\`VCS_TYPE', \`${VCS_TYPE}')dnl define(\`VCS_BASENAME', \`${VCS_BASENAME}')dnl define(\`VCS_UUID', \`${VCS_UUID}')dnl define(\`VCS_NUM', \`${VCS_NUM}')dnl define(\`VCS_DATE', \`${VCS_DATE}')dnl define(\`VCS_BRANCH', \`${VCS_BRANCH}')dnl define(\`VCS_TAG', \`${VCS_TAG}')dnl define(\`VCS_TAG_OPENPGP', \`${VCS_TAG_OPENPGP}')dnl define(\`VCS_TICK', \`${VCS_TICK}')dnl define(\`${EXTRA_NAME}', \`${VCS_EXTRA}')dnl define(\`VCS_ACTIONSTAMP', \`${VCS_ACTION_STAMP}')dnl define(\`VCS_FULLHASH', \`${VCS_FULL_HASH}')dnl define(\`VCS_COMMIT_OPENPGP', \`${VCS_COMMIT_OPENPGP}')dnl define(\`VCS_SHORTHASH', \`${VCS_SHORT_HASH}')dnl define(\`VCS_WC_MODIFIED', \`${VCS_WC_MODIFIED}')dnl EOF } # For (La)TeX output # shellcheck disable=SC1117 texOutput() { case "${VCS_WC_MODIFIED}" in 0) VCS_WC_MODIFIED="false" ;; 1) VCS_WC_MODIFIED="true" ;; esac if [ "${EXTRA_NAME}" = "VCS_EXTRA" ]; then EXTRA_NAME="vcsExtra" fi tee << EOF % ${GENERATED_HEADER} \def \vcsType {${VCS_TYPE}} \def \vcsBasename {${VCS_BASENAME}} \def \vcsUUID {${VCS_UUID}} \def \vcsNum {${VCS_NUM}} \def \vcsDate {${VCS_DATE}} \def \vcsBranch {${VCS_BRANCH}} \def \vcsTag {${VCS_TAG}} \def \vcsTagOpenpgp {${VCS_TAG_OPENPGP}} \def \vcsTick {${VCS_TICK}} \def \\${EXTRA_NAME} {${VCS_EXTRA}} \def \vcsACTIONSTAMP {${VCS_ACTION_STAMP}} \def \vcsFullHash {${VCS_FULL_HASH}} \def \vcsCommitOpenpgp {${VCS_COMMIT_OPENPGP}} \def \vcsShortHash {${VCS_SHORT_HASH}} \def \vcsWCModified {${VCS_WC_MODIFIED}} \endinput EOF } # For scheme output schemeOutput() { case "${VCS_WC_MODIFIED}" in 0) VCS_WC_MODIFIED="#f" ;; 1) VCS_WC_MODIFIED="#t" ;; esac tee << EOF ;; ${GENERATED_HEADER} (define VCS_TYPE "${VCS_TYPE}") (define VCS_BASENAME "${VCS_BASENAME}") (define VCS_UUID "${VCS_UUID}") (define VCS_NUM ${VCS_NUM}) (define VCS_DATE "${VCS_DATE}") (define VCS_BRANCH "${VCS_BRANCH}") (define VCS_TAG "${VCS_TAG}") (define VCS_TAG_OPENPGP "${VCS_TAG_OPENPGP}") (define VCS_TICK ${VCS_TICK}) (define ${EXTRA_NAME} "${VCS_EXTRA}") (define VCS_ACTION_STAMP "${VCS_ACTION_STAMP}") (define VCS_FULL_HASH "${VCS_FULL_HASH}") (define VCS_COMMIT_OPENPGP "${VCS_COMMIT_OPENPGP}") (define VCS_SHORT_HASH "${VCS_SHORT_HASH}") (define VCS_WC_MODIFIED ${VCS_WC_MODIFIED}) ;; end EOF } # For clojure output clojureOutput() { case "${VCS_WC_MODIFIED}" in 0) VCS_WC_MODIFIED="false" ;; 1) VCS_WC_MODIFIED="true" ;; esac tee << EOF ;; ${GENERATED_HEADER} (def VCS_TYPE "${VCS_TYPE}") (def VCS_BASENAME "${VCS_BASENAME}") (def VCS_UUID "${VCS_UUID}") (def VCS_NUM ${VCS_NUM}) (def VCS_DATE "${VCS_DATE}") (def VCS_BRANCH "${VCS_BRANCH}") (def VCS_TAG "${VCS_TAG}") (def VCS_TAG_OPENPGP "${VCS_TAG_OPENPGP}") (def VCS_TICK ${VCS_TICK}) (def ${EXTRA_NAME} "${VCS_EXTRA}") (def VCS_ACTION_STAMP "${VCS_ACTION_STAMP}") (def VCS_FULL_HASH "${VCS_FULL_HASH}") (def VCS_COMMIT_OPENPGP "${VCS_COMMIT_OPENPGP}") (def VCS_SHORT_HASH "${VCS_SHORT_HASH}") (def VCS_WC_MODIFIED ${VCS_WC_MODIFIED}) ;; end EOF } # For rpm spec file output rpmOutput() { tee << EOF # ${GENERATED_HEADER} $([ "${VCS_TYPE}" ] && echo "%define vcs_type ${VCS_TYPE}") $([ "${VCS_BASENAME}" ] && echo "%define vcs_basename ${VCS_BASENAME}") $([ "${VCS_UUID}" ] && echo "%define vcs_uuid ${VCS_UUID}") $([ "${VCS_NUM}" ] && echo "%define vcs_num ${VCS_NUM}") $([ "${VCS_DATE}" ] && echo "%define vcs_date ${VCS_DATE}") $([ "${VCS_BRANCH}" ] && echo "%define vcs_branch ${VCS_BRANCH}") $([ "${VCS_TAG_OPENPGP}" ] && echo "%define vcs_tag_openpgp ${VCS_TAG_OPENPGP}") $([ "${VCS_TAG}" ] && echo "%define vcs_tag ${VCS_TAG}") $([ "${VCS_TICK}" ] && echo "%define vcs_tick ${VCS_TICK}") $([ "${VCS_EXTRA}" ] && echo "%define ${EXTRA_NAME} ${VCS_EXTRA}") $([ "${VCS_ACTION_STAMP}" ] && echo "%define vcs_action_stamp ${VCS_ACTION_STAMP}") $([ "${VCS_FULL_HASH}" ] && echo "%define vcs_full_hash ${VCS_FULL_HASH}") $([ "${VCS_COMMIT_OPENPGP}" ] && echo "%define vcs_commit_openpgp ${VCS_COMMIT_OPENPGP}") $([ "${VCS_SHORT_HASH}" ] && echo "%define vcs_short_hash ${VCS_SHORT_HASH}") $([ "${VCS_WC_MODIFIED}" ] && echo "%define vcs_wc_modified ${VCS_WC_MODIFIED}") # end EOF } # For C++ Header output # shellcheck disable=SC2155,SC2039 hppOutput() { ${LOCAL} NAMESPACE="$(echo "${VCS_BASENAME}" | sed -e 's:_::g' | tr '[:lower:]' '[:upper:]')" tee << EOF /* ${GENERATED_HEADER} */ #ifndef ${NAMESPACE}_AUTOREVISION_H #define ${NAMESPACE}_AUTOREVISION_H #include namespace $(echo "${NAMESPACE}" | tr '[:upper:]' '[:lower:]') { const std::string VCS_TYPE = "${VCS_TYPE}"; const std::string VCS_BASENAME = "${VCS_BASENAME}"; const std::string VCS_UUID = "${VCS_UUID}"; const int VCS_NUM = ${VCS_NUM}; const std::string VCS_DATE = "${VCS_DATE}"; const std::string VCS_BRANCH = "${VCS_BRANCH}"; const std::string VCS_TAG = "${VCS_TAG}"; const std::string VCS_TAG_OPENPGP = "${VCS_TAG_OPENPGP}"; const int VCS_TICK = ${VCS_TICK}; const std::string ${EXTRA_NAME} = "${VCS_EXTRA}"; const std::string VCS_ACTION_STAMP = "${VCS_ACTION_STAMP}"; const std::string VCS_FULL_HASH = "${VCS_FULL_HASH}"; const std::string VCS_COMMIT_OPENPGP = "${VCS_COMMIT_OPENPGP}"; const std::string VCS_SHORT_HASH = "${VCS_SHORT_HASH}"; const int VCS_WC_MODIFIED = ${VCS_WC_MODIFIED}; } #endif /* end */ EOF } # For Matlab output matlabOutput() { case "${VCS_WC_MODIFIED}" in 0) VCS_WC_MODIFIED="FALSE" ;; 1) VCS_WC_MODIFIED="TRUE" ;; esac tee << EOF % ${GENERATED_HEADER} VCS_TYPE = '${VCS_TYPE}'; VCS_BASENAME = '${VCS_BASENAME}'; VCS_UUID = '${VCS_UUID}'; VCS_NUM = ${VCS_NUM}; VCS_DATE = '${VCS_DATE}'; VCS_BRANCH = '${VCS_BRANCH}'; VCS_TAG = '${VCS_TAG}'; VCS_TAG_OPENPGP = '${VCS_TAG_OPENPGP}'; VCS_TICK = ${VCS_TICK}; ${EXTRA_NAME} = '${VCS_EXTRA}'; VCS_ACTION_STAMP = '${VCS_ACTION_STAMP}'; VCS_FULL_HASH = '${VCS_FULL_HASH}'; VCS_COMMIT_OPENPGP = '${VCS_COMMIT_OPENPGP}'; VCS_SHORT_HASH = '${VCS_SHORT_HASH}'; VCS_WC_MODIFIED = ${VCS_WC_MODIFIED}; % end EOF } # For Octave output octaveOutput() { tee << EOF % ${GENERATED_HEADER} VCS_TYPE = '${VCS_TYPE}'; VCS_BASENAME = '${VCS_BASENAME}'; VCS_UUID = '${VCS_UUID}'; VCS_NUM = ${VCS_NUM}; VCS_DATE = '${VCS_DATE}'; VCS_BRANCH = '${VCS_BRANCH}'; VCS_TAG = '${VCS_TAG}'; VCS_TAG_OPENPGP = '${VCS_TAG_OPENPGP}'; VCS_TICK = ${VCS_TICK}; ${EXTRA_NAME} = '${VCS_EXTRA}'; VCS_ACTION_STAMP = '${VCS_ACTION_STAMP}'; VCS_FULL_HASH = '${VCS_FULL_HASH}'; VCS_COMMIT_OPENPGP = '${VCS_COMMIT_OPENPGP}'; VCS_SHORT_HASH = '${VCS_SHORT_HASH}'; VCS_WC_MODIFIED = ${VCS_WC_MODIFIED}; % end EOF } sedOutput() { tee << EOF # ${GENERATED_HEADER} s|@VCS_TYPE@|${VCS_TYPE}|g s|@VCS_BASENAME@|${VCS_BASENAME}|g s|@VCS_UUID@|${VCS_UUID}|g s|@VCS_NUM@|${VCS_NUM}|g s|@VCS_DATE@|${VCS_DATE}|g s|@VCS_BRANCH@|${VCS_BRANCH}|g s|@VCS_TAG@|${VCS_TAG}|g s|@VCS_TAG_OPENPGP@|${VCS_TAG_OPENPGP}|g s|@VCS_TICK@|${VCS_TICK}|g s|@${EXTRA_NAME}@|${VCS_EXTRA}|g s|@VCS_ACTION_STAMP@|${VCS_ACTION_STAMP}|g s|@VCS_FULL_HASH@|${VCS_FULL_HASH}|g s|@VCS_COMMIT_OPENPGP@|${VCS_COMMIT_OPENPGP}|g s|@VCS_SHORT_HASH@|${VCS_SHORT_HASH}|g s|@VCS_WC_MODIFIED@|${VCS_WC_MODIFIED}|g # end EOF } # Helper functions # Count path segments # shellcheck disable=SC2039 pathSegment() { ${LOCAL} pathz="${1}" ${LOCAL} depth="0" ${LOCAL} last_pathz="" if [ ! -z "${pathz}" ]; then # Continue until we are at / or there are no path separators left. while [ ! "${pathz}" = "/" ] && [ ! "${pathz}" = "${last_pathz}" ]; do last_pathz="${pathz}" pathz="$(dirname "${pathz}")" depth="$((depth+1))" done fi echo "${depth}" } # Largest of four numbers # shellcheck disable=SC2039 multiCompare() { ${LOCAL} larger="${1}" ${LOCAL} numA="${2}" ${LOCAL} numB="${3}" ${LOCAL} numC="${4}" [ "${numA}" -gt "${larger}" ] && larger="${numA}" [ "${numB}" -gt "${larger}" ] && larger="${numB}" [ "${numC}" -gt "${larger}" ] && larger="${numC}" echo "${larger}" } # Test for repositories # shellcheck disable=SC2155,SC2039 repoTest() { REPONUM="0" if command -v git > /dev/null 2>&1; then ${LOCAL} gitPath="$(git rev-parse --show-toplevel 2>/dev/null)" ${LOCAL} gitDepth="$(pathSegment "${gitPath}")" if [ ! -z "${gitPath}" ]; then REPONUM="$((REPONUM+1))" fi else ${LOCAL} gitDepth="0" fi if command -v hg > /dev/null 2>&1; then ${LOCAL} hgPath="$(hg root 2>/dev/null)" ${LOCAL} hgDepth="$(pathSegment "${hgPath}")" if [ ! -z "${hgPath}" ]; then REPONUM="$((REPONUM+1))" fi else ${LOCAL} hgDepth="0" fi if command -v bzr > /dev/null 2>&1; then ${LOCAL} bzrPath="$(bzr root 2>/dev/null)" ${LOCAL} bzrDepth="$(pathSegment "${bzrPath}")" if [ ! -z "${bzrPath}" ]; then REPONUM="$((REPONUM+1))" fi else ${LOCAL} bzrDepth="0" fi if command -v svn > /dev/null 2>&1; then ${LOCAL} stringz="" ${LOCAL} stringx="" ${LOCAL} svnPath="$(svn info --xml 2>/dev/null | sed -n -e "s:${stringz}::" -e "s:${stringx}::p")" # An old enough svn will not be able give us a path; default # to 1 for that case. if [ ! -z "${svnPath}" ]; then ${LOCAL} svnDepth="$(pathSegment "${svnPath}")" REPONUM="$((REPONUM+1))" elif [ -z "${svnPath}" ] && [ -d ".svn" ]; then ${LOCAL} svnDepth="1" REPONUM="$((REPONUM+1))" else ${LOCAL} svnDepth="0" fi else ${LOCAL} svnDepth="0" fi # Do not do more work then we have to. if [ "${REPONUM}" = "0" ]; then return 0 fi # Figure out which repo is the deepest and use it. ${LOCAL} wonRepo="$(multiCompare "${gitDepth}" "${hgDepth}" "${bzrDepth}" "${svnDepth}")" if [ "${wonRepo}" = "${gitDepth}" ]; then gitRepo elif [ "${wonRepo}" = "${hgDepth}" ]; then hgRepo elif [ "${wonRepo}" = "${bzrDepth}" ]; then bzrRepo elif [ "${wonRepo}" = "${svnDepth}" ]; then svnRepo fi } # Detect which repos we are in and gather data. # shellcheck source=/dev/null if [ -f "${CACHEFILE}" ] && [ "${CACHEFORCE}" = "1" ]; then # When requested only read from the cache to populate our symbols. . "${CACHEFILE}" else # If a value is not set through the environment set VCS_EXTRA to nothing. : "${VCS_EXTRA:=""}" if [ ! -z "${CHANGE_TO_DIR}" ]; then originalPath="$(pwd)" # shellcheck disable=SC2164 cd "${CHANGE_TO_DIR}" fi repoTest if [ ! -z "${originalPath}" ]; then # shellcheck disable=SC2164 cd "${originalPath}" fi if [ -f "${CACHEFILE}" ] && [ "${REPONUM}" = "0" ]; then # We are not in a repo; try to use a previously generated cache to populate our symbols. . "${CACHEFILE}" # Do not overwrite the cache if we know we are not going to write anything new. CACHEFORCE="1" elif [ "${REPONUM}" = "0" ]; then echo "error: No repo or cache detected." 1>&2 exit 1 fi fi # If requested, make a cache file. if [ ! -z "${CACHEFILE}" ] && [ ! "${CACHEFORCE}" = "1" ]; then EXTRA_OUTPUT="${EXTRA_NAME}" EXTRA_NAME="VCS_EXTRA" shOutput > "${CACHEFILE}.tmp" # Check to see if there have been any actual changes. if [ ! -f "${CACHEFILE}" ]; then mv -f "${CACHEFILE}.tmp" "${CACHEFILE}" elif cmp -s "${CACHEFILE}.tmp" "${CACHEFILE}"; then rm -f "${CACHEFILE}.tmp" else mv -f "${CACHEFILE}.tmp" "${CACHEFILE}" fi EXTRA_NAME="${EXTRA_OUTPUT}" fi # -s output is handled here. if [ ! -z "${VAROUT}" ]; then case "${VAROUT}" in VCS_TYPE) echo "${VCS_TYPE}" ;; VCS_BASENAME) echo "${VCS_BASENAME}" ;; VCS_NUM) echo "${VCS_NUM}" ;; VCS_DATE) echo "${VCS_DATE}" ;; VCS_BRANCH) echo "${VCS_BRANCH}" ;; VCS_TAG) echo "${VCS_TAG}" ;; VCS_TICK) echo "${VCS_TICK}" ;; VCS_FULL_HASH) echo "${VCS_FULL_HASH}" ;; VCS_SHORT_HASH) echo "${VCS_SHORT_HASH}" ;; VCS_WC_MODIFIED) echo "${VCS_WC_MODIFIED}" ;; VCS_ACTION_STAMP) echo "${VCS_ACTION_STAMP}" ;; *) echo "error: ${VAROUT} is not a valid output symbol." 1>&2 exit 1 ;; esac fi # Detect requested output type and use it. if [ ! -z "${AFILETYPE}" ]; then case "${AFILETYPE}" in c) cOutput ;; h) hOutput ;; xcode) xcodeOutput ;; swift) swiftOutput ;; sed) sedOutput ;; sh) shOutput ;; py|python) pyOutput ;; pl|perl) plOutput ;; lua) luaOutput ;; php) phpOutput ;; ini) iniOutput ;; js) jsOutput ;; json) jsonOutput ;; java) javaOutput ;; javaprop) javapropOutput ;; csharp) csharpOutput ;; tex) texOutput ;; m4) m4Output ;; scheme) schemeOutput ;; clojure) clojureOutput ;; rpm) rpmOutput ;; hpp) hppOutput ;; matlab) matlabOutput ;; octave) octaveOutput ;; cmake) cmakeOutput ;; *) echo "error: ${AFILETYPE} is not a valid output type." 1>&2 exit 1 ;; esac fi autorevision-1.22/contribs/0000755000076500000240000000000013163763703014674 5ustar dak180staffautorevision-1.22/contribs/autorevision.mk0000644000076500000240000000162712713114612017747 0ustar dak180staff# Generic makefile showing how to use autorevision. # # Get the version number for use in the makefile and generate / update # the cache as needed. VERS := $(shell autorevision -s VCS_TAG -o ./autorevision.cache) # This gives you a $(VERS) variable that you can use later in the # makefile (say, in your tarball name); it also means that the # expensive operations that autorevision runs only have to be done # once. SOURCES = \ autorevision.c \ autorevision.json EXTRA_DIST = \ autorevision.cache # Make sure that the cache file ends up in your tarball or # autorevision will break. all : json cpp # Generate json output json: autorevision.json autorevision.json: autorevision.cache autorevision -f -t json -o ./autorevision.cache > autorevision.json # Generate C/C++ source output cpp: autorevision.c autorevision.c: autorevision.cache autorevision -f -t c -o ./autorevision.cache > autorevision.c autorevision-1.22/contribs/autorevision_declr.h0000644000076500000240000000111613163763703020744 0ustar dak180staff/* Use this header with source C backend */ #ifndef AUTOREVISION_DECLR_H #define AUTOREVISION_DECLR_H extern const char *VCS_TYPE; extern const char *VCS_BASENAME; extern const char *VCS_UUID; extern const int VCS_NUM; extern const char *VCS_DATE; extern const char *VCS_BRANCH; extern const char *VCS_TAG; extern const char *VCS_TAG_OPENPGP; extern const int VCS_TICK; extern const char *VCS_EXTRA; extern const char *VCS_ACTION_STAMP; extern const char *VCS_FULL_HASH; extern const char *VCS_COMMIT_OPENPGP; extern const char *VCS_SHORT_HASH; extern const int VCS_WC_MODIFIED; #endif autorevision-1.22/contribs/README.md0000644000076500000240000000030212071437746016150 0ustar dak180staff# Autorevision Driving Script Examples # Some real life examples of how you can use `autorevision`. If you have used `autorevision` to do something tricky please send in your driving scripts. autorevision-1.22/contribs/wscript0000644000076500000240000000323512663204322016304 0ustar dak180staff#!/usr/bin/env python # encoding: utf-8 APPNAME = 'projectname' VERSION = '1.0' # This will be overwritten later. def configure(bld): # This makes sure that autorevision exists before we call it. bld.find_program('autorevision', var='AUTOREVISION') def options(bld): pass def arv(bld): # The cache file build is in its own function so it can be easily # included everywhere it needs to be. from waflib import ConfigSet # Get the path to autorevision found in configuration. try: env = ConfigSet.ConfigSet('build/c4che/_cache.py') except (OSError, IOError): bld.fatal('Project is not configured') # This is where the cache file is made and VERSION is rewritten. global VERSION VERSION = bld.cmd_and_log("%s -s VCS_TAG -o %s/autorevision.cache " % (env.get_flat('AUTOREVISION'), bld.path.abspath()), cwd=bld.path.abspath()).strip() def dist(bld): # Make sure that the cache file is in the tarball. arv(bld) def build(bld): # Make sure that the cache file is built first. arv(bld) # Here we let waf know about the autorevision.cache file. autorevision_cache_node = bld.path.find_or_declare('autorevision.cache') # This is where the autorevision.json file is made. bld( rule='${AUTOREVISION} -f -t json -o ${SRC[0].abspath()} > ${TGT}', source=autorevision_cache_node, target='autorevision.json') # This is where the autorevision.h file is made. bld( rule='${AUTOREVISION} -f -t h -o ${SRC[0].abspath()} > ${TGT}', source=autorevision_cache_node, target='autorevision.h') def test(bld): # A simple sanity check. arv(bld) autorevision-1.22/contribs/xcode.sh0000755000076500000240000000515712501404050016323 0ustar dak180staff#!/bin/sh # This script drives autorevision so that you end up with two # `autorevision.h` files; one for including in the program and one for # populating values in the `info.plist` file (some of which are user # visible). # The cache file is generated in a repo and is read from # unconditionally when building from a tarball. # This script is meant to called from within Xcode, some of the # variables are defined in the environment there. # Config export PATH=${PATH}:/sw/bin:/usr/local/bin:/usr/local/git/bin : "${DERIVED_FILE_DIR:="./der"}" : "${SRCROOT:="./src"}" : "${OBJROOT:="./obj"}" # This header file uses a slightly different format and a customized # cache suitable for use with an info.plist file. infoPlistOutput="${DERIVED_FILE_DIR}/autorevision.h" customCacheOutput="${OBJROOT}/autorevision.tmp" # This is a header suitable for including is your code. # The one that actually gets included is only updated when something # changes to prevent needless rebuilding. cHeaderOutput="${SRCROOT}/autorevision.h" cHeaderTempOutput="${OBJROOT}/autorevision.h" # This is what needs to be in a tarball to make things work. cacheOutput="${SRCROOT}/autorevision.cache" # Output the autorevision cache. if ! autorevision -o "${cacheOutput}" -t sh; then exit ${?} fi ### # This section does some manipulations to make the output pretty for # use in the info.plist # Source the cache to allow for value manipulation. . "${cacheOutput}" if [ ! "${VCS_TICK}" = "0" ]; then # If we are not exactly on a tag make the branch look better and use the value for the tag too. N_VCS_BRANCH="$(echo "${VCS_BRANCH}" | sed -e 's:remotes/:remote/:' -e 's:master:Master:')" sed -e "s:${VCS_BRANCH}:${N_VCS_BRANCH}:" -e "s:${VCS_TAG}:${N_VCS_BRANCH}:" "${cacheOutput}" > "${customCacheOutput}" else # When exactly on a tag make the value suitable for users. # The following tag prefix formats are recognized and striped: # v1.0 | v/1.0 = 1.0 # The following tag suffix formats are transformed: # 1.0_beta6 = 1.0 Beta 6 || 1.0_rc6 = 1.0 RC 6 N_VCS_TAG="$(echo "${VCS_TAG}" | sed -e 's:^v/::' -e 's:^v::' -e 's:_beta: Beta :' -e 's:_rc: RC :')" sed -e "s:${VCS_TAG}:${N_VCS_TAG}:" "${cacheOutput}" > "${customCacheOutput}" fi ### # Output for src/autorevision.h. autorevision -f -o "${cacheOutput}" -t h > "${cHeaderTempOutput}" if [ ! -f "${cHeaderOutput}" ] || ! cmp -s "${cHeaderTempOutput}" "${cHeaderOutput}"; then # Only copy `src/autorevision.h` in if there have been changes. cp -a "${cHeaderTempOutput}" "${cHeaderOutput}" fi # Output for info.plist prepossessing. autorevision -f -o "${customCacheOutput}" -t xcode > "${infoPlistOutput}" exit ${?} autorevision-1.22/CONTRIBUTING.md0000644000076500000240000000413313012215407015265 0ustar dak180staffThings to Keep in Mind ====================== Support For New Repo Types -------------------------- When supporting new types of repos you should set all of the currently used symbols and document how they are populated. Support for new repos should include a function named in the form `Repo` and a two part test: the first part should try to detect the presence of a repo without using any of the native repository commands, the second test should test for the presence the native repository commands, ideally by determining the full path to the top level of the repo. Generally you *should* assume that you are executing from the top of the repo. The first thing that any repo function should do is `cd` to the root level of the repository, if possible. As a rule of thumb, try to use commands to gather the data to populate the symbols in such a way as to require the least amount of post processing by things like `sed` or `grep`. Support For New Output Types ---------------------------- When supporting new types of outputs you *should* use all of the currently set symbols; if you do not, that needs to be explicitly documented. Support for new outputs should include a function named in the form `Output`; find one that's similar to your target language, clone it, and modify it. Make sure that you commit an example of the output into the `example` directory. Other Conventions ----------------- * Signed commits are preferred and signed tags are required. * Tabs are preferred to spaces. * Do not forget to update the documentation. * You generally should *not* assume that any extras, extensions or otherwise non-default commands are available. * Again, remember this is not `bash` but POSIX shell. * Any use of `sed` *should* use `:` as a delimiter whenever feasible. * All variables should be written in the form `"${}"`. * All error messages should be prefixed with `error: `. * All warning messages should be prefixed with `warning: `. * Try to avoid stderr output from any subcommand leaking through. * Test using [https://www.shellcheck.net/](https://www.shellcheck.net/). autorevision-1.22/control0000644000076500000240000000201513033071233014434 0ustar dak180staff# This is not a real Debian control file, though the syntax is compatible. # It's project metadata for the shipper tool Package: autorevision Description: Extracts metadata about the current revision from your repository. This program is meant to be used by project build systems to extract properties that can be used in software version strings. Repository types supported include git, hg, bzr, and svn. It can create files containing variable and macro definitions suitable for C, C++, Java, sh, Python, Perl, PHP, lua, Javascript, and header files suitable for use with preprocessing Info.plist files. XBS-Github-URL: https://github.com/Autorevision/autorevision Vcs-Browser: https://github.com/Autorevision/autorevision Vcs-Git: git://github.com/Autorevision/autorevision XBS-Ohloh-URL: https://www.openhub.net/p/autorevision Homepage: https://autorevision.github.io/ XBS-IRC-Channel: irc://chat.freenode.net/#autorevision XBS-Logo: contribs/logo.svg XBS-Freecode-Tags: svn git hg perl python c c++ bash build_tools autorevision-1.22/COPYING.md0000644000076500000240000000206314003623526014474 0ustar dak180staffCopyright (c) 2012 - 2021 dak180 and contributors. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. autorevision-1.22/logo.svg.in0000644000076500000240000000756313106605516015144 0ustar dak180staff #define VCS_TYPE                    "@VCS_TYPE@" #define VCS_BASENAME        "@VCS_BASENAME@" #define VCS_UUID                    "@VCS_UUID@" #define VCS_NUM                    @VCS_NUM@ #define VCS_DATE                    "@VCS_DATE@" #define VCS_BRANCH            "@VCS_BRANCH@" #define VCS_TAG                    "@VCS_TAG@" #define VCS_TICK                    @VCS_TICK@ #define VCS_FULL_HASH            "@VCS_FULL_HASH@" #define VCS_SHORT_HASH        "@VCS_SHORT_HASH@" #define VCS_WC_MODIFIED        @VCS_WC_MODIFIED@ autorevision-1.22/Makefile0000644000076500000240000000765514003202471014506 0ustar dak180staff# Makefile for the autorevision project # `a2x / asciidoc` is required to generate the Man page. # `markdown` is required for the `docs` target, though it is not # strictly necessary for packaging since unless you are planning on # serving the docs on a web site they are more readable not as html. # `shipper` and `gpg` are required for the `release` target, which # should only be used if you are shipping tarballs (you probably are # not). # Get the version number VERS := $(shell ./autorevision.sh -s VCS_TAG -o ./autorevision.cache | sed -e 's:v/::') # Date for documentation DOCDATE := $(shell ./autorevision.sh -s VCS_DATE -o ./autorevision.cache -f | sed -e 's:T.*::') # Find a md5 program MD5 := $(shell if command -v "md5" > /dev/null 2>&1; then echo "md5 -q"; elif command -v "md5sum" > /dev/null 2>&1; then echo "md5sum"; fi) .SUFFIXES: .md .html .md.html: markdown $< > $@ # `prefix`, `mandir` & `DESTDIR` can and should be set on the command line to control installation locations prefix ?= /usr/local mandir ?= /share/man target = $(DESTDIR)$(prefix) DOCS = \ NEWS \ autorevision.asciidoc \ README.md \ CONTRIBUTING.md \ COPYING.md SOURCES = \ $(DOCS) \ autorevision.sh \ Makefile \ control EXTRA_DIST = \ logo.svg.in \ contribs \ AUTHORS.txt \ autorevision.cache all : cmd man logo.svg # The script cmd: autorevision # Insert the version number autorevision: autorevision.sh sed -e 's:&&ARVERSION&&:$(VERS):g' autorevision.sh > autorevision chmod +x autorevision # The Man Page man: autorevision.1.gz autorevision.1.gz: autorevision.1 gzip --no-name < autorevision.1 > autorevision.1.gz autorevision.1: autorevision.asciidoc a2x --attribute="revdate=$(DOCDATE)" --attribute="revnumber=$(VERS)" -f manpage autorevision.asciidoc # HTML representation of the man page autorevision.html: autorevision.asciidoc asciidoc --attribute="revdate=$(DOCDATE)" --attribute="footer-style=revdate" --attribute="revnumber=$(VERS)" --doctype=manpage --backend=xhtml11 autorevision.asciidoc # Authors auth: AUTHORS.txt AUTHORS.txt: .mailmap autorevision.cache git log --format='%aN <%aE>' | sort -f | uniq -c | sort -rn | sed 's:^ *[0-9]* *::' > AUTHORS.txt autorevision.sed: autorevision.cache ./autorevision.sh -f -t sed -o $< > $@ logo.svg: logo.svg.in autorevision.sed sed -f autorevision.sed $< > $@ # The tarball signed and sealed dist: tarball autorevision-$(VERS).tgz.md5 autorevision-$(VERS).tgz.sig # The tarball tarball: autorevision-$(VERS).tgz # Make an md5 checksum autorevision-$(VERS).tgz.md5: tarball $(MD5) autorevision-$(VERS).tgz > autorevision-$(VERS).tgz.md5 # Make a detached gpg sig autorevision-$(VERS).tgz.sig: tarball gpg --armour --detach-sign --output "autorevision-$(VERS).tgz.sig" "autorevision-$(VERS).tgz" # The actual tarball autorevision-$(VERS).tgz: $(SOURCES) all auth mkdir autorevision-$(VERS) cp -pR $(SOURCES) $(EXTRA_DIST) autorevision-$(VERS)/ @COPYFILE_DISABLE=1 GZIP=-n9 tar -czf autorevision-$(VERS).tgz --exclude=".DS_Store" autorevision-$(VERS) rm -fr autorevision-$(VERS) install: all install -d "$(target)/bin" install -m 755 autorevision "$(target)/bin/autorevision" install -d "$(target)$(mandir)/man1" install -m 644 autorevision.1.gz "$(target)$(mandir)/man1/autorevision.1.gz" uninstall: rm -f "$(target)/bin/autorevision" "$(target)$(mandir)/man1/autorevision.1.gz" clean: rm -f autorevision autorevision.html autorevision.1 autorevision.1.gz rm -f autorevision.sed logo.svg rm -f *.tgz *.md5 *.sig rm -f docbook-xsl.css rm -f CONTRIBUTING.html COPYING.html README.html rm -f *~ index.html # Not safe to run in a tarball devclean: clean rm -f autorevision.cache rm -f AUTHORS AUTHORS.txt rm -f *.orig ./*/*.orig # HTML versions of doc files suitable for use on a website docs: \ autorevision.html \ README.html \ CONTRIBUTING.html \ COPYING.html # Tag with `git tag -s v/` before running this. release: docs dist git tag -v "v/$(VERS)" # shipper version=$(VERS) | sh -e -x autorevision-1.22/NEWS0000644000076500000240000000654114003624036013543 0ustar dak180staff autorevision history 1.22 @ 2021-01-25: Make sure we do not get a tag where we need a branch. Do not emit warnings about nonexistent tags. Add option -C for changing working directory. Add a subcommand check. Replace if chains with case. 1.21 @ 2017-09-30: Try to make tarballs more reproducible. Add an option to silence warnings. Add a sed script output. Auto generate the logo with update commit info. Note if the tag (in git) is not annotated. Extract info about OpenPGP keys used to sign tags/commits. 1.20 @ 2017-01-03: Better determinism in the order of the author file. Better tests for `local` support. Make sure the cache file is not polluted from other output types. 1.19 @ 2016-12-20: Only use the committer date for git. Only use the `local` keyword where supported. 1.18 @ 2016-11-22: Fix some bashisms in the make file. Get the short hash from git rather than assuming its length. 1.17 @ 2016-11-18: Fix out of repo operation. Bring back the irc channel. Add a script to sanity check out of repo operation. 1.16 @ 2016-11-15: Try to eliminate stray error output. Allow the VCS_EXTRA symbol to be renamed. Add an C# output. Add an CMake output. 1.15 @ 2016-08-08: Add support for action stamps. Add support for plain c/c++ source output. Activate mq as needed for hg. Add an .editorconfig file. 1.14 @ 2016-02-22: Fix PHP output. Use constants array in PHP output. Make sure that the cache file gets outputted where expected. Add an example for use with waf. 1.13 @ 2015-07-31: Make the man page more reproducible. Make sure VCS_WS_MODIFIED is not empty for svn. Remove sql output until such time as it can be completed. Add some missing example files. 1.12 @ 2015-03-16 Use --xml for svn when we care about the output. New site: https://autorevision.github.io/ Handle older svn detection more gracefully. 1.11 @ 2015-02-20 Added scheme, clojure, rpm, and sql outputs. Added hpp, matlab, and octave outputs. Reorder types in help and asciidoc to be more alphabetical. Try using md5sum when md5 is not available when making tarballs. Fix a typo in the svn driver. 1.10a @ 2014-10-24 Emergency bug fix. 1.10 @ 2014-10-23 Cover the case of split repository heads. Add initial Swift output support. 1.9 @ 2014-05-23 Add a logo. Only update the cache file when there are changes. New dependency `cmp`. 1.8 @ 2013-12-27 Added user-set symbol VC_EXTRA. Added VCS_UUID as a unique repostory key. 1.7 @ 2013-12-01 Autogenerate the AUTHORS file. Do not change empty CACHEFILE to `./`. Make sure the -U option works properly. 1.6 @ 2013-08-28 Use autorevision in autorevision. Ensure that the cache path is one that can be sourced. Add an AUTHORS file. 1.5 @ 2013-08-12 Add support for git-svn - gives back the Subversion revision, not the hash. Add a -U to check for unversioned files in svn. 1.4 @ 2013-01-18 Remove bashisms. Add "python" and "perl" language synonyms. Add m4. Work around unreliable return value of git diff in 1.7.9.5. 1.3 @ 2012-12-09 (La)TeX output support added. 1.2 @ 2012-10-30 Bazaar extractor added. autorevision can now usually be called safely from subdirectories. Drop back to numeric VCS_WC_MODIFIED so the C processor can use it. 1.1 @ 2012-10-28 Java and Java properties support added. 1.0 @ 2012-10-25 Initial release. autorevision-1.22/README.md0000644000076500000240000000155712460572306014334 0ustar dak180staffAutorevision ============ A shell script for extracting revision information useful in release/build scripting from repositories. Supported repository types include `git`, `hg`, `bzr`, and `svn`. The record can be emitted in a ready-to-use form for `C`, `C++`, `Java`, `bash`, `Python`, `Perl`, `lua`, `php`, `ini` and others. Emitted information includes the ID of the most recent commit, its branch, its date, and several other useful pieces of meta-information. There is support for reading and writing a cache file so autorevision will remain useful during a build from an unpacked distribution tarball. See the [manual page](./autorevision.asciidoc), included in the distribution, for invocation details. You can check out examples of the different output that autorevision can produce in [examples](https://github.com/Autorevision/autorevision/tree/master/examples).