autorevision-1.13/0000755000076500000240000000000012557154124013046 5ustar dak180staffautorevision-1.13/AUTHORS.txt0000644000076500000240000000056212557154123014736 0ustar dak180staffdak180 Eric S. Raymond Mike Swanson Dmitry Marakasov Dennis Biringer Paul Wise Joel C. Salomon yuanchuan Robert Wenner Hironori Ichimiya autorevision-1.13/autorevision.asciidoc0000644000076500000240000001627012557016413017301 0ustar dak180staff= AUTOREVISION(1) = == NAME == autorevision - extract current-revision metadata from version-control repositories == SYNOPSIS == *autorevision* {*-t* | *-s* } [*-o* [*-f*]] [*-U*] [*-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 software version strings. It can emit source files containing variable and macro definitions suitable for use with C, C++, Java, sh, Python, Perl, Mac info.plist and other types of files (see below for the full list). The generated source is written to 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. *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. *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 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 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 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_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. *VCS_FULL_HASH*:: A full unique identifier for the current revision. *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. *-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. *-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. autorevision-1.13/autorevision.cache0000644000076500000240000000056012557154041016561 0ustar dak180staff# Generated by autorevision - do not hand-hack! VCS_TYPE="git" VCS_BASENAME="autorevision" VCS_UUID="da2830f81fec4c6ebce8ebf23f35b0e6b066c149" VCS_NUM="295" VCS_DATE="2015-07-31T21:41:59-0400" VCS_BRANCH="master" VCS_TAG="v/1.13" VCS_TICK="0" VCS_EXTRA="" VCS_FULL_HASH="cfddb0e162d68d84ba38d3e00742c983aed021a1" VCS_SHORT_HASH="cfddb0e" VCS_WC_MODIFIED="0" # end autorevision-1.13/autorevision.mk0000644000076500000240000000162712336457404016136 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.h \ 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++ header output cpp: autorevision.h autorevision.h: autorevision.cache autorevision -f -t h -o ./autorevision.cache > autorevision.h autorevision-1.13/autorevision.sh0000755000076500000240000006767012557016413016152 0ustar dak180staff#!/bin/sh # Copyright (c) 2012 - 2014 dak180 and contributors. See # http://opensource.org/licenses/mit-license.php or the included # COPYING.md for licence terms. # # autorevision - extracts metadata about the head version from your # repository. # Usage message. arUsage() { cat > "/dev/stderr" << EOF usage: autorevision {-t output-type | -s symbol} [-o cache-file [-f] ] [-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 -U = check for untracked files in svn -V = emit version and exit -? = help message The following are valid output types: clojure = clojure 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 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_TICK VCS_EXTRA VCS_FULL_HASH VCS_SHORT_HASH VCS_WC_MODIFIED EOF exit 1 } # Config ARVERSION="&&ARVERSION&&" TARGETFILE="/dev/stdout" while getopts ":t:o:s:VfU" OPTION; do case "${OPTION}" in t) AFILETYPE="${OPTARG}" ;; o) CACHEFILE="${OPTARG}" ;; f) CACHEFORCE="1" ;; s) VAROUT="${OPTARG}" ;; U) UNTRACKEDFILES="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 # 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 # Functions to extract data from different repo types. # For git repos # shellcheck disable=SC2155 gitRepo() { cd "$(git rev-parse --show-toplevel)" VCS_TYPE="git" VCS_BASENAME="$(basename "${PWD}")" VCS_UUID="$(git rev-list --max-parents=0 --date-order --reverse HEAD 2>/dev/null | sed -n 1p)" if [ -z "${VCS_UUID}" ]; then VCS_UUID="$(git rev-list --topo-order HEAD | 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 HEAD 2>/dev/null)" if [ -z "${VCS_NUM}" ]; 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 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 HEAD)" # The short hash VCS_SHORT_HASH="$(echo "${VCS_FULL_HASH}" | cut -b 1-7)" else # The git-svn revision number VCS_FULL_HASH="$(git svn find-rev HEAD)" VCS_SHORT_HASH="${VCS_FULL_HASH}" fi # Current branch VCS_BRANCH="$(git rev-parse --symbolic-full-name --verify "$(git name-rev --name-only --no-undefined HEAD 2>/dev/null)" 2>/dev/null | sed -e 's:refs/heads/::' | sed -e 's:refs/::')" # Cache the description local DESCRIPTION="$(git describe --long --tags 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]*$::')" # 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="$(git log -1 --pretty=format:%ci | sed -e 's: :T:' -e 's: ::')" } # For hg repos hgRepo() { 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=' --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: ::')" } # For bzr repos bzrRepo() { 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: ::')" } # For svn repos # shellcheck disable=SC2155 svnRepo() { 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:::' -e 's:Z:-0000:p')" } # Functions to output data in different formats. # For header output hOutput() { cat > "${TARGETFILE}" << EOF /* Generated by autorevision - do not hand-hack! */ #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_TICK ${VCS_TICK} #define VCS_EXTRA "${VCS_EXTRA}" #define VCS_FULL_HASH "${VCS_FULL_HASH}" #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() { cat > "${TARGETFILE}" << EOF /* Generated by autorevision - do not hand-hack! */ #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_TICK ${VCS_TICK} #define VCS_EXTRA ${VCS_EXTRA} #define VCS_FULL_HASH ${VCS_FULL_HASH} #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 : "${VCS_TICK:="nil"}" if [ -z "${VCS_EXTRA}" ]; then VCS_EXTRA="nil" else VCS_EXTRA="\"${VCS_EXTRA}\"" fi cat > "${TARGETFILE}" << EOF /* Generated by autorevision - do not hand-hack! */ 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_TICK: Int? = ${VCS_TICK} let VCS_EXTRA: String? = ${VCS_EXTRA} let VCS_FULL_HASH: String = "${VCS_FULL_HASH}" let VCS_SHORT_HASH: String = "${VCS_SHORT_HASH}" let VCS_WC_MODIFIED: Bool = ${VCS_WC_MODIFIED} /* end */ EOF } # For bash output shOutput() { cat > "${TARGETFILE}" << EOF # Generated by autorevision - do not hand-hack! 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_TICK="${VCS_TICK}" VCS_EXTRA="${VCS_EXTRA}" VCS_FULL_HASH="${VCS_FULL_HASH}" VCS_SHORT_HASH="${VCS_SHORT_HASH}" VCS_WC_MODIFIED="${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 cat > "${TARGETFILE}" << EOF # Generated by autorevision - do not hand-hack! 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_TICK = ${VCS_TICK} VCS_EXTRA = "${VCS_EXTRA}" VCS_FULL_HASH = "${VCS_FULL_HASH}" VCS_SHORT_HASH = "${VCS_SHORT_HASH}" VCS_WC_MODIFIED = ${VCS_WC_MODIFIED} # end EOF } # For Perl output plOutput() { cat << EOF # Generated by autorevision - do not hand-hack! \$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_TICK = ${VCS_TICK}; \$VCS_EXTRA = "${VCS_EXTRA}"; \$VCS_FULL_HASH = "${VCS_FULL_HASH}"; \$VCS_SHORT_HASH = "${VCS_SHORT_HASH}"; \$VCS_WC_MODIFIED = ${VCS_WC_MODIFIED}; # end EOF } # For lua output luaOutput() { case "${VCS_WC_MODIFIED}" in 0) VCS_WC_MODIFIED="false" ;; 1) VCS_WC_MODIFIED="true" ;; esac cat > "${TARGETFILE}" << EOF -- Generated by autorevision - do not hand-hack! 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_TICK = ${VCS_TICK} VCS_EXTRA = "${VCS_EXTRA}" VCS_FULL_HASH = "${VCS_FULL_HASH}" 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 cat > "${TARGETFILE}" << EOF EOF } # For ini output iniOutput() { case "${VCS_WC_MODIFIED}" in 0) VCS_WC_MODIFIED="false" ;; 1) VCS_WC_MODIFIED="true" ;; esac cat > "${TARGETFILE}" << EOF ; Generated by autorevision - do not hand-hack! [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_TICK = ${VCS_TICK} VCS_EXTRA = "${VCS_EXTRA}" VCS_FULL_HASH = "${VCS_FULL_HASH}" 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 cat > "${TARGETFILE}" << EOF /** Generated by autorevision - do not hand-hack! */ 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_TICK: ${VCS_TICK}, VCS_EXTRA: "${VCS_EXTRA}", VCS_FULL_HASH: "${VCS_FULL_HASH}", 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 cat > "${TARGETFILE}" << EOF { "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_TICK": ${VCS_TICK}, "VCS_EXTRA": "${VCS_EXTRA}", "VCS_FULL_HASH": "${VCS_FULL_HASH}", "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 cat > "${TARGETFILE}" << EOF /* Generated by autorevision - do not hand-hack! */ 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 long VCS_TICK = ${VCS_TICK}; public static final String VCS_EXTRA = "${VCS_EXTRA}"; public static final String VCS_FULL_HASH = "${VCS_FULL_HASH}"; public static final String VCS_SHORT_HASH = "${VCS_SHORT_HASH}"; public static final boolean VCS_WC_MODIFIED = ${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 cat > "${TARGETFILE}" << EOF # Generated by autorevision - do not hand-hack! 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_TICK=${VCS_TICK} VCS_EXTRA=${VCS_EXTRA} VCS_FULL_HASH=${VCS_FULL_HASH} VCS_SHORT_HASH=${VCS_SHORT_HASH} VCS_WC_MODIFIED=${VCS_WC_MODIFIED} EOF } # For m4 output m4Output() { cat > "${TARGETFILE}" << EOF 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_TICK', \`${VCS_TICK}')dnl define(\`VCS_EXTRA', \`${VCS_EXTRA}')dnl define(\`VCS_FULLHASH', \`${VCS_FULL_HASH}')dnl define(\`VCS_SHORTHASH', \`${VCS_SHORT_HASH}')dnl define(\`VCS_WC_MODIFIED', \`${VCS_WC_MODIFIED}')dnl EOF } # For (La)TeX output texOutput() { case "${VCS_WC_MODIFIED}" in 0) VCS_WC_MODIFIED="false" ;; 1) VCS_WC_MODIFIED="true" ;; esac cat > "${TARGETFILE}" << EOF % Generated by autorevision - do not hand-hack! \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 \vcsTick {${VCS_TICK}} \def \vcsExtra {${VCS_EXTRA}} \def \vcsFullHash {${VCS_FULL_HASH}} \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 cat > "${TARGETFILE}" << EOF ;; Generated by autorevision - do not hand-hack! (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_EXTRA "${VCS_EXTRA}") (define VCS_FULL_HASH "${VCS_FULL_HASH}") (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 cat > "${TARGETFILE}" << EOF ;; Generated by autorevision - do not hand-hack! (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_TICK ${VCS_TICK}) (def VCS_EXTRA "${VCS_EXTRA}") (def VCS_FULL_HASH "${VCS_FULL_HASH}") (def VCS_SHORT_HASH "${VCS_SHORT_HASH}") (def VCS_WC_MODIFIED ${VCS_WC_MODIFIED}) ;; end EOF } # For rpm spec file output rpmOutput() { cat > "${TARGETFILE}" << EOF # Generated by autorevision - do not hand-hack! $([ "${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}" ] && echo "%define vcs_tag ${VCS_TAG}") $([ "${VCS_TICK}" ] && echo "%define vcs_tick ${VCS_TICK}") $([ "${VCS_EXTRA}" ] && echo "%define vcs_extra ${VCS_EXTRA}") $([ "${VCS_FULL_HASH}" ] && echo "%define vcs_full_hash ${VCS_FULL_HASH}") $([ "${VCS_SHORT_HASH}" ] && echo "%define vcs_short_hash ${VCS_SHORT_HASH}") $([ "${VCS_WC_MODIFIED}" ] && echo "%define vcs_wc_modified ${VCS_WC_MODIFIED}") # end EOF } # shellcheck disable=SC2155 hppOutput() { local NAMESPACE="$(echo "${VCS_BASENAME}" | sed -e 's:_::g' | tr '[:lower:]' '[:upper:]')" cat > "${TARGETFILE}" << EOF /* Generated by autorevision - do not hand-hack! */ #ifndef ${NAMESPACE}_AUTOREVISION_H #define ${NAMESPACE}_AUTOREVISION_H 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 int VCS_TICK = ${VCS_TICK}; const std::string VCS_EXTRA = "${VCS_EXTRA}"; const std::string VCS_FULL_HASH = "${VCS_FULL_HASH}"; const std::string VCS_SHORT_HASH = "${VCS_SHORT_HASH}"; const int VCS_WC_MODIFIED = ${VCS_WC_MODIFIED}; } #endif /* end */ EOF } matlabOutput() { case "${VCS_WC_MODIFIED}" in 0) VCS_WC_MODIFIED="FALSE" ;; 1) VCS_WC_MODIFIED="TRUE" ;; esac cat > "${TARGETFILE}" << EOF % Generated by autorevision - do not hand-hack! 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_TICK = ${VCS_TICK}; VCS_EXTRA = '${VCS_EXTRA}'; VCS_FULL_HASH = '${VCS_FULL_HASH}'; VCS_SHORT_HASH = '${VCS_SHORT_HASH}'; VCS_WC_MODIFIED = ${VCS_WC_MODIFIED}; % end EOF } octaveOutput() { cat > "${TARGETFILE}" << EOF % Generated by autorevision - do not hand-hack! 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_TICK = ${VCS_TICK}; VCS_EXTRA = '${VCS_EXTRA}'; VCS_FULL_HASH = '${VCS_FULL_HASH}'; VCS_SHORT_HASH = '${VCS_SHORT_HASH}'; VCS_WC_MODIFIED = ${VCS_WC_MODIFIED}; % end EOF } # Helper functions # Count path segments pathSegment() { local pathz="${1}" local depth="0" if [ ! -z "${pathz}" ]; then while [ ! "${pathz}" = "/" ] && [ ! "${pathz}" = "." ]; do pathz="$(dirname "${pathz}")" depth="$((depth+1))" done fi echo "${depth}" } # Largest of four numbers 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}" } # shellcheck disable=SC2155 # Test for repositories repoTest() { REPONUM="0" if [ ! -z "$(git rev-parse HEAD 2>/dev/null)" ]; then local gitPath="$(git rev-parse --show-toplevel)" local gitDepth="$(pathSegment "${gitPath}")" REPONUM="$((REPONUM+1))" else local gitDepth="0" fi if [ ! -z "$(hg root 2>/dev/null)" ]; then local hgPath="$(hg root 2>/dev/null)" local hgDepth="$(pathSegment "${hgPath}")" REPONUM="$((REPONUM+1))" else local hgDepth="0" fi if [ ! -z "$(bzr root 2>/dev/null)" ]; then local bzrPath="$(bzr root 2>/dev/null)" local bzrDepth="$(pathSegment "${bzrPath}")" REPONUM="$((REPONUM+1))" else local bzrDepth="0" fi if [ ! -z "$(svn info 2>/dev/null)" ]; then local stringz="" local stringx="" local svnPath="$(svn info --xml | 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="1" else local svnDepth="$(pathSegment "${svnPath}")" fi REPONUM="$((REPONUM+1))" else local svnDepth="0" fi # Do not do more work then we have to. if [ "${REPONUM}" = "0" ]; then return 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. 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:=""}" repoTest 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 # -s output is handled here. if [ ! -z "${VAROUT}" ]; then if [ "${VAROUT}" = "VCS_TYPE" ]; then echo "${VCS_TYPE}" elif [ "${VAROUT}" = "VCS_BASENAME" ]; then echo "${VCS_BASENAME}" elif [ "${VAROUT}" = "VCS_NUM" ]; then echo "${VCS_NUM}" elif [ "${VAROUT}" = "VCS_DATE" ]; then echo "${VCS_DATE}" elif [ "${VAROUT}" = "VCS_BRANCH" ]; then echo "${VCS_BRANCH}" elif [ "${VAROUT}" = "VCS_TAG" ]; then echo "${VCS_TAG}" elif [ "${VAROUT}" = "VCS_TICK" ]; then echo "${VCS_TICK}" elif [ "${VAROUT}" = "VCS_FULL_HASH" ]; then echo "${VCS_FULL_HASH}" elif [ "${VAROUT}" = "VCS_SHORT_HASH" ]; then echo "${VCS_SHORT_HASH}" elif [ "${VAROUT}" = "VCS_WC_MODIFIED" ]; then echo "${VCS_WC_MODIFIED}" else echo "error: Not a valid output symbol." 1>&2 exit 1 fi fi # Detect requested output type and use it. if [ ! -z "${AFILETYPE}" ]; then if [ "${AFILETYPE}" = "h" ]; then hOutput elif [ "${AFILETYPE}" = "xcode" ]; then xcodeOutput elif [ "${AFILETYPE}" = "swift" ]; then swiftOutput elif [ "${AFILETYPE}" = "sh" ]; then shOutput elif [ "${AFILETYPE}" = "py" ] || [ "${AFILETYPE}" = "python" ]; then pyOutput elif [ "${AFILETYPE}" = "pl" ] || [ "${AFILETYPE}" = "perl" ]; then plOutput elif [ "${AFILETYPE}" = "lua" ]; then luaOutput elif [ "${AFILETYPE}" = "php" ]; then phpOutput elif [ "${AFILETYPE}" = "ini" ]; then iniOutput elif [ "${AFILETYPE}" = "js" ]; then jsOutput elif [ "${AFILETYPE}" = "json" ]; then jsonOutput elif [ "${AFILETYPE}" = "java" ]; then javaOutput elif [ "${AFILETYPE}" = "javaprop" ]; then javapropOutput elif [ "${AFILETYPE}" = "tex" ]; then texOutput elif [ "${AFILETYPE}" = "m4" ]; then m4Output elif [ "${AFILETYPE}" = "scheme" ]; then schemeOutput elif [ "${AFILETYPE}" = "clojure" ]; then clojureOutput elif [ "${AFILETYPE}" = "rpm" ]; then rpmOutput elif [ "${AFILETYPE}" = "hpp" ]; then hppOutput elif [ "${AFILETYPE}" = "matlab" ]; then matlabOutput elif [ "${AFILETYPE}" = "octave" ]; then octaveOutput else echo "error: Not a valid output type." 1>&2 exit 1 fi fi # If requested, make a cache file. if [ ! -z "${CACHEFILE}" ] && [ ! "${CACHEFORCE}" = "1" ]; then TARGETFILE="${CACHEFILE}.tmp" shOutput # 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 fi autorevision-1.13/CONTRIBUTING.md0000644000076500000240000000403412460605214015272 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 ----------------- * 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 [http://www.shellcheck.net/](http://www.shellcheck.net/). autorevision-1.13/control0000644000076500000240000000163312501343664014452 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 XBS-Ohloh-URL: http://www.ohloh.net/p/autorevision XBS-Destinations: freecode Homepage: https://autorevision.github.io/ XBS-HTML-Target: index.html XBS-Logo: contribs/logo.svg XBS-Freecode-Tags: svn git hg perl python c c++ bash build_tools autorevision-1.13/COPYING.md0000644000076500000240000000206312461012343014467 0ustar dak180staffCopyright (c) 2012 - 2015 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.13/logo.svg0000644000076500000240000000757512303712677014547 0ustar dak180staff #define VCS_TYPE                    "git" #define VCS_BASENAME        "autorevision" #define VCS_UUID                    "da2830f81fec4c6ebce8ebf23f35b0e6b066c149" #define VCS_NUM                    218 #define VCS_DATE                    "2014-01-01T14:44:20-0500" #define VCS_BRANCH            "master" #define VCS_TAG                    "v/1.8" #define VCS_TICK                    6 #define VCS_FULL_HASH            "5f5ef3165c882132bd43daed1211c7b9ee5c28b8" #define VCS_SHORT_HASH        "5f5ef31" #define VCS_WC_MODIFIED        0 autorevision-1.13/Makefile0000644000076500000240000000673012504422505014505 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 type "md5" &> /dev/null; then echo "md5 -q"; elif type "md5sum" &> /dev/null; 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 = \ contribs/logo.svg \ contribs/autorevision.mk \ AUTHORS.txt \ autorevision.cache all : cmd man # 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 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 --doctype=manpage --backend=xhtml11 autorevision.asciidoc # Authors auth: AUTHORS.txt AUTHORS.txt: git log --format='%aN <%aE>' | awk '{arr[$$0]++} END{for (i in arr){print arr[i], i;}}' | sort -rn | cut -d\ -f2- > AUTHORS.txt # The tarball dist: autorevision-$(VERS).tgz autorevision-$(VERS).tgz.md5 autorevision-$(VERS).tgz.sig # Make an md5 checksum autorevision-$(VERS).tgz.md5: autorevision-$(VERS).tgz $(MD5) autorevision-$(VERS).tgz > autorevision-$(VERS).tgz.md5 # Make a detached gpg sig autorevision-$(VERS).tgz.sig: autorevision-$(VERS).tgz 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 tar -czf autorevision-$(VERS).tgz autorevision-$(VERS) rm -fr autorevision-$(VERS) install: all install -d "$(target)/bin" install -m 755 autorevision "$(target)/bin/autorevision" install -d "$(target)$(mandir)/man1" gzip --no-name < autorevision.1 > "$(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 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 # 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.13/NEWS0000644000076500000240000000355212557021720013545 0ustar dak180staff autorevision history 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.13/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).