├── .editorconfig ├── .github ├── ISSUE_TEMPLATE.md └── PULL_REQUEST_TEMPLATE.md ├── .gitignore ├── .mailmap ├── CONTRIBUTING.md ├── COPYING.md ├── Makefile ├── NEWS ├── README.md ├── autorevision.asciidoc ├── autorevision.sh ├── contribs ├── README.md ├── autorevision.mk ├── autorevision_declr.h ├── wscript └── xcode.sh ├── control ├── examples ├── autorevision.c ├── autorevision.clojure ├── autorevision.cmake ├── autorevision.csharp ├── autorevision.h ├── autorevision.hpp ├── autorevision.ini ├── autorevision.java ├── autorevision.javaprop ├── autorevision.js ├── autorevision.json ├── autorevision.lua ├── autorevision.m4 ├── autorevision.matlab ├── autorevision.octave ├── autorevision.php ├── autorevision.pl ├── autorevision.py ├── autorevision.rpm ├── autorevision.scheme ├── autorevision.sed ├── autorevision.sh ├── autorevision.swift ├── autorevision.tex ├── autorevision.xcode └── mkexamp.sh ├── logo.svg.in └── test.sh /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | 3 | root = true 4 | 5 | [*] 6 | charset = utf-8 7 | end_of_line = lf 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | indent_style = tab 11 | indent_size = 4 12 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ### What you are doing? 2 | _Post a minimal code sample that reproduces the issue_ 3 | 4 | ```shell 5 | // code here 6 | ``` 7 | 8 | ### What do you expect to happen? 9 | _I wanted Foo!_ 10 | 11 | ### What is actually happening? 12 | _But the output was bar!_ 13 | 14 | ### What version is Autorevision? 15 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ### Preflight Checklist 2 | I have: 3 | 4 | - [ ] Read the Contributor's Guidelines. 5 | - [ ] Updated the examples as necessary. 6 | - [ ] Updated the documentation as necessary. 7 | - [ ] GPG signed my commits. 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /*.html 2 | /*.css 3 | /*.cache 4 | /*.1 5 | /*.1.gz 6 | /*.tgz 7 | /*.md5 8 | /*.sig 9 | /logo.svg 10 | /autorevision.sed 11 | /autorevision 12 | /AUTHORS 13 | /AUTHORS.txt 14 | -------------------------------------------------------------------------------- /.mailmap: -------------------------------------------------------------------------------- 1 | Dennis Biringer 2 | Qiuwen Lu 3 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Things to Keep in Mind 2 | ====================== 3 | 4 | 5 | Support For New Repo Types 6 | -------------------------- 7 | 8 | When supporting new types of repos you should set all of the currently used symbols and document how they are populated. 9 | 10 | 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. 11 | 12 | Generally you *should* assume that you are executing from the top of the repo. 13 | 14 | The first thing that any repo function should do is `cd` to the root level of the repository, if possible. 15 | 16 | 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`. 17 | 18 | 19 | Support For New Output Types 20 | ---------------------------- 21 | 22 | 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. 23 | 24 | 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. 25 | 26 | Make sure that you commit an example of the output into the `example` directory. 27 | 28 | Other Conventions 29 | ----------------- 30 | 31 | * Signed commits are preferred and signed tags are required. 32 | * Tabs are preferred to spaces. 33 | * Do not forget to update the documentation. 34 | * You generally should *not* assume that any extras, extensions or otherwise non-default commands are available. 35 | * Again, remember this is not `bash` but POSIX shell. 36 | * Any use of `sed` *should* use `:` as a delimiter whenever feasible. 37 | * All variables should be written in the form `"${}"`. 38 | * All error messages should be prefixed with `error: `. 39 | * All warning messages should be prefixed with `warning: `. 40 | * Try to avoid stderr output from any subcommand leaking through. 41 | * Test using [https://www.shellcheck.net/](https://www.shellcheck.net/). 42 | -------------------------------------------------------------------------------- /COPYING.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 - 2023 dak180 and contributors. 2 | 3 | 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: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | 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. 8 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for the autorevision project 2 | 3 | # `a2x / asciidoc` is required to generate the Man page. 4 | # `markdown` is required for the `docs` target, though it is not 5 | # strictly necessary for packaging since unless you are planning on 6 | # serving the docs on a web site they are more readable not as html. 7 | # `shipper` and `gpg` are required for the `release` target, which 8 | # should only be used if you are shipping tarballs (you probably are 9 | # not). 10 | 11 | # Get the version number 12 | VERS := $(shell ./autorevision.sh -s VCS_TAG -o ./autorevision.cache | sed -e 's:v/::') 13 | # Date for documentation 14 | DOCDATE := $(shell ./autorevision.sh -s VCS_DATE -o ./autorevision.cache -f | sed -e 's:T.*::') 15 | 16 | # Find a md5 program 17 | 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) 18 | 19 | # Find a sha256 program 20 | SHA256 := $(shell if command -v "shasum" > /dev/null 2>&1; then echo "shasum -a 256"; elif command -v "openssl" > /dev/null 2>&1; then echo "openssl sha256"; fi) 21 | 22 | .SUFFIXES: .md .html 23 | 24 | .md.html: 25 | markdown $< > $@ 26 | 27 | # `prefix`, `mandir` & `DESTDIR` can and should be set on the command line to control installation locations 28 | prefix ?= /usr/local 29 | mandir ?= /share/man 30 | target = $(DESTDIR)$(prefix) 31 | 32 | DOCS = \ 33 | NEWS \ 34 | autorevision.asciidoc \ 35 | README.md \ 36 | CONTRIBUTING.md \ 37 | COPYING.md 38 | 39 | SOURCES = \ 40 | $(DOCS) \ 41 | autorevision.sh \ 42 | Makefile \ 43 | control 44 | 45 | EXTRA_DIST = \ 46 | logo.svg.in \ 47 | contribs \ 48 | AUTHORS.txt \ 49 | autorevision.cache 50 | 51 | TEXT_PRODUCTS = \ 52 | autorevision.1 53 | 54 | all : cmd man logo.svg 55 | 56 | # The script 57 | cmd: autorevision 58 | 59 | # Insert the version number 60 | autorevision: autorevision.sh 61 | sed -e 's:&&ARVERSION&&:$(VERS):g' autorevision.sh > autorevision 62 | chmod +x autorevision 63 | 64 | # The Man Page 65 | man: autorevision.1.gz 66 | 67 | autorevision.1.gz: autorevision.1 68 | gzip --no-name < autorevision.1 > autorevision.1.gz 69 | 70 | autorevision.1: autorevision.asciidoc 71 | a2x --attribute="revdate=$(DOCDATE)" --attribute="revnumber=$(VERS)" -f manpage autorevision.asciidoc 72 | 73 | # HTML representation of the man page 74 | autorevision.html: autorevision.asciidoc 75 | asciidoc --attribute="revdate=$(DOCDATE)" --attribute="footer-style=revdate" --attribute="revnumber=$(VERS)" --doctype=manpage --backend=xhtml11 autorevision.asciidoc 76 | 77 | # Authors 78 | auth: AUTHORS.txt 79 | 80 | AUTHORS.txt: .mailmap autorevision.cache 81 | git log --format='%aN <%aE>' | sort -f | uniq -c | sort -rn | sed 's:^ *[0-9]* *::' > AUTHORS.txt 82 | 83 | autorevision.sed: autorevision.cache 84 | ./autorevision.sh -f -t sed -o $< > $@ 85 | 86 | logo.svg: logo.svg.in autorevision.sed 87 | sed -f autorevision.sed $< > $@ 88 | 89 | # The tarball signed and sealed 90 | dist: autorevision-$(VERS).tgz autorevision-$(VERS).tgz.md5 autorevision-$(VERS).tgz.sha256 autorevision-$(VERS).tgz.sig 91 | 92 | # The tarball 93 | tarball: autorevision-$(VERS).tgz 94 | 95 | # Make an md5 checksum 96 | autorevision-$(VERS).tgz.md5: autorevision-$(VERS).tgz 97 | $(MD5) autorevision-$(VERS).tgz > autorevision-$(VERS).tgz.md5 98 | 99 | # Make an sha256 checksum 100 | : autorevision-$(VERS).tgz 101 | $(SHA256) autorevision-$(VERS).tgz > autorevision-$(VERS).tgz.sha256 102 | 103 | # Make a detached gpg sig 104 | autorevision-$(VERS).tgz.sig: autorevision-$(VERS).tgz 105 | gpg --armour --detach-sign --output "autorevision-$(VERS).tgz.sig" "autorevision-$(VERS).tgz" 106 | 107 | # The actual tarball 108 | autorevision-$(VERS).tgz: $(SOURCES) all auth 109 | mkdir autorevision-$(VERS) 110 | cp -pR $(SOURCES) $(EXTRA_DIST) $(TEXT_PRODUCTS) autorevision-$(VERS)/ 111 | @COPYFILE_DISABLE=1 GZIP=-n9 tar -czf autorevision-$(VERS).tgz --exclude=".DS_Store" autorevision-$(VERS) 112 | rm -fr autorevision-$(VERS) 113 | 114 | install: all 115 | install -d "$(target)/bin" 116 | install -m 755 autorevision "$(target)/bin/autorevision" 117 | install -d "$(target)$(mandir)/man1" 118 | install -m 644 autorevision.1.gz "$(target)$(mandir)/man1/autorevision.1.gz" 119 | 120 | uninstall: 121 | rm -f "$(target)/bin/autorevision" "$(target)$(mandir)/man1/autorevision.1.gz" 122 | 123 | clean: 124 | rm -f autorevision autorevision.html autorevision.1 autorevision.1.gz 125 | rm -f autorevision.sed logo.svg 126 | rm -f *.tgz *.md5 *.sig 127 | rm -f docbook-xsl.css 128 | rm -f CONTRIBUTING.html COPYING.html README.html 129 | rm -f *~ index.html 130 | 131 | # Not safe to run in a tarball 132 | devclean: clean 133 | rm -f autorevision.cache 134 | rm -f AUTHORS AUTHORS.txt 135 | rm -f *.orig ./*/*.orig 136 | 137 | # HTML versions of doc files suitable for use on a website 138 | docs: \ 139 | autorevision.html \ 140 | README.html \ 141 | CONTRIBUTING.html \ 142 | COPYING.html 143 | 144 | # Tag with `git tag -s v/` before running this. 145 | release: docs dist 146 | git tag -v "v/$(VERS)" 147 | # shipper version=$(VERS) | sh -e -x 148 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- 1 | autorevision history 2 | 3 | Repository head: 4 | Update the irc channel address. 5 | 6 | 1.22 @ 2021-01-25: 7 | Make sure we do not get a tag where we need a branch. 8 | Do not emit warnings about nonexistent tags. 9 | Add option -C for changing working directory. 10 | Add a subcommand check. 11 | Replace if chains with case. 12 | 13 | 1.21 @ 2017-09-30: 14 | Try to make tarballs more reproducible. 15 | Add an option to silence warnings. 16 | Add a sed script output. 17 | Auto generate the logo with update commit info. 18 | Note if the tag (in git) is not annotated. 19 | Extract info about OpenPGP keys used to sign tags/commits. 20 | 21 | 1.20 @ 2017-01-03: 22 | Better determinism in the order of the author file. 23 | Better tests for `local` support. 24 | Make sure the cache file is not polluted from other output types. 25 | 26 | 1.19 @ 2016-12-20: 27 | Only use the committer date for git. 28 | Only use the `local` keyword where supported. 29 | 30 | 1.18 @ 2016-11-22: 31 | Fix some bashisms in the make file. 32 | Get the short hash from git rather than assuming its length. 33 | 34 | 1.17 @ 2016-11-18: 35 | Fix out of repo operation. 36 | Bring back the irc channel. 37 | Add a script to sanity check out of repo operation. 38 | 39 | 1.16 @ 2016-11-15: 40 | Try to eliminate stray error output. 41 | Allow the VCS_EXTRA symbol to be renamed. 42 | Add an C# output. 43 | Add an CMake output. 44 | 45 | 1.15 @ 2016-08-08: 46 | Add support for action stamps. 47 | Add support for plain c/c++ source output. 48 | Activate mq as needed for hg. 49 | Add an .editorconfig file. 50 | 51 | 1.14 @ 2016-02-22: 52 | Fix PHP output. 53 | Use constants array in PHP output. 54 | Make sure that the cache file gets outputted where expected. 55 | Add an example for use with waf. 56 | 57 | 1.13 @ 2015-07-31: 58 | Make the man page more reproducible. 59 | Make sure VCS_WS_MODIFIED is not empty for svn. 60 | Remove sql output until such time as it can be completed. 61 | Add some missing example files. 62 | 63 | 1.12 @ 2015-03-16 64 | Use --xml for svn when we care about the output. 65 | New site: https://autorevision.github.io/ 66 | Handle older svn detection more gracefully. 67 | 68 | 1.11 @ 2015-02-20 69 | Added scheme, clojure, rpm, and sql outputs. 70 | Added hpp, matlab, and octave outputs. 71 | Reorder types in help and asciidoc to be more alphabetical. 72 | Try using md5sum when md5 is not available when making tarballs. 73 | Fix a typo in the svn driver. 74 | 75 | 1.10a @ 2014-10-24 76 | Emergency bug fix. 77 | 78 | 1.10 @ 2014-10-23 79 | Cover the case of split repository heads. 80 | Add initial Swift output support. 81 | 82 | 1.9 @ 2014-05-23 83 | Add a logo. 84 | Only update the cache file when there are changes. 85 | New dependency `cmp`. 86 | 87 | 1.8 @ 2013-12-27 88 | Added user-set symbol VC_EXTRA. 89 | Added VCS_UUID as a unique repostory key. 90 | 91 | 1.7 @ 2013-12-01 92 | Autogenerate the AUTHORS file. 93 | Do not change empty CACHEFILE to `./`. 94 | Make sure the -U option works properly. 95 | 96 | 1.6 @ 2013-08-28 97 | Use autorevision in autorevision. 98 | Ensure that the cache path is one that can be sourced. 99 | Add an AUTHORS file. 100 | 101 | 1.5 @ 2013-08-12 102 | Add support for git-svn - gives back the Subversion revision, not the hash. 103 | Add a -U to check for unversioned files in svn. 104 | 105 | 1.4 @ 2013-01-18 106 | Remove bashisms. 107 | Add "python" and "perl" language synonyms. 108 | Add m4. 109 | Work around unreliable return value of git diff in 1.7.9.5. 110 | 111 | 1.3 @ 2012-12-09 112 | (La)TeX output support added. 113 | 114 | 1.2 @ 2012-10-30 115 | Bazaar extractor added. 116 | autorevision can now usually be called safely from subdirectories. 117 | Drop back to numeric VCS_WC_MODIFIED so the C processor can use it. 118 | 119 | 1.1 @ 2012-10-28 120 | Java and Java properties support added. 121 | 122 | 1.0 @ 2012-10-25 123 | Initial release. 124 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Autorevision 2 | ============ 3 | 4 | A shell script for extracting revision information useful in release/build scripting from repositories. 5 | 6 | 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. 7 | 8 | Emitted information includes the ID of the most recent commit, its branch, its date, and several other useful pieces of meta-information. 9 | 10 | There is support for reading and writing a cache file so autorevision will remain useful during a build from an unpacked distribution tarball. 11 | 12 | See the [manual page](./autorevision.asciidoc), included in the distribution, for invocation details. 13 | 14 | You can check out examples of the different output that autorevision can produce in [examples](https://github.com/Autorevision/autorevision/tree/master/examples). 15 | -------------------------------------------------------------------------------- /autorevision.asciidoc: -------------------------------------------------------------------------------- 1 | = AUTOREVISION(1) = 2 | 3 | == NAME == 4 | autorevision - extract current-revision metadata from version-control repositories 5 | 6 | == SYNOPSIS == 7 | *autorevision* *-t* [*-o* [*-f*] ] [*-e* ] [*-U*] [*-C* ] [*-q*] 8 | 9 | *autorevision* *-s* [*-o* [*-f*] ] [*-e* ] [*-U*] [*-C* ] [*-q*] 10 | 11 | *autorevision* *-V* 12 | 13 | == DESCRIPTION == 14 | Extracts metadata about the head revision from your repository. 15 | 16 | This program is meant to be used by project build systems to extract 17 | properties that can be used in version strings. It can emit source 18 | files containing variable and macro definitions suitable for use with 19 | C, C++, Java, Mac info.plist, sh, Python, Perl and many other types of 20 | files (see below for the full list). 21 | 22 | The generated source is written to the standard output. 23 | 24 | This program can normally be called from anywhere within a repository 25 | copy. Under bzr the copy must be of a branch, not a full multibranch 26 | repository. Under Subversion it must be called under a repository 27 | checkout, not the repository itself. 28 | 29 | If you specify a cache file, then when *autorevision* is run where no 30 | repository can be recognized, the values from the cache file will be 31 | used instead. If a repository can be recognized, the cache is 32 | rewritten. This feature makes it possible for your build to run from 33 | an unpacked tarball that includes the cache file. 34 | 35 | === Valid Repository Types === 36 | 37 | *Git*: A version greater than 1.7.2.3 is recommended. 38 | 39 | *Mercurial*: A version greater than 1.6 is recommended. 40 | 41 | *Subversion*: Any production version. 42 | 43 | *Bazaar*: Any production version. 44 | 45 | === Valid Output Types === 46 | 47 | *clojure*:: 48 | A clojure source file setting clojure variables. 49 | 50 | *c*:: 51 | A C/C++ source file. + 52 | `autorevision_declr.h` in the contribs dir is provided for use with 53 | this output. 54 | 55 | *cmake*:: 56 | A cmake script file. 57 | 58 | *csharp*:: 59 | C# file with Autorevision class 60 | 61 | *h*:: 62 | A header file suitable for C/C++. 63 | 64 | *hpp*:: 65 | Alternate C++ header file with namespace. Namespace is assigned 66 | from VCS_BASENAME. 67 | 68 | *ini*:: 69 | A ini source file setting ini variables. 70 | 71 | *java*:: 72 | A Java source file setting class properties. 73 | 74 | *javaprop*:: 75 | A Java properties file (like ini); useful when META-INF is readable in 76 | Java. 77 | 78 | *js*:: 79 | A javascript source file setting javascript variables. 80 | 81 | *json*:: 82 | A JSON format file. 83 | 84 | *lua*:: 85 | A lua source file setting lua variables. 86 | 87 | *m4*:: 88 | An m4 source file defining m4 macros. 89 | 90 | *matlab*:: 91 | Matlab output. 92 | 93 | *octave*:: 94 | Octave output. 95 | 96 | *php*:: 97 | A PHP source file setting PHP variables. 98 | 99 | *pl*:: 100 | A Perl source file setting Perl variables (*`perl`* is an acceptable 101 | synonym). 102 | 103 | *py*:: 104 | A Python source file setting Python variables (*`python`* is an 105 | acceptable synonym). 106 | 107 | *rpm*:: 108 | A RPM spec file format setting spec file macros. 109 | 110 | *scheme*:: 111 | A scheme source file setting scheme variables. 112 | 113 | *sed*:: 114 | A sed script that replaces symbol names enclosed in @ symbols. 115 | It uses the | character as a separator in the sed commands. 116 | You can run it using `sed -f script.sed file-to-edit`. 117 | 118 | *sh*:: 119 | A text file suitable for including from a bash script. Will work with 120 | Ruby. 121 | 122 | *swift*:: 123 | A Swift source file setting Swift global constants. + 124 | Unless set *VCS_EXTRA* and any symbols that are missing because of 125 | repository support are set to `nil`. 126 | 127 | *tex*:: 128 | A TeX source file defining TeX macros. Note that the symbols are 129 | given different names since the underscore has a special meaning in 130 | TeX. For example, VCS_SHORT_HASH is renamed to \vcsShortHash. 131 | 132 | *xcode*:: 133 | A header like output for use with xcode to populate info.plist strings. 134 | 135 | === Valid Symbol Names === 136 | 137 | *VCS_TYPE*:: 138 | The repository type - "git", "hg", "bzr", or "svn". 139 | 140 | *VCS_BASENAME*:: 141 | The basename of the directory root. For most VCSes this will simply 142 | be the basename of the repository root directory. For Subversion, 143 | *autorevision* will attempt to navigate up though trunk, branches, and 144 | tags directories to find the actual root. 145 | 146 | *VCS_NUM*:: 147 | A count of revisions between the current one and the initial 148 | one; useful for reporting build numbers. 149 | 150 | *VCS_UUID*:: 151 | A universally unique identifier, generated from the root commit in git 152 | and hg; for svn it uses the supplied UUID. + 153 | For git we choose the oldest commit if there is more than one. + 154 | Not currently implemented for bzr. 155 | 156 | *VCS_DATE*:: 157 | The date of the most recent commit in true ISO-8601/RFC3339 158 | format, including seconds. 159 | 160 | *VCS_BRANCH*:: 161 | The name of the branch of the commit graph that was selected when 162 | autoversion was run. + 163 | Under git, this will normally be the shortname of the current branch 164 | (the asterisked line in the output of "git branch") except that 165 | when the branch doesn't have a shortname it will be a full 166 | refspec. + 167 | Under hg the feature that is called 'branches' is actually a sort of 168 | graph coloring (multiple heads can have the same branch name) so this 169 | symbol is filled with the current bookmark if it exists, with the 170 | current branch name as a fallback. + 171 | Under Subversion this will normally be either 'trunk' or the basename 172 | of some branch or tag subdirectory, depending on where *autoversion* 173 | was run. + 174 | Under bzr, this is the nick of the branch you are on. 175 | 176 | *VCS_TAG*:: 177 | The name of the most recent tag ancestral to the current commit. + 178 | Empty under Subversion. 179 | 180 | *VCS_TAG_OPENPGP*:: 181 | The fingerprint OpenPGP of the key that that signed the current tag. + 182 | Blank if the current tag is not signed or if no tags exist. + 183 | Currently only implemented for git. 184 | 185 | *VCS_TICK*:: 186 | A count of commits since most recent tag ancestral to the current 187 | commit or an alias of *VCS_NUM* if there are no prior tags. + 188 | Empty under Subversion. 189 | 190 | *VCS_EXTRA*:: 191 | A symbol set aside specifically to be set by the user through the 192 | environment or via scripts. + 193 | Additionally, the name of this symbol may be customized as well. ('See *-e* for more info.') 194 | 195 | *VCS_ACTION_STAMP*:: 196 | An "action stamp" consists of an RFC3339 timestamp in Zulu time, 197 | followed by an exclamation point, followed by an RFC822 address 198 | (technically, an "addr-spec" as defined in 6.1). + 199 | For svn the second part is simply the author name. + 200 | Not currently implemented for bzr. 201 | 202 | *VCS_FULL_HASH*:: 203 | A full unique identifier for the current revision. 204 | 205 | *VCS_COMMIT_OPENPGP*:: 206 | The fingerprint OpenPGP of the key that that signed the current revision. + 207 | Blank if the current revision is not signed. + 208 | Currently only implemented for git. 209 | 210 | *VCS_SHORT_HASH*:: 211 | A shortened version of *VCS_FULL_HASH*, but *VCS_FULL_HASH* if it 212 | cannot be shortened. 213 | 214 | *VCS_WC_MODIFIED*:: 215 | Set to `1` if the current working directory has been modified and `0` 216 | if not. If the output language has native Boolean literals, true will 217 | mean modified and false unmodified. The C/C++ output is left as 218 | numeric so the preprocessor can test it. + 219 | 'Untracked files are not ignored; see *`-U`* for details.' 220 | 221 | == OPTIONS == 222 | 223 | *-t* '':: 224 | Sets the output type. It is required unless *`-s`* is specified; both 225 | *`-t`* and *`-s`* cannot be used in the same invocation. 226 | 227 | *-s* '':: 228 | Changes the reporting behavior; instead of emitting a symbol file to 229 | stdout, only the value of that individual symbol will be reported. It 230 | is required unless *`-t`* is specified; both *`-t`* and *`-s`* cannot 231 | be used in the same invocation. 232 | 233 | *-o* '':: 234 | Sets the name of the cache file. 235 | 236 | *-e* '':: 237 | Sets the output name of *VCS_EXTRA* + 238 | Defaults to `VCS_EXTRA`. 239 | 240 | *-f*:: 241 | Forces the use of cache data even when in a repo; useful for speeding 242 | up subsequent runs if more than one output format is needed. 243 | 244 | *-U*:: 245 | Causes untracked files to be checked when determining if the 246 | working copy is modified 'for Subversion only'. While this is the 247 | default behavior for all other repository types, it is off by default 248 | for Subversion because of speed concerns. 249 | 250 | *-C* '':: 251 | Change working directory to given path. This allows autorevision to extract 252 | metadata from repositories found at a specific path to support VPATH or 253 | out-of-source builds. 254 | 255 | *-q*:: 256 | Silence warnings. 257 | 258 | *-V*:: 259 | Emits the autorevision version and exits. 260 | 261 | == BUGS == 262 | The bzr extractor is not very well tested. 263 | 264 | When a git repo is actually a git-svn remote, this tool tries to do 265 | the right thing and return a Subversion revision. The bug is that the 266 | detector code for this case is somewhat unreliable; you will get the 267 | hash instead if your configuration doesn't use svn-remote.svn.url. 268 | 269 | Nested repositories, particularly repositories of different types, 270 | _may_ result in incorrect and unintended behavior. 271 | 272 | Unpacking a tarball into a repository _will_ result in incorrect and 273 | unintended behavior. 274 | 275 | == Notes == 276 | Development of autorevision is carried out at 277 | https://github.com/Autorevision/autorevision 278 | 279 | HTML rendered docs and usage examples can be found at 280 | https://autorevision.github.io/ 281 | 282 | == AUTHORS == 283 | 284 | dak180 : concept, bash/C/C++/XCode/PHP/ini 285 | support, git and hg extraction. + 286 | Eric S. Raymond : Python/Perl/lua/m4 support, svn and 287 | bzr extraction, git-svn support, CLI design, man page. + 288 | See AUTHORS.txt for a full list in order of number of contributions. 289 | -------------------------------------------------------------------------------- /autorevision.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Copyright (c) 2012 - 2023 dak180 and contributors. See 4 | # https://opensource.org/licenses/mit-license.php or the included 5 | # COPYING.md for licence terms. 6 | # 7 | # autorevision - extracts metadata about the head version from your 8 | # repository. 9 | 10 | # shellcheck disable=SC2154,SC2236,SC2030,SC2031 11 | 12 | # Usage message. 13 | arUsage() { 14 | tee >&2 << EOF 15 | usage: autorevision {-t output-type | -s symbol} [-o cache-file [-f] ] [-e name] [-U] [-C path] [-q] [-V] 16 | Options include: 17 | -t output-type = specify output type 18 | -s symbol = specify symbol output 19 | -o cache-file = specify cache file location 20 | -f = force the use of cache data 21 | -e name = set a different output name for VCS_EXTRA 22 | -U = check for untracked files in svn 23 | -C path = change to path before working on repository 24 | -q = Silence warnings 25 | -V = emit version and exit 26 | -? = help message 27 | 28 | The following are valid output types: 29 | c = C/C++ file 30 | clojure = clojure file 31 | cmake = CMake script file 32 | csharp = CSharp properties file 33 | h = Header for use with c/c++ 34 | hpp = Alternate C++ header strings with namespace 35 | ini = INI file 36 | java = Java file 37 | javaprop = Java properties file 38 | js = javascript file 39 | json = JSON file 40 | lua = Lua file 41 | m4 = m4 file 42 | matlab = matlab file 43 | octave = octave file 44 | php = PHP file 45 | pl = Perl file 46 | py = Python file 47 | rpm = rpm file 48 | scheme = scheme file 49 | sed = sed script 50 | sh = Bash sytax 51 | swift = Swift file 52 | tex = (La)TeX file 53 | xcode = Header useful for populating info.plist files 54 | 55 | 56 | The following are valid symbols: 57 | VCS_TYPE 58 | VCS_BASENAME 59 | VCS_UUID 60 | VCS_NUM 61 | VCS_DATE 62 | VCS_BRANCH 63 | VCS_TAG 64 | VCS_TAG_OPENPGP 65 | VCS_TICK 66 | VCS_EXTRA 67 | VCS_FULL_HASH 68 | VCS_COMMIT_OPENPGP 69 | VCS_SHORT_HASH 70 | VCS_WC_MODIFIED 71 | VCS_ACTION_STAMP 72 | EOF 73 | exit 1 74 | } 75 | 76 | # Config 77 | ARVERSION="&&ARVERSION&&" 78 | while getopts ":t:o:s:e:C:VfqU" OPTION; do 79 | case "${OPTION}" in 80 | t) 81 | AFILETYPE="${OPTARG}" 82 | ;; 83 | o) 84 | CACHEFILE="${OPTARG}" 85 | ;; 86 | f) 87 | CACHEFORCE="1" 88 | ;; 89 | s) 90 | VAROUT="${OPTARG}" 91 | ;; 92 | e) 93 | EXTRA_NAME="${OPTARG}" 94 | ;; 95 | C) 96 | CHANGE_TO_DIR="${OPTARG}" 97 | ;; 98 | U) 99 | UNTRACKEDFILES="1" 100 | ;; 101 | q) 102 | WARNHIDE="1" 103 | ;; 104 | V) 105 | echo "autorevision ${ARVERSION}" 106 | exit 0 107 | ;; 108 | ?) 109 | # If an unknown flag is used (or -?): 110 | arUsage 111 | ;; 112 | esac 113 | done 114 | 115 | if [ ! -z "${VAROUT}" ] && [ ! -z "${AFILETYPE}" ]; then 116 | # If both -s and -t are specified: 117 | echo "error: Improper argument combination." 1>&2 118 | exit 1 119 | elif [ -z "${VAROUT}" ] && [ -z "${AFILETYPE}" ]; then 120 | # If neither -s or -t are specified: 121 | arUsage 122 | elif [ -z "${CACHEFILE}" ] && [ "${CACHEFORCE}" = "1" ]; then 123 | # If -f is specified without -o: 124 | arUsage 125 | elif [ ! -f "${CACHEFILE}" ] && [ "${CACHEFORCE}" = "1" ]; then 126 | # If we are forced to use the cache but it does not exist. 127 | echo "error: Cache forced but no cache found." 1>&2 128 | exit 1 129 | fi 130 | 131 | # Only use the local keyword if it is there (ksh we are looking at 132 | # you). 133 | 134 | if [ "$(command -v local 2> /dev/null)" = "local" ]; then 135 | LOCAL="local" 136 | elif [ "$(command -v typeset 2> /dev/null)" = "typeset" ]; then 137 | LOCAL="typeset" 138 | else 139 | LOCAL="" 140 | fi 141 | 142 | #check if needed software is installed 143 | commands="sed 144 | cut 145 | grep 146 | wc 147 | tail 148 | basename 149 | dirname 150 | tee 151 | getopts 152 | tr 153 | cmp" 154 | 155 | for command in ${commands}; do 156 | if ! command -v "${command}" > /dev/null 2>&1; then 157 | echo "${command} is missing, please install" 158 | exit 100 159 | fi 160 | done 161 | 162 | # Make sure that the path we are given is one we can source 163 | # (dash, we are looking at you). 164 | if [ ! -z "${CACHEFILE}" ] && ! echo "${CACHEFILE}" | grep -q '^\.*/'; then 165 | CACHEFILE="./${CACHEFILE}" 166 | fi 167 | 168 | GENERATED_HEADER="Generated by autorevision - do not hand-hack!" 169 | : "${EXTRA_NAME:="VCS_EXTRA"}" 170 | : "${WARNHIDE:="0"}" 171 | 172 | # Functions to extract data from different repo types. 173 | # For git repos 174 | # shellcheck disable=SC2039,SC2164,SC2155 175 | gitRepo() { 176 | ${LOCAL} oldPath="$(pwd)" 177 | 178 | cd "$(git rev-parse --show-toplevel)" 179 | 180 | VCS_TYPE="git" 181 | 182 | VCS_BASENAME="$(basename "$(pwd)")" 183 | 184 | ${LOCAL} currentRev="$(git rev-parse HEAD)" 185 | 186 | VCS_UUID="$(git rev-list --max-parents=0 --date-order --reverse "${currentRev}" 2>/dev/null | sed -n 1p)" 187 | if [ -z "${VCS_UUID}" ]; then 188 | VCS_UUID="$(git rev-list --topo-order "${currentRev}" | tail -n 1)" 189 | fi 190 | 191 | # Is the working copy clean? 192 | test -z "$(git status --untracked-files=normal --porcelain)" 193 | VCS_WC_MODIFIED="${?}" 194 | 195 | # Enumeration of changesets 196 | VCS_NUM="$(git rev-list --count "${currentRev}" 2>/dev/null)" 197 | if [ -z "${VCS_NUM}" ]; then 198 | if [ ! "${WARNHIDE}" = "1" ]; then 199 | 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 200 | fi 201 | VCS_NUM="$(git rev-list HEAD | wc -l)" 202 | fi 203 | 204 | # This may be a git-svn remote. If so, report the Subversion revision. 205 | if [ -z "$(git config svn-remote.svn.url 2>/dev/null)" ]; then 206 | # The full revision hash 207 | VCS_FULL_HASH="$(git rev-parse "${currentRev}")" 208 | 209 | # The short hash 210 | VCS_SHORT_HASH="$(git rev-parse --short "${currentRev}")" 211 | else 212 | # The git-svn revision number 213 | VCS_FULL_HASH="$(git svn find-rev "${currentRev}")" 214 | VCS_SHORT_HASH="${VCS_FULL_HASH}" 215 | fi 216 | 217 | # Get the current revision's signing key. 218 | VCS_COMMIT_OPENPGP="$(git verify-commit --raw "${currentRev}" 2>&1 | grep "VALIDSIG" | cut -d ' ' -f 12)" 219 | 220 | # Current branch 221 | 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/::')" 222 | 223 | # Cache the description 224 | ${LOCAL} DESCRIPTION="$(git describe --long --tags "${currentRev}" 2>/dev/null)" 225 | 226 | # Current or last tag ancestor (empty if no tags) 227 | VCS_TAG="$(echo "${DESCRIPTION}" | sed -e "s:-g${VCS_SHORT_HASH}\$::" -e 's:-[0-9]*$::')" 228 | 229 | if [ ! -z "${VCS_TAG}" ]; then 230 | # Determine if the tag is annotated. 231 | ${LOCAL} tagType="$(git for-each-ref --format='%(objecttype)' "$(git rev-parse --symbolic-full-name --verify "${VCS_TAG}")")" 232 | if [ ! "${tagType}" = "tag" ]; then 233 | # Let the user know if the current tag is not annotated. 234 | if [ ! "${WARNHIDE}" = "1" ]; then 235 | 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 236 | fi 237 | else 238 | # You cannot have a signed tag that is not annotated. 239 | VCS_TAG_OPENPGP="$(git verify-tag --raw "${VCS_TAG}" 2>&1 | grep "VALIDSIG" | cut -d ' ' -f 12)" 240 | fi 241 | fi 242 | 243 | # Distance to last tag or an alias of VCS_NUM if there is no tag 244 | if [ ! -z "${DESCRIPTION}" ]; then 245 | VCS_TICK="$(echo "${DESCRIPTION}" | sed -e "s:${VCS_TAG}-::" -e "s:-g${VCS_SHORT_HASH}::")" 246 | else 247 | VCS_TICK="${VCS_NUM}" 248 | fi 249 | 250 | # Date of the current commit 251 | VCS_DATE="$(TZ=UTC git show -s --date=iso-strict-local --pretty=format:%cd "${currentRev}" 2>/dev/null | sed -e 's|+00:00|Z|')" 252 | if [ -z "${VCS_DATE}" ]; then 253 | if [ ! "${WARNHIDE}" = "1" ]; then 254 | echo "warning: Action stamps require git version 2.7+." 1>&2 255 | fi 256 | VCS_DATE="$(git log -1 --pretty=format:%ci "${currentRev}" | sed -e 's: :T:' -e 's: ::' -e 's|+00:00|Z|')" 257 | ${LOCAL} ASdis="1" 258 | fi 259 | 260 | # Action Stamp 261 | if [ -z "${ASdis}" ]; then 262 | VCS_ACTION_STAMP="${VCS_DATE}!$(git show -s --pretty=format:%cE "${currentRev}")" 263 | else 264 | VCS_ACTION_STAMP="" 265 | fi 266 | 267 | cd "${oldPath}" 268 | } 269 | 270 | # For hg repos 271 | # shellcheck disable=SC2039,SC2164 272 | hgRepo() { 273 | ${LOCAL} oldPath="$(pwd)" 274 | 275 | cd "$(hg root)" 276 | 277 | VCS_TYPE="hg" 278 | 279 | VCS_BASENAME="$(basename "$(pwd)")" 280 | 281 | VCS_UUID="$(hg log -r "0" -l 1 --template '{node}\n')" 282 | 283 | # Is the working copy clean? 284 | test -z "$(hg status -duram)" 285 | VCS_WC_MODIFIED="${?}" 286 | 287 | # Enumeration of changesets 288 | VCS_NUM="$(hg id -n | tr -d '+')" 289 | 290 | # The full revision hash 291 | VCS_FULL_HASH="$(hg log -r "${VCS_NUM}" -l 1 --template '{node}\n')" 292 | 293 | # The short hash 294 | VCS_SHORT_HASH="$(hg id -i | tr -d '+')" 295 | 296 | # Current bookmark (bookmarks are roughly equivalent to git's branches) 297 | # or branch if no bookmark 298 | VCS_BRANCH="$(hg id -B | cut -d ' ' -f 1)" 299 | # Fall back to the branch if there are no bookmarks 300 | if [ -z "${VCS_BRANCH}" ]; then 301 | VCS_BRANCH="$(hg id -b)" 302 | fi 303 | 304 | # Current or last tag ancestor (excluding auto tags, empty if no tags) 305 | 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)" 306 | 307 | # Distance to last tag or an alias of VCS_NUM if there is no tag 308 | if [ ! -z "${VCS_TAG}" ]; then 309 | VCS_TICK="$(hg log -r "${VCS_NUM}" -l 1 --template '{latesttagdistance}\n' 2>/dev/null)" 310 | else 311 | VCS_TICK="${VCS_NUM}" 312 | fi 313 | 314 | # Date of the current commit 315 | 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|')" 316 | 317 | # Action Stamp 318 | 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)" 319 | 320 | cd "${oldPath}" 321 | } 322 | 323 | # For bzr repos 324 | # shellcheck disable=SC2039,SC2164 325 | bzrRepo() { 326 | ${LOCAL} oldPath="$(pwd)" 327 | 328 | cd "$(bzr root)" 329 | 330 | VCS_TYPE="bzr" 331 | 332 | VCS_BASENAME="$(basename "$(pwd)")" 333 | 334 | # Currently unimplemented because more investigation is needed. 335 | VCS_UUID="" 336 | 337 | # Is the working copy clean? 338 | bzr version-info --custom --template='{clean}\n' | grep -q '1' 339 | VCS_WC_MODIFIED="${?}" 340 | 341 | # Enumeration of changesets 342 | VCS_NUM="$(bzr revno)" 343 | 344 | # The full revision hash 345 | VCS_FULL_HASH="$(bzr version-info --custom --template='{revision_id}\n')" 346 | 347 | # The short hash 348 | VCS_SHORT_HASH="${VCS_NUM}" 349 | 350 | # Nick of the current branch 351 | VCS_BRANCH="$(bzr nick)" 352 | 353 | # Current or last tag ancestor (excluding auto tags, empty if no tags) 354 | VCS_TAG="$(bzr tags --sort=time | sed '/?$/d' | tail -n1 | cut -d ' ' -f1)" 355 | 356 | # Distance to last tag or an alias of VCS_NUM if there is no tag 357 | if [ ! -z "${VCS_TAG}" ]; then 358 | VCS_TICK="$(bzr log --line -r "tag:${VCS_TAG}.." | tail -n +2 | wc -l | sed -e 's:^ *::')" 359 | else 360 | VCS_TICK="${VCS_NUM}" 361 | fi 362 | 363 | # Date of the current commit 364 | VCS_DATE="$(bzr version-info --custom --template='{date}\n' | sed -e 's: :T:' -e 's: ::')" 365 | 366 | # Action Stamp 367 | # Currently unimplemented because more investigation is needed. 368 | VCS_ACTION_STAMP="" 369 | 370 | cd "${oldPath}" 371 | } 372 | 373 | # For svn repos 374 | # shellcheck disable=SC2039,SC2164,SC2155 375 | svnRepo() { 376 | ${LOCAL} oldPath="$(pwd)" 377 | 378 | VCS_TYPE="svn" 379 | 380 | case "$(pwd)" in 381 | /*trunk*|/*branches*|/*tags*) 382 | ${LOCAL} fn="$(pwd)" 383 | while [ "$(basename "${fn}")" != 'trunk' ] && [ "$(basename "${fn}")" != 'branches' ] && [ "$(basename "${fn}")" != 'tags' ] && [ "$(basename "${fn}")" != '/' ]; do 384 | ${LOCAL} fn="$(dirname "${fn}")" 385 | done 386 | ${LOCAL} fn="$(dirname "${fn}")" 387 | if [ "${fn}" = '/' ]; then 388 | VCS_BASENAME="$(basename "$(pwd)")" 389 | else 390 | VCS_BASENAME="$(basename "${fn}")" 391 | fi 392 | ;; 393 | *) VCS_BASENAME="$(basename "$(pwd)")" ;; 394 | esac 395 | 396 | VCS_UUID="$(svn info --xml | sed -n -e 's:::' -e 's:::p')" 397 | 398 | # Cache svnversion output 399 | ${LOCAL} SVNVERSION="$(svnversion)" 400 | 401 | # Is the working copy clean? 402 | echo "${SVNVERSION}" | grep -q "M" 403 | case "${?}" in 404 | 0) 405 | VCS_WC_MODIFIED="1" 406 | ;; 407 | 1) 408 | if [ ! -z "${UNTRACKEDFILES}" ]; then 409 | # `svnversion` does not detect untracked files and `svn status` is really slow, so only run it if we really have to. 410 | if [ -z "$(svn status)" ]; then 411 | VCS_WC_MODIFIED="0" 412 | else 413 | VCS_WC_MODIFIED="1" 414 | fi 415 | else 416 | VCS_WC_MODIFIED="0" 417 | fi 418 | ;; 419 | esac 420 | 421 | # Enumeration of changesets 422 | VCS_NUM="$(echo "${SVNVERSION}" | cut -d : -f 1 | sed -e 's:M::' -e 's:S::' -e 's:P::')" 423 | 424 | # The full revision hash 425 | VCS_FULL_HASH="${SVNVERSION}" 426 | 427 | # The short hash 428 | VCS_SHORT_HASH="${VCS_NUM}" 429 | 430 | # Current branch 431 | case "$(pwd)" in 432 | /*trunk*|/*branches*|/*tags*) 433 | ${LOCAL} lastbase="" 434 | ${LOCAL} fn="$(pwd)" 435 | while : 436 | do 437 | base="$(basename "${fn}")" 438 | if [ "${base}" = 'trunk' ]; then 439 | VCS_BRANCH='trunk' 440 | break 441 | elif [ "${base}" = 'branches' ] || [ "${base}" = 'tags' ]; then 442 | VCS_BRANCH="${lastbase}" 443 | break 444 | elif [ "${base}" = '/' ]; then 445 | VCS_BRANCH="" 446 | break 447 | fi 448 | ${LOCAL} lastbase="${base}" 449 | ${LOCAL} fn="$(dirname "${fn}")" 450 | done 451 | ;; 452 | *) VCS_BRANCH="" ;; 453 | esac 454 | 455 | # Current or last tag ancestor (empty if no tags). But "current 456 | # tag" can't be extracted reliably because Subversion doesn't 457 | # have tags the way other VCSes do. 458 | VCS_TAG="" 459 | VCS_TICK="" 460 | 461 | # Date of the current commit 462 | VCS_DATE="$(svn info --xml | sed -n -e 's:::' -e 's:::p')" 463 | 464 | # Action Stamp 465 | VCS_ACTION_STAMP="${VCS_DATE}!$(svn log --xml -l 1 -r "${VCS_SHORT_HASH}" | sed -n -e 's:::' -e 's:::p')" 466 | 467 | cd "${oldPath}" 468 | } 469 | 470 | 471 | # Functions to output data in different formats. 472 | # For bash output 473 | # First in list because it is used by autorevision 474 | shOutput() { 475 | tee << EOF 476 | # ${GENERATED_HEADER} 477 | 478 | VCS_TYPE="${VCS_TYPE}" 479 | VCS_BASENAME="${VCS_BASENAME}" 480 | VCS_UUID="${VCS_UUID}" 481 | VCS_NUM="${VCS_NUM}" 482 | VCS_DATE="${VCS_DATE}" 483 | VCS_BRANCH="${VCS_BRANCH}" 484 | VCS_TAG="${VCS_TAG}" 485 | VCS_TAG_OPENPGP="${VCS_TAG_OPENPGP}" 486 | VCS_TICK="${VCS_TICK}" 487 | ${EXTRA_NAME}="${VCS_EXTRA}" 488 | 489 | VCS_ACTION_STAMP="${VCS_ACTION_STAMP}" 490 | VCS_FULL_HASH="${VCS_FULL_HASH}" 491 | VCS_COMMIT_OPENPGP="${VCS_COMMIT_OPENPGP}" 492 | VCS_SHORT_HASH="${VCS_SHORT_HASH}" 493 | 494 | VCS_WC_MODIFIED="${VCS_WC_MODIFIED}" 495 | 496 | # end 497 | EOF 498 | } 499 | 500 | # For source C output 501 | cOutput() { 502 | tee << EOF 503 | /* ${GENERATED_HEADER} */ 504 | 505 | const char *VCS_TYPE = "${VCS_TYPE}"; 506 | const char *VCS_BASENAME = "${VCS_BASENAME}"; 507 | const char *VCS_UUID = "${VCS_UUID}"; 508 | const int VCS_NUM = ${VCS_NUM}; 509 | const char *VCS_DATE = "${VCS_DATE}"; 510 | const char *VCS_BRANCH = "${VCS_BRANCH}"; 511 | const char *VCS_TAG = "${VCS_TAG}"; 512 | const char *VCS_TAG_OPENPGP = "${VCS_TAG_OPENPGP}"; 513 | const int VCS_TICK = ${VCS_TICK}; 514 | const char *${EXTRA_NAME} = "${VCS_EXTRA}"; 515 | 516 | const char *VCS_ACTION_STAMP = "${VCS_ACTION_STAMP}"; 517 | const char *VCS_FULL_HASH = "${VCS_FULL_HASH}"; 518 | const char *VCS_COMMIT_OPENPGP = "${VCS_COMMIT_OPENPGP}"; 519 | const char *VCS_SHORT_HASH = "${VCS_SHORT_HASH}"; 520 | 521 | const int VCS_WC_MODIFIED = ${VCS_WC_MODIFIED}; 522 | 523 | /* end */ 524 | EOF 525 | } 526 | 527 | # For Cmake output 528 | cmakeOutput() { 529 | tee << EOF 530 | # ${GENERATED_HEADER} 531 | 532 | set(VCS_TYPE ${VCS_TYPE}) 533 | set(VCS_BASENAME ${VCS_BASENAME}) 534 | set(VCS_UUID ${VCS_UUID}) 535 | set(VCS_NUM ${VCS_NUM}) 536 | set(VCS_DATE ${VCS_DATE}) 537 | set(VCS_BRANCH ${VCS_BRANCH}) 538 | set(VCS_TAG ${VCS_TAG}) 539 | set(VCS_TAG_OPENPGP ${VCS_TAG_OPENPGP}) 540 | set(VCS_TICK ${VCS_TICK}) 541 | set(${EXTRA_NAME} ${VCS_EXTRA}) 542 | 543 | set(VCS_ACTION_STAMP ${VCS_ACTION_STAMP}) 544 | set(VCS_FULL_HASH ${VCS_FULL_HASH}) 545 | set(VCS_COMMIT_OPENPGP ${VCS_COMMIT_OPENPGP}) 546 | set(VCS_SHORT_HASH ${VCS_SHORT_HASH}) 547 | 548 | set(VCS_WC_MODIFIED ${VCS_WC_MODIFIED}) 549 | 550 | # end 551 | EOF 552 | } 553 | 554 | # For header output 555 | hOutput() { 556 | tee << EOF 557 | /* ${GENERATED_HEADER} */ 558 | #ifndef AUTOREVISION_H 559 | #define AUTOREVISION_H 560 | 561 | #define VCS_TYPE "${VCS_TYPE}" 562 | #define VCS_BASENAME "${VCS_BASENAME}" 563 | #define VCS_UUID "${VCS_UUID}" 564 | #define VCS_NUM ${VCS_NUM} 565 | #define VCS_DATE "${VCS_DATE}" 566 | #define VCS_BRANCH "${VCS_BRANCH}" 567 | #define VCS_TAG "${VCS_TAG}" 568 | #define VCS_TAG_OPENPGP "${VCS_TAG_OPENPGP}" 569 | #define VCS_TICK ${VCS_TICK} 570 | #define ${EXTRA_NAME} "${VCS_EXTRA}" 571 | 572 | #define VCS_ACTION_STAMP "${VCS_ACTION_STAMP}" 573 | #define VCS_FULL_HASH "${VCS_FULL_HASH}" 574 | #define VCS_COMMIT_OPENPGP "${VCS_COMMIT_OPENPGP}" 575 | #define VCS_SHORT_HASH "${VCS_SHORT_HASH}" 576 | 577 | #define VCS_WC_MODIFIED ${VCS_WC_MODIFIED} 578 | 579 | #endif 580 | 581 | /* end */ 582 | EOF 583 | } 584 | 585 | # A header output for use with xcode to populate info.plist strings 586 | xcodeOutput() { 587 | tee << EOF 588 | /* ${GENERATED_HEADER} */ 589 | #ifndef AUTOREVISION_H 590 | #define AUTOREVISION_H 591 | 592 | #define VCS_TYPE ${VCS_TYPE} 593 | #define VCS_BASENAME ${VCS_BASENAME} 594 | #define VCS_UUID ${VCS_UUID} 595 | #define VCS_NUM ${VCS_NUM} 596 | #define VCS_DATE ${VCS_DATE} 597 | #define VCS_BRANCH ${VCS_BRANCH} 598 | #define VCS_TAG ${VCS_TAG} 599 | #define VCS_TAG_OPENPGP ${VCS_TAG_OPENPGP} 600 | #define VCS_TICK ${VCS_TICK} 601 | #define ${EXTRA_NAME} ${VCS_EXTRA} 602 | 603 | #define VCS_ACTION_STAMP ${VCS_ACTION_STAMP} 604 | #define VCS_FULL_HASH ${VCS_FULL_HASH} 605 | #define VCS_COMMIT_OPENPGP ${VCS_COMMIT_OPENPGP} 606 | #define VCS_SHORT_HASH ${VCS_SHORT_HASH} 607 | 608 | #define VCS_WC_MODIFIED ${VCS_WC_MODIFIED} 609 | 610 | #endif 611 | 612 | /* end */ 613 | EOF 614 | } 615 | 616 | # For Swift output 617 | swiftOutput() { 618 | case "${VCS_WC_MODIFIED}" in 619 | 0) VCS_WC_MODIFIED="false" ;; 620 | 1) VCS_WC_MODIFIED="true" ;; 621 | esac 622 | # For values that may not exist depending on the type of repo we 623 | # have read from, set them to `nil` when they are empty. 624 | if [ -z "${VCS_UUID}" ]; then 625 | VCS_UUID="nil" 626 | else 627 | VCS_UUID="\"${VCS_UUID}\"" 628 | fi 629 | if [ -z "${VCS_TAG}" ]; then 630 | VCS_TAG="nil" 631 | else 632 | VCS_TAG="\"${VCS_TAG}\"" 633 | fi 634 | if [ -z "${VCS_TAG_OPENPGP}" ]; then 635 | VCS_TAG_OPENPGP="nil" 636 | else 637 | VCS_TAG_OPENPGP="\"${VCS_TAG_OPENPGP}\"" 638 | fi 639 | : "${VCS_TICK:="nil"}" 640 | if [ -z "${VCS_EXTRA}" ]; then 641 | VCS_EXTRA="nil" 642 | else 643 | VCS_EXTRA="\"${VCS_EXTRA}\"" 644 | fi 645 | if [ -z "${VCS_ACTION_STAMP}" ]; then 646 | VCS_ACTION_STAMP="nil" 647 | else 648 | VCS_ACTION_STAMP="\"${VCS_ACTION_STAMP}\"" 649 | fi 650 | if [ -z "${VCS_COMMIT_OPENPGP}" ]; then 651 | VCS_COMMIT_OPENPGP="nil" 652 | else 653 | VCS_COMMIT_OPENPGP="\"${VCS_COMMIT_OPENPGP}\"" 654 | fi 655 | tee << EOF 656 | /* ${GENERATED_HEADER} */ 657 | 658 | let VCS_TYPE = "${VCS_TYPE}" 659 | let VCS_BASENAME = "${VCS_BASENAME}" 660 | let VCS_UUID: String? = ${VCS_UUID} 661 | let VCS_NUM: Int = ${VCS_NUM} 662 | let VCS_DATE = "${VCS_DATE}" 663 | let VCS_BRANCH: String = "${VCS_BRANCH}" 664 | let VCS_TAG: String? = ${VCS_TAG} 665 | let VCS_TAG_OPENPGP: String? = ${VCS_TAG_OPENPGP} 666 | let VCS_TICK: Int? = ${VCS_TICK} 667 | let ${EXTRA_NAME}: String? = ${VCS_EXTRA} 668 | 669 | let VCS_ACTION_STAMP: String? = ${VCS_ACTION_STAMP} 670 | let VCS_FULL_HASH: String = "${VCS_FULL_HASH}" 671 | let VCS_COMMIT_OPENPGP: String? = ${VCS_COMMIT_OPENPGP} 672 | let VCS_SHORT_HASH: String = "${VCS_SHORT_HASH}" 673 | 674 | let VCS_WC_MODIFIED: Bool = ${VCS_WC_MODIFIED} 675 | 676 | /* end */ 677 | EOF 678 | } 679 | 680 | # For Python output 681 | pyOutput() { 682 | case "${VCS_WC_MODIFIED}" in 683 | 0) VCS_WC_MODIFIED="False" ;; 684 | 1) VCS_WC_MODIFIED="True" ;; 685 | esac 686 | tee << EOF 687 | # ${GENERATED_HEADER} 688 | 689 | VCS_TYPE = "${VCS_TYPE}" 690 | VCS_BASENAME = "${VCS_BASENAME}" 691 | VCS_UUID = "${VCS_UUID}" 692 | VCS_NUM = ${VCS_NUM} 693 | VCS_DATE = "${VCS_DATE}" 694 | VCS_BRANCH = "${VCS_BRANCH}" 695 | VCS_TAG = "${VCS_TAG}" 696 | VCS_TAG_OPENPGP = "${VCS_TAG_OPENPGP}" 697 | VCS_TICK = ${VCS_TICK} 698 | ${EXTRA_NAME} = "${VCS_EXTRA}" 699 | 700 | VCS_ACTION_STAMP = "${VCS_ACTION_STAMP}" 701 | VCS_FULL_HASH = "${VCS_FULL_HASH}" 702 | VCS_COMMIT_OPENPGP = "${VCS_COMMIT_OPENPGP}" 703 | VCS_SHORT_HASH = "${VCS_SHORT_HASH}" 704 | 705 | VCS_WC_MODIFIED = ${VCS_WC_MODIFIED} 706 | 707 | # end 708 | EOF 709 | } 710 | 711 | # For Perl output 712 | plOutput() { 713 | tee << EOF 714 | # ${GENERATED_HEADER} 715 | 716 | \$VCS_TYPE = '${VCS_TYPE}'; 717 | \$VCS_BASENAME = '${VCS_BASENAME}'; 718 | \$VCS_UUID = '${VCS_UUID}'; 719 | \$VCS_NUM = ${VCS_NUM}; 720 | \$VCS_DATE = '${VCS_DATE}'; 721 | \$VCS_BRANCH = '${VCS_BRANCH}'; 722 | \$VCS_TAG = '${VCS_TAG}'; 723 | \$VCS_TAG_OPENPGP = '${VCS_TAG_OPENPGP}'; 724 | \$VCS_TICK = ${VCS_TICK}; 725 | \$${EXTRA_NAME} = '${VCS_EXTRA}'; 726 | 727 | \$VCS_ACTION_STAMP = '${VCS_ACTION_STAMP}'; 728 | \$VCS_FULL_HASH = '${VCS_FULL_HASH}'; 729 | \$VCS_COMMIT_OPENPGP = '${VCS_COMMIT_OPENPGP}'; 730 | \$VCS_SHORT_HASH = '${VCS_SHORT_HASH}'; 731 | 732 | \$VCS_WC_MODIFIED = ${VCS_WC_MODIFIED}; 733 | 734 | # end 735 | 1; 736 | EOF 737 | } 738 | 739 | # For lua output 740 | luaOutput() { 741 | case "${VCS_WC_MODIFIED}" in 742 | 0) VCS_WC_MODIFIED="false" ;; 743 | 1) VCS_WC_MODIFIED="true" ;; 744 | esac 745 | tee << EOF 746 | -- ${GENERATED_HEADER} 747 | 748 | VCS_TYPE = "${VCS_TYPE}" 749 | VCS_BASENAME = "${VCS_BASENAME}" 750 | VCS_UUID = "${VCS_UUID}" 751 | VCS_NUM = ${VCS_NUM} 752 | VCS_DATE = "${VCS_DATE}" 753 | VCS_BRANCH = "${VCS_BRANCH}" 754 | VCS_TAG = "${VCS_TAG}" 755 | VCS_TAG_OPENPGP = "${VCS_TAG_OPENPGP}" 756 | VCS_TICK = ${VCS_TICK} 757 | ${EXTRA_NAME} = "${VCS_EXTRA}" 758 | 759 | VCS_ACTION_STAMP = "${VCS_ACTION_STAMP}" 760 | VCS_FULL_HASH = "${VCS_FULL_HASH}" 761 | VCS_COMMIT_OPENPGP = "${VCS_COMMIT_OPENPGP}" 762 | VCS_SHORT_HASH = "${VCS_SHORT_HASH}" 763 | 764 | VCS_WC_MODIFIED = ${VCS_WC_MODIFIED} 765 | 766 | -- end 767 | EOF 768 | } 769 | 770 | # For php output 771 | phpOutput() { 772 | case "${VCS_WC_MODIFIED}" in 773 | 0) VCS_WC_MODIFIED="false" ;; 774 | 1) VCS_WC_MODIFIED="true" ;; 775 | esac 776 | tee << EOF 777 | "${VCS_TYPE}", 782 | "VCS_BASENAME" => "${VCS_BASENAME}", 783 | "VCS_UUID" => "${VCS_UUID}", 784 | "VCS_NUM" => ${VCS_NUM}, 785 | "VCS_DATE" => "${VCS_DATE}", 786 | "VCS_BRANCH" => "${VCS_BRANCH}", 787 | "VCS_TAG" => "${VCS_TAG}", 788 | "VCS_TAG_OPENPGP" => "${VCS_TAG_OPENPGP}", 789 | "VCS_TICK" => ${VCS_TICK}, 790 | "${EXTRA_NAME}" => "${VCS_EXTRA}", 791 | "VCS_ACTION_STAMP" => "${VCS_ACTION_STAMP}", 792 | "VCS_FULL_HASH" => "${VCS_FULL_HASH}", 793 | "VCS_COMMIT_OPENPGP" => "${VCS_COMMIT_OPENPGP}", 794 | "VCS_SHORT_HASH" => "${VCS_SHORT_HASH}", 795 | "VCS_WC_MODIFIED" => ${VCS_WC_MODIFIED} 796 | ); 797 | 798 | # end 799 | ?> 800 | EOF 801 | } 802 | 803 | # For ini output 804 | iniOutput() { 805 | case "${VCS_WC_MODIFIED}" in 806 | 0) VCS_WC_MODIFIED="false" ;; 807 | 1) VCS_WC_MODIFIED="true" ;; 808 | esac 809 | tee << EOF 810 | ; ${GENERATED_HEADER} 811 | [VCS] 812 | VCS_TYPE = "${VCS_TYPE}" 813 | VCS_BASENAME = "${VCS_BASENAME}" 814 | VCS_UUID = "${VCS_UUID}" 815 | VCS_NUM = ${VCS_NUM} 816 | VCS_DATE = "${VCS_DATE}" 817 | VCS_BRANCH = "${VCS_BRANCH}" 818 | VCS_TAG = "${VCS_TAG}" 819 | VCS_TAG_OPENPGP = "${VCS_TAG_OPENPGP}" 820 | VCS_TICK = ${VCS_TICK} 821 | ${EXTRA_NAME} = "${VCS_EXTRA}" 822 | VCS_ACTION_STAMP = "${VCS_ACTION_STAMP}" 823 | VCS_FULL_HASH = "${VCS_FULL_HASH}" 824 | VCS_COMMIT_OPENPGP = "${VCS_COMMIT_OPENPGP}" 825 | VCS_SHORT_HASH = "${VCS_SHORT_HASH}" 826 | VCS_WC_MODIFIED = ${VCS_WC_MODIFIED} 827 | ; end 828 | EOF 829 | } 830 | 831 | # For javascript output 832 | jsOutput() { 833 | case "${VCS_WC_MODIFIED}" in 834 | 1) VCS_WC_MODIFIED="true" ;; 835 | 0) VCS_WC_MODIFIED="false" ;; 836 | esac 837 | tee << EOF 838 | /** ${GENERATED_HEADER} */ 839 | 840 | var autorevision = { 841 | VCS_TYPE: "${VCS_TYPE}", 842 | VCS_BASENAME: "${VCS_BASENAME}", 843 | VCS_UUID: "${VCS_UUID}", 844 | VCS_NUM: ${VCS_NUM}, 845 | VCS_DATE: "${VCS_DATE}", 846 | VCS_BRANCH: "${VCS_BRANCH}", 847 | VCS_TAG: "${VCS_TAG}", 848 | VCS_TAG_OPENPGP: "${VCS_TAG_OPENPGP}", 849 | VCS_TICK: ${VCS_TICK}, 850 | ${EXTRA_NAME}: "${VCS_EXTRA}", 851 | 852 | VCS_ACTION_STAMP: "${VCS_ACTION_STAMP}", 853 | VCS_FULL_HASH: "${VCS_FULL_HASH}", 854 | VCS_COMMIT_OPENPGP: "${VCS_COMMIT_OPENPGP}", 855 | VCS_SHORT_HASH: "${VCS_SHORT_HASH}", 856 | 857 | VCS_WC_MODIFIED: ${VCS_WC_MODIFIED} 858 | }; 859 | 860 | /** Node.js compatibility */ 861 | if (typeof module !== 'undefined') { 862 | module.exports = autorevision; 863 | } 864 | 865 | /** end */ 866 | EOF 867 | } 868 | 869 | # For JSON output 870 | jsonOutput() { 871 | case "${VCS_WC_MODIFIED}" in 872 | 1) VCS_WC_MODIFIED="true" ;; 873 | 0) VCS_WC_MODIFIED="false" ;; 874 | esac 875 | tee << EOF 876 | { 877 | "_comment": "${GENERATED_HEADER}", 878 | "VCS_TYPE": "${VCS_TYPE}", 879 | "VCS_BASENAME": "${VCS_BASENAME}", 880 | "VCS_UUID": "${VCS_UUID}", 881 | "VCS_NUM": ${VCS_NUM}, 882 | "VCS_DATE": "${VCS_DATE}", 883 | "VCS_BRANCH":"${VCS_BRANCH}", 884 | "VCS_TAG": "${VCS_TAG}", 885 | "VCS_TAG_OPENPGP": "${VCS_TAG_OPENPGP}", 886 | "VCS_TICK": ${VCS_TICK}, 887 | "${EXTRA_NAME}": "${VCS_EXTRA}", 888 | 889 | "VCS_ACTION_STAMP": "${VCS_ACTION_STAMP}", 890 | "VCS_FULL_HASH": "${VCS_FULL_HASH}", 891 | "VCS_COMMIT_OPENPGP": "${VCS_COMMIT_OPENPGP}", 892 | "VCS_SHORT_HASH": "${VCS_SHORT_HASH}", 893 | 894 | "VCS_WC_MODIFIED": ${VCS_WC_MODIFIED} 895 | } 896 | EOF 897 | } 898 | 899 | # For Java output 900 | javaOutput() { 901 | case "${VCS_WC_MODIFIED}" in 902 | 1) VCS_WC_MODIFIED="true" ;; 903 | 0) VCS_WC_MODIFIED="false" ;; 904 | esac 905 | tee << EOF 906 | /* ${GENERATED_HEADER} */ 907 | 908 | public class autorevision { 909 | public static final String VCS_TYPE = "${VCS_TYPE}"; 910 | public static final String VCS_BASENAME = "${VCS_BASENAME}"; 911 | public static final String VCS_UUID = "${VCS_UUID}"; 912 | public static final long VCS_NUM = ${VCS_NUM}; 913 | public static final String VCS_DATE = "${VCS_DATE}"; 914 | public static final String VCS_BRANCH = "${VCS_BRANCH}"; 915 | public static final String VCS_TAG = "${VCS_TAG}"; 916 | public static final String VCS_TAG_OPENPGP = "${VCS_TAG_OPENPGP}"; 917 | public static final long VCS_TICK = ${VCS_TICK}; 918 | public static final String ${EXTRA_NAME} = "${VCS_EXTRA}"; 919 | 920 | public static final String VCS_ACTION_STAMP = "${VCS_ACTION_STAMP}"; 921 | public static final String VCS_FULL_HASH = "${VCS_FULL_HASH}"; 922 | public static final String VCS_COMMIT_OPENPGP = "${VCS_COMMIT_OPENPGP}"; 923 | public static final String VCS_SHORT_HASH = "${VCS_SHORT_HASH}"; 924 | 925 | public static final boolean VCS_WC_MODIFIED = ${VCS_WC_MODIFIED}; 926 | } 927 | EOF 928 | } 929 | 930 | csharpOutput() { 931 | case "${VCS_WC_MODIFIED}" in 932 | 1) VCS_WC_MODIFIED="true" ;; 933 | 0) VCS_WC_MODIFIED="false" ;; 934 | esac 935 | if [ "${EXTRA_NAME}" = "VCS_EXTRA" ]; then 936 | EXTRA_NAME="VcsExtra" 937 | fi 938 | tee << EOF 939 | /* ${GENERATED_HEADER} */ 940 | 941 | namespace AutoRevision 942 | { 943 | public class VersionInfo 944 | { 945 | public static string VcsType = "${VCS_TYPE}"; 946 | public static string VcsBasename = "${VCS_BASENAME}"; 947 | public static string VcsUuid = "${VCS_UUID}"; 948 | public static string VcsNum = "${VCS_NUM}"; 949 | public static string VcsDate = "${VCS_DATE}"; 950 | public static string VcsBranch = "${VCS_DATE}"; 951 | public static string VcsTag = "${VCS_TAG}"; 952 | public static string VcsTagOpenpgp = "${VCS_TAG_OPENPGP}"; 953 | public static string VcsTick = "${VCS_TICK}"; 954 | public static string ${EXTRA_NAME} = "${VCS_EXTRA}"; 955 | public static string VcsActionStamp = "${VCS_ACTION_STAMP}"; 956 | public static string VcsFullHash = "${VCS_FULL_HASH}"; 957 | public static string VcsCommitOpenpgp = "${VCS_COMMIT_OPENPGP}"; 958 | public static string VcsShortHash = "${VCS_SHORT_HASH}"; 959 | public static string VcsWcModified = "${VCS_WC_MODIFIED}"; 960 | } 961 | } 962 | EOF 963 | } 964 | 965 | # For Java properties output 966 | javapropOutput() { 967 | case "${VCS_WC_MODIFIED}" in 968 | 1) VCS_WC_MODIFIED="true" ;; 969 | 0) VCS_WC_MODIFIED="false" ;; 970 | esac 971 | tee << EOF 972 | # ${GENERATED_HEADER} 973 | 974 | VCS_TYPE=${VCS_TYPE} 975 | VCS_BASENAME=${VCS_BASENAME} 976 | VCS_UUID=${VCS_UUID} 977 | VCS_NUM=${VCS_NUM} 978 | VCS_DATE=${VCS_DATE} 979 | VCS_BRANCH=${VCS_BRANCH} 980 | VCS_TAG=${VCS_TAG} 981 | VCS_TAG_OPENPGP=${VCS_TAG_OPENPGP} 982 | VCS_TICK=${VCS_TICK} 983 | ${EXTRA_NAME}=${VCS_EXTRA} 984 | 985 | VCS_ACTION_STAMP=${VCS_ACTION_STAMP} 986 | VCS_FULL_HASH=${VCS_FULL_HASH} 987 | VCS_COMMIT_OPENPGP=${VCS_COMMIT_OPENPGP} 988 | VCS_SHORT_HASH=${VCS_SHORT_HASH} 989 | 990 | VCS_WC_MODIFIED=${VCS_WC_MODIFIED} 991 | EOF 992 | } 993 | 994 | # For m4 output 995 | m4Output() { 996 | tee << EOF 997 | dnl ${GENERATED_HEADER} 998 | define(\`VCS_TYPE', \`${VCS_TYPE}')dnl 999 | define(\`VCS_BASENAME', \`${VCS_BASENAME}')dnl 1000 | define(\`VCS_UUID', \`${VCS_UUID}')dnl 1001 | define(\`VCS_NUM', \`${VCS_NUM}')dnl 1002 | define(\`VCS_DATE', \`${VCS_DATE}')dnl 1003 | define(\`VCS_BRANCH', \`${VCS_BRANCH}')dnl 1004 | define(\`VCS_TAG', \`${VCS_TAG}')dnl 1005 | define(\`VCS_TAG_OPENPGP', \`${VCS_TAG_OPENPGP}')dnl 1006 | define(\`VCS_TICK', \`${VCS_TICK}')dnl 1007 | define(\`${EXTRA_NAME}', \`${VCS_EXTRA}')dnl 1008 | define(\`VCS_ACTIONSTAMP', \`${VCS_ACTION_STAMP}')dnl 1009 | define(\`VCS_FULLHASH', \`${VCS_FULL_HASH}')dnl 1010 | define(\`VCS_COMMIT_OPENPGP', \`${VCS_COMMIT_OPENPGP}')dnl 1011 | define(\`VCS_SHORTHASH', \`${VCS_SHORT_HASH}')dnl 1012 | define(\`VCS_WC_MODIFIED', \`${VCS_WC_MODIFIED}')dnl 1013 | EOF 1014 | } 1015 | 1016 | # For (La)TeX output 1017 | # shellcheck disable=SC1117 1018 | texOutput() { 1019 | case "${VCS_WC_MODIFIED}" in 1020 | 0) VCS_WC_MODIFIED="false" ;; 1021 | 1) VCS_WC_MODIFIED="true" ;; 1022 | esac 1023 | if [ "${EXTRA_NAME}" = "VCS_EXTRA" ]; then 1024 | EXTRA_NAME="vcsExtra" 1025 | fi 1026 | tee << EOF 1027 | % ${GENERATED_HEADER} 1028 | \def \vcsType {${VCS_TYPE}} 1029 | \def \vcsBasename {${VCS_BASENAME}} 1030 | \def \vcsUUID {${VCS_UUID}} 1031 | \def \vcsNum {${VCS_NUM}} 1032 | \def \vcsDate {${VCS_DATE}} 1033 | \def \vcsBranch {${VCS_BRANCH}} 1034 | \def \vcsTag {${VCS_TAG}} 1035 | \def \vcsTagOpenpgp {${VCS_TAG_OPENPGP}} 1036 | \def \vcsTick {${VCS_TICK}} 1037 | \def \\${EXTRA_NAME} {${VCS_EXTRA}} 1038 | \def \vcsACTIONSTAMP {${VCS_ACTION_STAMP}} 1039 | \def \vcsFullHash {${VCS_FULL_HASH}} 1040 | \def \vcsCommitOpenpgp {${VCS_COMMIT_OPENPGP}} 1041 | \def \vcsShortHash {${VCS_SHORT_HASH}} 1042 | \def \vcsWCModified {${VCS_WC_MODIFIED}} 1043 | \endinput 1044 | EOF 1045 | } 1046 | 1047 | # For scheme output 1048 | schemeOutput() { 1049 | case "${VCS_WC_MODIFIED}" in 1050 | 0) VCS_WC_MODIFIED="#f" ;; 1051 | 1) VCS_WC_MODIFIED="#t" ;; 1052 | esac 1053 | tee << EOF 1054 | ;; ${GENERATED_HEADER} 1055 | (define VCS_TYPE "${VCS_TYPE}") 1056 | (define VCS_BASENAME "${VCS_BASENAME}") 1057 | (define VCS_UUID "${VCS_UUID}") 1058 | (define VCS_NUM ${VCS_NUM}) 1059 | (define VCS_DATE "${VCS_DATE}") 1060 | (define VCS_BRANCH "${VCS_BRANCH}") 1061 | (define VCS_TAG "${VCS_TAG}") 1062 | (define VCS_TAG_OPENPGP "${VCS_TAG_OPENPGP}") 1063 | (define VCS_TICK ${VCS_TICK}) 1064 | (define ${EXTRA_NAME} "${VCS_EXTRA}") 1065 | 1066 | (define VCS_ACTION_STAMP "${VCS_ACTION_STAMP}") 1067 | (define VCS_FULL_HASH "${VCS_FULL_HASH}") 1068 | (define VCS_COMMIT_OPENPGP "${VCS_COMMIT_OPENPGP}") 1069 | (define VCS_SHORT_HASH "${VCS_SHORT_HASH}") 1070 | 1071 | (define VCS_WC_MODIFIED ${VCS_WC_MODIFIED}) 1072 | ;; end 1073 | EOF 1074 | } 1075 | 1076 | # For clojure output 1077 | clojureOutput() { 1078 | case "${VCS_WC_MODIFIED}" in 1079 | 0) VCS_WC_MODIFIED="false" ;; 1080 | 1) VCS_WC_MODIFIED="true" ;; 1081 | esac 1082 | tee << EOF 1083 | ;; ${GENERATED_HEADER} 1084 | (def VCS_TYPE "${VCS_TYPE}") 1085 | (def VCS_BASENAME "${VCS_BASENAME}") 1086 | (def VCS_UUID "${VCS_UUID}") 1087 | (def VCS_NUM ${VCS_NUM}) 1088 | (def VCS_DATE "${VCS_DATE}") 1089 | (def VCS_BRANCH "${VCS_BRANCH}") 1090 | (def VCS_TAG "${VCS_TAG}") 1091 | (def VCS_TAG_OPENPGP "${VCS_TAG_OPENPGP}") 1092 | (def VCS_TICK ${VCS_TICK}) 1093 | (def ${EXTRA_NAME} "${VCS_EXTRA}") 1094 | 1095 | (def VCS_ACTION_STAMP "${VCS_ACTION_STAMP}") 1096 | (def VCS_FULL_HASH "${VCS_FULL_HASH}") 1097 | (def VCS_COMMIT_OPENPGP "${VCS_COMMIT_OPENPGP}") 1098 | (def VCS_SHORT_HASH "${VCS_SHORT_HASH}") 1099 | 1100 | (def VCS_WC_MODIFIED ${VCS_WC_MODIFIED}) 1101 | ;; end 1102 | EOF 1103 | } 1104 | 1105 | # For rpm spec file output 1106 | rpmOutput() { 1107 | tee << EOF 1108 | # ${GENERATED_HEADER} 1109 | $([ "${VCS_TYPE}" ] && echo "%define vcs_type ${VCS_TYPE}") 1110 | $([ "${VCS_BASENAME}" ] && echo "%define vcs_basename ${VCS_BASENAME}") 1111 | $([ "${VCS_UUID}" ] && echo "%define vcs_uuid ${VCS_UUID}") 1112 | $([ "${VCS_NUM}" ] && echo "%define vcs_num ${VCS_NUM}") 1113 | $([ "${VCS_DATE}" ] && echo "%define vcs_date ${VCS_DATE}") 1114 | $([ "${VCS_BRANCH}" ] && echo "%define vcs_branch ${VCS_BRANCH}") 1115 | $([ "${VCS_TAG_OPENPGP}" ] && echo "%define vcs_tag_openpgp ${VCS_TAG_OPENPGP}") 1116 | $([ "${VCS_TAG}" ] && echo "%define vcs_tag ${VCS_TAG}") 1117 | $([ "${VCS_TICK}" ] && echo "%define vcs_tick ${VCS_TICK}") 1118 | $([ "${VCS_EXTRA}" ] && echo "%define ${EXTRA_NAME} ${VCS_EXTRA}") 1119 | 1120 | $([ "${VCS_ACTION_STAMP}" ] && echo "%define vcs_action_stamp ${VCS_ACTION_STAMP}") 1121 | $([ "${VCS_FULL_HASH}" ] && echo "%define vcs_full_hash ${VCS_FULL_HASH}") 1122 | $([ "${VCS_COMMIT_OPENPGP}" ] && echo "%define vcs_commit_openpgp ${VCS_COMMIT_OPENPGP}") 1123 | $([ "${VCS_SHORT_HASH}" ] && echo "%define vcs_short_hash ${VCS_SHORT_HASH}") 1124 | 1125 | $([ "${VCS_WC_MODIFIED}" ] && echo "%define vcs_wc_modified ${VCS_WC_MODIFIED}") 1126 | # end 1127 | EOF 1128 | } 1129 | 1130 | # For C++ Header output 1131 | # shellcheck disable=SC2155,SC2039 1132 | hppOutput() { 1133 | ${LOCAL} NAMESPACE="$(echo "${VCS_BASENAME}" | sed -e 's:_::g' | tr '[:lower:]' '[:upper:]')" 1134 | tee << EOF 1135 | /* ${GENERATED_HEADER} */ 1136 | 1137 | #ifndef ${NAMESPACE}_AUTOREVISION_H 1138 | #define ${NAMESPACE}_AUTOREVISION_H 1139 | 1140 | #include 1141 | 1142 | namespace $(echo "${NAMESPACE}" | tr '[:upper:]' '[:lower:]') 1143 | { 1144 | const std::string VCS_TYPE = "${VCS_TYPE}"; 1145 | const std::string VCS_BASENAME = "${VCS_BASENAME}"; 1146 | const std::string VCS_UUID = "${VCS_UUID}"; 1147 | const int VCS_NUM = ${VCS_NUM}; 1148 | const std::string VCS_DATE = "${VCS_DATE}"; 1149 | const std::string VCS_BRANCH = "${VCS_BRANCH}"; 1150 | const std::string VCS_TAG = "${VCS_TAG}"; 1151 | const std::string VCS_TAG_OPENPGP = "${VCS_TAG_OPENPGP}"; 1152 | const int VCS_TICK = ${VCS_TICK}; 1153 | const std::string ${EXTRA_NAME} = "${VCS_EXTRA}"; 1154 | 1155 | const std::string VCS_ACTION_STAMP = "${VCS_ACTION_STAMP}"; 1156 | const std::string VCS_FULL_HASH = "${VCS_FULL_HASH}"; 1157 | const std::string VCS_COMMIT_OPENPGP = "${VCS_COMMIT_OPENPGP}"; 1158 | const std::string VCS_SHORT_HASH = "${VCS_SHORT_HASH}"; 1159 | 1160 | const int VCS_WC_MODIFIED = ${VCS_WC_MODIFIED}; 1161 | } 1162 | 1163 | #endif 1164 | 1165 | /* end */ 1166 | EOF 1167 | } 1168 | 1169 | # For Matlab output 1170 | matlabOutput() { 1171 | case "${VCS_WC_MODIFIED}" in 1172 | 0) VCS_WC_MODIFIED="FALSE" ;; 1173 | 1) VCS_WC_MODIFIED="TRUE" ;; 1174 | esac 1175 | tee << EOF 1176 | % ${GENERATED_HEADER} 1177 | 1178 | VCS_TYPE = '${VCS_TYPE}'; 1179 | VCS_BASENAME = '${VCS_BASENAME}'; 1180 | VCS_UUID = '${VCS_UUID}'; 1181 | VCS_NUM = ${VCS_NUM}; 1182 | VCS_DATE = '${VCS_DATE}'; 1183 | VCS_BRANCH = '${VCS_BRANCH}'; 1184 | VCS_TAG = '${VCS_TAG}'; 1185 | VCS_TAG_OPENPGP = '${VCS_TAG_OPENPGP}'; 1186 | VCS_TICK = ${VCS_TICK}; 1187 | ${EXTRA_NAME} = '${VCS_EXTRA}'; 1188 | 1189 | VCS_ACTION_STAMP = '${VCS_ACTION_STAMP}'; 1190 | VCS_FULL_HASH = '${VCS_FULL_HASH}'; 1191 | VCS_COMMIT_OPENPGP = '${VCS_COMMIT_OPENPGP}'; 1192 | VCS_SHORT_HASH = '${VCS_SHORT_HASH}'; 1193 | 1194 | VCS_WC_MODIFIED = ${VCS_WC_MODIFIED}; 1195 | 1196 | % end 1197 | EOF 1198 | } 1199 | 1200 | # For Octave output 1201 | octaveOutput() { 1202 | tee << EOF 1203 | % ${GENERATED_HEADER} 1204 | 1205 | VCS_TYPE = '${VCS_TYPE}'; 1206 | VCS_BASENAME = '${VCS_BASENAME}'; 1207 | VCS_UUID = '${VCS_UUID}'; 1208 | VCS_NUM = ${VCS_NUM}; 1209 | VCS_DATE = '${VCS_DATE}'; 1210 | VCS_BRANCH = '${VCS_BRANCH}'; 1211 | VCS_TAG = '${VCS_TAG}'; 1212 | VCS_TAG_OPENPGP = '${VCS_TAG_OPENPGP}'; 1213 | VCS_TICK = ${VCS_TICK}; 1214 | ${EXTRA_NAME} = '${VCS_EXTRA}'; 1215 | 1216 | VCS_ACTION_STAMP = '${VCS_ACTION_STAMP}'; 1217 | VCS_FULL_HASH = '${VCS_FULL_HASH}'; 1218 | VCS_COMMIT_OPENPGP = '${VCS_COMMIT_OPENPGP}'; 1219 | VCS_SHORT_HASH = '${VCS_SHORT_HASH}'; 1220 | 1221 | VCS_WC_MODIFIED = ${VCS_WC_MODIFIED}; 1222 | 1223 | % end 1224 | EOF 1225 | } 1226 | 1227 | sedOutput() { 1228 | tee << EOF 1229 | # ${GENERATED_HEADER} 1230 | 1231 | s|@VCS_TYPE@|${VCS_TYPE}|g 1232 | s|@VCS_BASENAME@|${VCS_BASENAME}|g 1233 | s|@VCS_UUID@|${VCS_UUID}|g 1234 | s|@VCS_NUM@|${VCS_NUM}|g 1235 | s|@VCS_DATE@|${VCS_DATE}|g 1236 | s|@VCS_BRANCH@|${VCS_BRANCH}|g 1237 | s|@VCS_TAG@|${VCS_TAG}|g 1238 | s|@VCS_TAG_OPENPGP@|${VCS_TAG_OPENPGP}|g 1239 | s|@VCS_TICK@|${VCS_TICK}|g 1240 | s|@${EXTRA_NAME}@|${VCS_EXTRA}|g 1241 | 1242 | s|@VCS_ACTION_STAMP@|${VCS_ACTION_STAMP}|g 1243 | s|@VCS_FULL_HASH@|${VCS_FULL_HASH}|g 1244 | s|@VCS_COMMIT_OPENPGP@|${VCS_COMMIT_OPENPGP}|g 1245 | s|@VCS_SHORT_HASH@|${VCS_SHORT_HASH}|g 1246 | 1247 | s|@VCS_WC_MODIFIED@|${VCS_WC_MODIFIED}|g 1248 | 1249 | # end 1250 | EOF 1251 | } 1252 | 1253 | # Helper functions 1254 | # Count path segments 1255 | # shellcheck disable=SC2039 1256 | pathSegment() { 1257 | ${LOCAL} pathz="${1}" 1258 | ${LOCAL} depth="0" 1259 | ${LOCAL} last_pathz="" 1260 | 1261 | if [ ! -z "${pathz}" ]; then 1262 | # Continue until we are at / or there are no path separators left. 1263 | while [ ! "${pathz}" = "/" ] && [ ! "${pathz}" = "${last_pathz}" ]; do 1264 | last_pathz="${pathz}" 1265 | pathz="$(dirname "${pathz}")" 1266 | depth="$((depth+1))" 1267 | done 1268 | fi 1269 | echo "${depth}" 1270 | } 1271 | 1272 | # Largest of four numbers 1273 | # shellcheck disable=SC2039 1274 | multiCompare() { 1275 | ${LOCAL} larger="${1}" 1276 | ${LOCAL} numA="${2}" 1277 | ${LOCAL} numB="${3}" 1278 | ${LOCAL} numC="${4}" 1279 | 1280 | [ "${numA}" -gt "${larger}" ] && larger="${numA}" 1281 | [ "${numB}" -gt "${larger}" ] && larger="${numB}" 1282 | [ "${numC}" -gt "${larger}" ] && larger="${numC}" 1283 | echo "${larger}" 1284 | } 1285 | 1286 | # Test for repositories 1287 | # shellcheck disable=SC2155,SC2039 1288 | repoTest() { 1289 | REPONUM="0" 1290 | if command -v git > /dev/null 2>&1; then 1291 | ${LOCAL} gitPath="$(git rev-parse --show-toplevel 2>/dev/null)" 1292 | ${LOCAL} gitDepth="$(pathSegment "${gitPath}")" 1293 | if [ ! -z "${gitPath}" ]; then 1294 | REPONUM="$((REPONUM+1))" 1295 | fi 1296 | else 1297 | ${LOCAL} gitDepth="0" 1298 | fi 1299 | if command -v hg > /dev/null 2>&1; then 1300 | ${LOCAL} hgPath="$(hg root 2>/dev/null)" 1301 | ${LOCAL} hgDepth="$(pathSegment "${hgPath}")" 1302 | if [ ! -z "${hgPath}" ]; then 1303 | REPONUM="$((REPONUM+1))" 1304 | fi 1305 | else 1306 | ${LOCAL} hgDepth="0" 1307 | fi 1308 | if command -v bzr > /dev/null 2>&1; then 1309 | ${LOCAL} bzrPath="$(bzr root 2>/dev/null)" 1310 | ${LOCAL} bzrDepth="$(pathSegment "${bzrPath}")" 1311 | if [ ! -z "${bzrPath}" ]; then 1312 | REPONUM="$((REPONUM+1))" 1313 | fi 1314 | else 1315 | ${LOCAL} bzrDepth="0" 1316 | fi 1317 | if command -v svn > /dev/null 2>&1; then 1318 | ${LOCAL} stringz="" 1319 | ${LOCAL} stringx="" 1320 | ${LOCAL} svnPath="$(svn info --xml 2>/dev/null | sed -n -e "s:${stringz}::" -e "s:${stringx}::p")" 1321 | # An old enough svn will not be able give us a path; default 1322 | # to 1 for that case. 1323 | if [ ! -z "${svnPath}" ]; then 1324 | ${LOCAL} svnDepth="$(pathSegment "${svnPath}")" 1325 | REPONUM="$((REPONUM+1))" 1326 | elif [ -z "${svnPath}" ] && [ -d ".svn" ]; then 1327 | ${LOCAL} svnDepth="1" 1328 | REPONUM="$((REPONUM+1))" 1329 | else 1330 | ${LOCAL} svnDepth="0" 1331 | fi 1332 | else 1333 | ${LOCAL} svnDepth="0" 1334 | fi 1335 | 1336 | # Do not do more work then we have to. 1337 | if [ "${REPONUM}" = "0" ]; then 1338 | return 0 1339 | fi 1340 | 1341 | # Figure out which repo is the deepest and use it. 1342 | ${LOCAL} wonRepo="$(multiCompare "${gitDepth}" "${hgDepth}" "${bzrDepth}" "${svnDepth}")" 1343 | if [ "${wonRepo}" = "${gitDepth}" ]; then 1344 | gitRepo 1345 | elif [ "${wonRepo}" = "${hgDepth}" ]; then 1346 | hgRepo 1347 | elif [ "${wonRepo}" = "${bzrDepth}" ]; then 1348 | bzrRepo 1349 | elif [ "${wonRepo}" = "${svnDepth}" ]; then 1350 | svnRepo 1351 | fi 1352 | } 1353 | 1354 | 1355 | 1356 | # Detect which repos we are in and gather data. 1357 | # shellcheck source=/dev/null 1358 | if [ -f "${CACHEFILE}" ] && [ "${CACHEFORCE}" = "1" ]; then 1359 | # When requested only read from the cache to populate our symbols. 1360 | . "${CACHEFILE}" 1361 | else 1362 | # If a value is not set through the environment set VCS_EXTRA to nothing. 1363 | : "${VCS_EXTRA:=""}" 1364 | 1365 | if [ ! -z "${CHANGE_TO_DIR}" ]; then 1366 | originalPath="$(pwd)" 1367 | # shellcheck disable=SC2164 1368 | cd "${CHANGE_TO_DIR}" 1369 | fi 1370 | 1371 | repoTest 1372 | 1373 | if [ ! -z "${originalPath}" ]; then 1374 | # shellcheck disable=SC2164 1375 | cd "${originalPath}" 1376 | fi 1377 | 1378 | if [ -f "${CACHEFILE}" ] && [ "${REPONUM}" = "0" ]; then 1379 | # We are not in a repo; try to use a previously generated cache to populate our symbols. 1380 | . "${CACHEFILE}" 1381 | # Do not overwrite the cache if we know we are not going to write anything new. 1382 | CACHEFORCE="1" 1383 | elif [ "${REPONUM}" = "0" ]; then 1384 | echo "error: No repo or cache detected." 1>&2 1385 | exit 1 1386 | fi 1387 | fi 1388 | 1389 | 1390 | # If requested, make a cache file. 1391 | if [ ! -z "${CACHEFILE}" ] && [ ! "${CACHEFORCE}" = "1" ]; then 1392 | EXTRA_OUTPUT="${EXTRA_NAME}" 1393 | EXTRA_NAME="VCS_EXTRA" 1394 | shOutput > "${CACHEFILE}.tmp" 1395 | 1396 | # Check to see if there have been any actual changes. 1397 | if [ ! -f "${CACHEFILE}" ]; then 1398 | mv -f "${CACHEFILE}.tmp" "${CACHEFILE}" 1399 | elif cmp -s "${CACHEFILE}.tmp" "${CACHEFILE}"; then 1400 | rm -f "${CACHEFILE}.tmp" 1401 | else 1402 | mv -f "${CACHEFILE}.tmp" "${CACHEFILE}" 1403 | fi 1404 | EXTRA_NAME="${EXTRA_OUTPUT}" 1405 | fi 1406 | 1407 | 1408 | 1409 | # -s output is handled here. 1410 | if [ ! -z "${VAROUT}" ]; then 1411 | case "${VAROUT}" in 1412 | VCS_TYPE) 1413 | echo "${VCS_TYPE}" 1414 | ;; 1415 | VCS_BASENAME) 1416 | echo "${VCS_BASENAME}" 1417 | ;; 1418 | VCS_NUM) 1419 | echo "${VCS_NUM}" 1420 | ;; 1421 | VCS_DATE) 1422 | echo "${VCS_DATE}" 1423 | ;; 1424 | VCS_BRANCH) 1425 | echo "${VCS_BRANCH}" 1426 | ;; 1427 | VCS_TAG) 1428 | echo "${VCS_TAG}" 1429 | ;; 1430 | VCS_TICK) 1431 | echo "${VCS_TICK}" 1432 | ;; 1433 | VCS_FULL_HASH) 1434 | echo "${VCS_FULL_HASH}" 1435 | ;; 1436 | VCS_SHORT_HASH) 1437 | echo "${VCS_SHORT_HASH}" 1438 | ;; 1439 | VCS_WC_MODIFIED) 1440 | echo "${VCS_WC_MODIFIED}" 1441 | ;; 1442 | VCS_ACTION_STAMP) 1443 | echo "${VCS_ACTION_STAMP}" 1444 | ;; 1445 | *) 1446 | echo "error: ${VAROUT} is not a valid output symbol." 1>&2 1447 | exit 1 1448 | ;; 1449 | esac 1450 | fi 1451 | 1452 | 1453 | # Detect requested output type and use it. 1454 | if [ ! -z "${AFILETYPE}" ]; then 1455 | case "${AFILETYPE}" in 1456 | c) 1457 | cOutput 1458 | ;; 1459 | h) 1460 | hOutput 1461 | ;; 1462 | xcode) 1463 | xcodeOutput 1464 | ;; 1465 | swift) 1466 | swiftOutput 1467 | ;; 1468 | sed) 1469 | sedOutput 1470 | ;; 1471 | sh) 1472 | shOutput 1473 | ;; 1474 | py|python) 1475 | pyOutput 1476 | ;; 1477 | pl|perl) 1478 | plOutput 1479 | ;; 1480 | lua) 1481 | luaOutput 1482 | ;; 1483 | php) 1484 | phpOutput 1485 | ;; 1486 | ini) 1487 | iniOutput 1488 | ;; 1489 | js) 1490 | jsOutput 1491 | ;; 1492 | json) 1493 | jsonOutput 1494 | ;; 1495 | java) 1496 | javaOutput 1497 | ;; 1498 | javaprop) 1499 | javapropOutput 1500 | ;; 1501 | csharp) 1502 | csharpOutput 1503 | ;; 1504 | tex) 1505 | texOutput 1506 | ;; 1507 | m4) 1508 | m4Output 1509 | ;; 1510 | scheme) 1511 | schemeOutput 1512 | ;; 1513 | clojure) 1514 | clojureOutput 1515 | ;; 1516 | rpm) 1517 | rpmOutput 1518 | ;; 1519 | hpp) 1520 | hppOutput 1521 | ;; 1522 | matlab) 1523 | matlabOutput 1524 | ;; 1525 | octave) 1526 | octaveOutput 1527 | ;; 1528 | cmake) 1529 | cmakeOutput 1530 | ;; 1531 | *) 1532 | echo "error: ${AFILETYPE} is not a valid output type." 1>&2 1533 | exit 1 1534 | ;; 1535 | esac 1536 | fi 1537 | -------------------------------------------------------------------------------- /contribs/README.md: -------------------------------------------------------------------------------- 1 | # Autorevision Driving Script Examples # 2 | 3 | Some real life examples of how you can use `autorevision`. 4 | 5 | If you have used `autorevision` to do something tricky please send in your driving scripts. 6 | -------------------------------------------------------------------------------- /contribs/autorevision.mk: -------------------------------------------------------------------------------- 1 | # Generic makefile showing how to use autorevision. 2 | # 3 | # Get the version number for use in the makefile and generate / update 4 | # the cache as needed. 5 | VERS := $(shell autorevision -s VCS_TAG -o ./autorevision.cache) 6 | 7 | # This gives you a $(VERS) variable that you can use later in the 8 | # makefile (say, in your tarball name); it also means that the 9 | # expensive operations that autorevision runs only have to be done 10 | # once. 11 | 12 | 13 | SOURCES = \ 14 | autorevision.c \ 15 | autorevision.json 16 | 17 | EXTRA_DIST = \ 18 | autorevision.cache 19 | 20 | # Make sure that the cache file ends up in your tarball or 21 | # autorevision will break. 22 | 23 | 24 | all : json cpp 25 | 26 | 27 | 28 | # Generate json output 29 | json: autorevision.json 30 | 31 | autorevision.json: autorevision.cache 32 | autorevision -f -t json -o ./autorevision.cache > autorevision.json 33 | 34 | 35 | # Generate C/C++ source output 36 | cpp: autorevision.c 37 | 38 | autorevision.c: autorevision.cache 39 | autorevision -f -t c -o ./autorevision.cache > autorevision.c 40 | -------------------------------------------------------------------------------- /contribs/autorevision_declr.h: -------------------------------------------------------------------------------- 1 | /* Use this header with source C backend */ 2 | #ifndef AUTOREVISION_DECLR_H 3 | #define AUTOREVISION_DECLR_H 4 | 5 | extern const char *VCS_TYPE; 6 | extern const char *VCS_BASENAME; 7 | extern const char *VCS_UUID; 8 | extern const int VCS_NUM; 9 | extern const char *VCS_DATE; 10 | extern const char *VCS_BRANCH; 11 | extern const char *VCS_TAG; 12 | extern const char *VCS_TAG_OPENPGP; 13 | extern const int VCS_TICK; 14 | extern const char *VCS_EXTRA; 15 | 16 | extern const char *VCS_ACTION_STAMP; 17 | extern const char *VCS_FULL_HASH; 18 | extern const char *VCS_COMMIT_OPENPGP; 19 | extern const char *VCS_SHORT_HASH; 20 | 21 | extern const int VCS_WC_MODIFIED; 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /contribs/wscript: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # encoding: utf-8 3 | 4 | APPNAME = 'projectname' 5 | VERSION = '1.0' # This will be overwritten later. 6 | 7 | 8 | def configure(bld): 9 | # This makes sure that autorevision exists before we call it. 10 | bld.find_program('autorevision', var='AUTOREVISION') 11 | 12 | 13 | def options(bld): 14 | pass 15 | 16 | 17 | def arv(bld): 18 | # The cache file build is in its own function so it can be easily 19 | # included everywhere it needs to be. 20 | from waflib import ConfigSet 21 | # Get the path to autorevision found in configuration. 22 | try: 23 | env = ConfigSet.ConfigSet('build/c4che/_cache.py') 24 | except (OSError, IOError): 25 | bld.fatal('Project is not configured') 26 | 27 | # This is where the cache file is made and VERSION is rewritten. 28 | global VERSION 29 | 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() 30 | 31 | 32 | def dist(bld): 33 | # Make sure that the cache file is in the tarball. 34 | arv(bld) 35 | 36 | 37 | def build(bld): 38 | # Make sure that the cache file is built first. 39 | arv(bld) 40 | # Here we let waf know about the autorevision.cache file. 41 | autorevision_cache_node = bld.path.find_or_declare('autorevision.cache') 42 | 43 | # This is where the autorevision.json file is made. 44 | bld( 45 | rule='${AUTOREVISION} -f -t json -o ${SRC[0].abspath()} > ${TGT}', 46 | source=autorevision_cache_node, 47 | target='autorevision.json') 48 | 49 | # This is where the autorevision.h file is made. 50 | bld( 51 | rule='${AUTOREVISION} -f -t h -o ${SRC[0].abspath()} > ${TGT}', 52 | source=autorevision_cache_node, 53 | target='autorevision.h') 54 | 55 | 56 | def test(bld): 57 | # A simple sanity check. 58 | arv(bld) 59 | -------------------------------------------------------------------------------- /contribs/xcode.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This script drives autorevision so that you end up with two 4 | # `autorevision.h` files; one for including in the program and one for 5 | # populating values in the `info.plist` file (some of which are user 6 | # visible). 7 | # The cache file is generated in a repo and is read from 8 | # unconditionally when building from a tarball. 9 | # This script is meant to called from within Xcode, some of the 10 | # variables are defined in the environment there. 11 | 12 | # Config 13 | export PATH=${PATH}:/sw/bin:/usr/local/bin:/usr/local/git/bin 14 | : "${DERIVED_FILE_DIR:="./der"}" 15 | : "${SRCROOT:="./src"}" 16 | : "${OBJROOT:="./obj"}" 17 | 18 | # This header file uses a slightly different format and a customized 19 | # cache suitable for use with an info.plist file. 20 | infoPlistOutput="${DERIVED_FILE_DIR}/autorevision.h" 21 | customCacheOutput="${OBJROOT}/autorevision.tmp" 22 | 23 | # This is a header suitable for including is your code. 24 | # The one that actually gets included is only updated when something 25 | # changes to prevent needless rebuilding. 26 | cHeaderOutput="${SRCROOT}/autorevision.h" 27 | cHeaderTempOutput="${OBJROOT}/autorevision.h" 28 | 29 | # This is what needs to be in a tarball to make things work. 30 | cacheOutput="${SRCROOT}/autorevision.cache" 31 | 32 | 33 | 34 | # Output the autorevision cache. 35 | if ! autorevision -o "${cacheOutput}" -t sh; then 36 | exit ${?} 37 | fi 38 | 39 | ### 40 | # This section does some manipulations to make the output pretty for 41 | # use in the info.plist 42 | 43 | # Source the cache to allow for value manipulation. 44 | . "${cacheOutput}" 45 | 46 | if [ ! "${VCS_TICK}" = "0" ]; then 47 | # If we are not exactly on a tag make the branch look better and use the value for the tag too. 48 | N_VCS_BRANCH="$(echo "${VCS_BRANCH}" | sed -e 's:remotes/:remote/:' -e 's:master:Master:')" 49 | sed -e "s:${VCS_BRANCH}:${N_VCS_BRANCH}:" -e "s:${VCS_TAG}:${N_VCS_BRANCH}:" "${cacheOutput}" > "${customCacheOutput}" 50 | else 51 | # When exactly on a tag make the value suitable for users. 52 | # The following tag prefix formats are recognized and striped: 53 | # v1.0 | v/1.0 = 1.0 54 | # The following tag suffix formats are transformed: 55 | # 1.0_beta6 = 1.0 Beta 6 || 1.0_rc6 = 1.0 RC 6 56 | N_VCS_TAG="$(echo "${VCS_TAG}" | sed -e 's:^v/::' -e 's:^v::' -e 's:_beta: Beta :' -e 's:_rc: RC :')" 57 | sed -e "s:${VCS_TAG}:${N_VCS_TAG}:" "${cacheOutput}" > "${customCacheOutput}" 58 | fi 59 | 60 | ### 61 | 62 | # Output for src/autorevision.h. 63 | autorevision -f -o "${cacheOutput}" -t h > "${cHeaderTempOutput}" 64 | if [ ! -f "${cHeaderOutput}" ] || ! cmp -s "${cHeaderTempOutput}" "${cHeaderOutput}"; then 65 | # Only copy `src/autorevision.h` in if there have been changes. 66 | cp -a "${cHeaderTempOutput}" "${cHeaderOutput}" 67 | fi 68 | 69 | # Output for info.plist prepossessing. 70 | autorevision -f -o "${customCacheOutput}" -t xcode > "${infoPlistOutput}" 71 | 72 | exit ${?} 73 | -------------------------------------------------------------------------------- /control: -------------------------------------------------------------------------------- 1 | # This is not a real Debian control file, though the syntax is compatible. 2 | # It's project metadata for the shipper tool 3 | 4 | Package: autorevision 5 | 6 | Description: Extracts metadata about the current revision from your repository. 7 | This program is meant to be used by project build systems to extract 8 | properties that can be used in software version strings. Repository 9 | types supported include git, hg, bzr, and svn. It can create files 10 | containing variable and macro definitions suitable for C, C++, Java, 11 | sh, Python, Perl, PHP, lua, Javascript, and header files suitable for 12 | use with preprocessing Info.plist files. 13 | 14 | XBS-Github-URL: https://github.com/Autorevision/autorevision 15 | 16 | Vcs-Browser: https://github.com/Autorevision/autorevision 17 | 18 | Vcs-Git: git://github.com/Autorevision/autorevision 19 | 20 | XBS-Ohloh-URL: https://www.openhub.net/p/autorevision 21 | 22 | Homepage: https://autorevision.github.io/ 23 | 24 | XBS-IRC-Channel: irc://irc.libera.chat/#autorevision 25 | 26 | XBS-Logo: contribs/logo.svg 27 | 28 | XBS-Freecode-Tags: svn git hg perl python c c++ bash build_tools 29 | -------------------------------------------------------------------------------- /examples/autorevision.c: -------------------------------------------------------------------------------- 1 | /* Generated by autorevision - do not hand-hack! */ 2 | 3 | const char *VCS_TYPE = "git"; 4 | const char *VCS_BASENAME = "autorevision"; 5 | const char *VCS_UUID = "da2830f81fec4c6ebce8ebf23f35b0e6b066c149"; 6 | const int VCS_NUM = 424; 7 | const char *VCS_DATE = "2017-09-26T03:57:45Z"; 8 | const char *VCS_BRANCH = "topic/gpg"; 9 | const char *VCS_TAG = "v/1.20"; 10 | const char *VCS_TAG_OPENPGP = "A16E4FE1BFE882DE9D6E28AD0044B6E72C414317"; 11 | const int VCS_TICK = 16; 12 | const char *VCS_EXTRA = ""; 13 | 14 | const char *VCS_ACTION_STAMP = "2017-09-26T03:57:45Z!dak180@users.sourceforge.net"; 15 | const char *VCS_FULL_HASH = "c009f3afa47dc7cc2bcf789f37cdea8c91a32f5e"; 16 | const char *VCS_COMMIT_OPENPGP = "A16E4FE1BFE882DE9D6E28AD0044B6E72C414317"; 17 | const char *VCS_SHORT_HASH = "c009f3a"; 18 | 19 | const int VCS_WC_MODIFIED = 0; 20 | 21 | /* end */ 22 | -------------------------------------------------------------------------------- /examples/autorevision.clojure: -------------------------------------------------------------------------------- 1 | ;; Generated by autorevision - do not hand-hack! 2 | (def VCS_TYPE "git") 3 | (def VCS_BASENAME "autorevision") 4 | (def VCS_UUID "da2830f81fec4c6ebce8ebf23f35b0e6b066c149") 5 | (def VCS_NUM 424) 6 | (def VCS_DATE "2017-09-26T03:57:45Z") 7 | (def VCS_BRANCH "topic/gpg") 8 | (def VCS_TAG "v/1.20") 9 | (def VCS_TAG_OPENPGP "A16E4FE1BFE882DE9D6E28AD0044B6E72C414317") 10 | (def VCS_TICK 16) 11 | (def VCS_EXTRA "") 12 | 13 | (def VCS_ACTION_STAMP "2017-09-26T03:57:45Z!dak180@users.sourceforge.net") 14 | (def VCS_FULL_HASH "c009f3afa47dc7cc2bcf789f37cdea8c91a32f5e") 15 | (def VCS_COMMIT_OPENPGP "A16E4FE1BFE882DE9D6E28AD0044B6E72C414317") 16 | (def VCS_SHORT_HASH "c009f3a") 17 | 18 | (def VCS_WC_MODIFIED false) 19 | ;; end 20 | -------------------------------------------------------------------------------- /examples/autorevision.cmake: -------------------------------------------------------------------------------- 1 | # Generated by autorevision - do not hand-hack! 2 | 3 | set(VCS_TYPE git) 4 | set(VCS_BASENAME autorevision) 5 | set(VCS_UUID da2830f81fec4c6ebce8ebf23f35b0e6b066c149) 6 | set(VCS_NUM 424) 7 | set(VCS_DATE 2017-09-26T03:57:45Z) 8 | set(VCS_BRANCH topic/gpg) 9 | set(VCS_TAG v/1.20) 10 | set(VCS_TAG_OPENPGP A16E4FE1BFE882DE9D6E28AD0044B6E72C414317) 11 | set(VCS_TICK 16) 12 | set(VCS_EXTRA ) 13 | 14 | set(VCS_ACTION_STAMP 2017-09-26T03:57:45Z!dak180@users.sourceforge.net) 15 | set(VCS_FULL_HASH c009f3afa47dc7cc2bcf789f37cdea8c91a32f5e) 16 | set(VCS_COMMIT_OPENPGP A16E4FE1BFE882DE9D6E28AD0044B6E72C414317) 17 | set(VCS_SHORT_HASH c009f3a) 18 | 19 | set(VCS_WC_MODIFIED 0) 20 | 21 | # end 22 | -------------------------------------------------------------------------------- /examples/autorevision.csharp: -------------------------------------------------------------------------------- 1 | /* Generated by autorevision - do not hand-hack! */ 2 | 3 | namespace AutoRevision 4 | { 5 | public class VersionInfo 6 | { 7 | public static string VcsType = "git"; 8 | public static string VcsBasename = "autorevision"; 9 | public static string VcsUuid = "da2830f81fec4c6ebce8ebf23f35b0e6b066c149"; 10 | public static string VcsNum = "424"; 11 | public static string VcsDate = "2017-09-26T03:57:45Z"; 12 | public static string VcsBranch = "2017-09-26T03:57:45Z"; 13 | public static string VcsTag = "v/1.20"; 14 | public static string VcsTagOpenpgp = "A16E4FE1BFE882DE9D6E28AD0044B6E72C414317"; 15 | public static string VcsTick = "16"; 16 | public static string VcsExtra = ""; 17 | public static string VcsActionStamp = "2017-09-26T03:57:45Z!dak180@users.sourceforge.net"; 18 | public static string VcsFullHash = "c009f3afa47dc7cc2bcf789f37cdea8c91a32f5e"; 19 | public static string VcsCommitOpenpgp = "A16E4FE1BFE882DE9D6E28AD0044B6E72C414317"; 20 | public static string VcsShortHash = "c009f3a"; 21 | public static string VcsWcModified = "false"; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /examples/autorevision.h: -------------------------------------------------------------------------------- 1 | /* Generated by autorevision - do not hand-hack! */ 2 | #ifndef AUTOREVISION_H 3 | #define AUTOREVISION_H 4 | 5 | #define VCS_TYPE "git" 6 | #define VCS_BASENAME "autorevision" 7 | #define VCS_UUID "da2830f81fec4c6ebce8ebf23f35b0e6b066c149" 8 | #define VCS_NUM 424 9 | #define VCS_DATE "2017-09-26T03:57:45Z" 10 | #define VCS_BRANCH "topic/gpg" 11 | #define VCS_TAG "v/1.20" 12 | #define VCS_TAG_OPENPGP "A16E4FE1BFE882DE9D6E28AD0044B6E72C414317" 13 | #define VCS_TICK 16 14 | #define VCS_EXTRA "" 15 | 16 | #define VCS_ACTION_STAMP "2017-09-26T03:57:45Z!dak180@users.sourceforge.net" 17 | #define VCS_FULL_HASH "c009f3afa47dc7cc2bcf789f37cdea8c91a32f5e" 18 | #define VCS_COMMIT_OPENPGP "A16E4FE1BFE882DE9D6E28AD0044B6E72C414317" 19 | #define VCS_SHORT_HASH "c009f3a" 20 | 21 | #define VCS_WC_MODIFIED 0 22 | 23 | #endif 24 | 25 | /* end */ 26 | -------------------------------------------------------------------------------- /examples/autorevision.hpp: -------------------------------------------------------------------------------- 1 | /* Generated by autorevision - do not hand-hack! */ 2 | 3 | #ifndef AUTOREVISION_AUTOREVISION_H 4 | #define AUTOREVISION_AUTOREVISION_H 5 | 6 | #include 7 | 8 | namespace autorevision 9 | { 10 | const std::string VCS_TYPE = "git"; 11 | const std::string VCS_BASENAME = "autorevision"; 12 | const std::string VCS_UUID = "da2830f81fec4c6ebce8ebf23f35b0e6b066c149"; 13 | const int VCS_NUM = 424; 14 | const std::string VCS_DATE = "2017-09-26T03:57:45Z"; 15 | const std::string VCS_BRANCH = "topic/gpg"; 16 | const std::string VCS_TAG = "v/1.20"; 17 | const std::string VCS_TAG_OPENPGP = "A16E4FE1BFE882DE9D6E28AD0044B6E72C414317"; 18 | const int VCS_TICK = 16; 19 | const std::string VCS_EXTRA = ""; 20 | 21 | const std::string VCS_ACTION_STAMP = "2017-09-26T03:57:45Z!dak180@users.sourceforge.net"; 22 | const std::string VCS_FULL_HASH = "c009f3afa47dc7cc2bcf789f37cdea8c91a32f5e"; 23 | const std::string VCS_COMMIT_OPENPGP = "A16E4FE1BFE882DE9D6E28AD0044B6E72C414317"; 24 | const std::string VCS_SHORT_HASH = "c009f3a"; 25 | 26 | const int VCS_WC_MODIFIED = 0; 27 | } 28 | 29 | #endif 30 | 31 | /* end */ 32 | -------------------------------------------------------------------------------- /examples/autorevision.ini: -------------------------------------------------------------------------------- 1 | ; Generated by autorevision - do not hand-hack! 2 | [VCS] 3 | VCS_TYPE = "git" 4 | VCS_BASENAME = "autorevision" 5 | VCS_UUID = "da2830f81fec4c6ebce8ebf23f35b0e6b066c149" 6 | VCS_NUM = 424 7 | VCS_DATE = "2017-09-26T03:57:45Z" 8 | VCS_BRANCH = "topic/gpg" 9 | VCS_TAG = "v/1.20" 10 | VCS_TAG_OPENPGP = "A16E4FE1BFE882DE9D6E28AD0044B6E72C414317" 11 | VCS_TICK = 16 12 | VCS_EXTRA = "" 13 | VCS_ACTION_STAMP = "2017-09-26T03:57:45Z!dak180@users.sourceforge.net" 14 | VCS_FULL_HASH = "c009f3afa47dc7cc2bcf789f37cdea8c91a32f5e" 15 | VCS_COMMIT_OPENPGP = "A16E4FE1BFE882DE9D6E28AD0044B6E72C414317" 16 | VCS_SHORT_HASH = "c009f3a" 17 | VCS_WC_MODIFIED = false 18 | ; end 19 | -------------------------------------------------------------------------------- /examples/autorevision.java: -------------------------------------------------------------------------------- 1 | /* Generated by autorevision - do not hand-hack! */ 2 | 3 | public class autorevision { 4 | public static final String VCS_TYPE = "git"; 5 | public static final String VCS_BASENAME = "autorevision"; 6 | public static final String VCS_UUID = "da2830f81fec4c6ebce8ebf23f35b0e6b066c149"; 7 | public static final long VCS_NUM = 424; 8 | public static final String VCS_DATE = "2017-09-26T03:57:45Z"; 9 | public static final String VCS_BRANCH = "topic/gpg"; 10 | public static final String VCS_TAG = "v/1.20"; 11 | public static final String VCS_TAG_OPENPGP = "A16E4FE1BFE882DE9D6E28AD0044B6E72C414317"; 12 | public static final long VCS_TICK = 16; 13 | public static final String VCS_EXTRA = ""; 14 | 15 | public static final String VCS_ACTION_STAMP = "2017-09-26T03:57:45Z!dak180@users.sourceforge.net"; 16 | public static final String VCS_FULL_HASH = "c009f3afa47dc7cc2bcf789f37cdea8c91a32f5e"; 17 | public static final String VCS_COMMIT_OPENPGP = "A16E4FE1BFE882DE9D6E28AD0044B6E72C414317"; 18 | public static final String VCS_SHORT_HASH = "c009f3a"; 19 | 20 | public static final boolean VCS_WC_MODIFIED = false; 21 | } 22 | -------------------------------------------------------------------------------- /examples/autorevision.javaprop: -------------------------------------------------------------------------------- 1 | # Generated by autorevision - do not hand-hack! 2 | 3 | VCS_TYPE=git 4 | VCS_BASENAME=autorevision 5 | VCS_UUID=da2830f81fec4c6ebce8ebf23f35b0e6b066c149 6 | VCS_NUM=424 7 | VCS_DATE=2017-09-26T03:57:45Z 8 | VCS_BRANCH=topic/gpg 9 | VCS_TAG=v/1.20 10 | VCS_TAG_OPENPGP=A16E4FE1BFE882DE9D6E28AD0044B6E72C414317 11 | VCS_TICK=16 12 | VCS_EXTRA= 13 | 14 | VCS_ACTION_STAMP=2017-09-26T03:57:45Z!dak180@users.sourceforge.net 15 | VCS_FULL_HASH=c009f3afa47dc7cc2bcf789f37cdea8c91a32f5e 16 | VCS_COMMIT_OPENPGP=A16E4FE1BFE882DE9D6E28AD0044B6E72C414317 17 | VCS_SHORT_HASH=c009f3a 18 | 19 | VCS_WC_MODIFIED=false 20 | -------------------------------------------------------------------------------- /examples/autorevision.js: -------------------------------------------------------------------------------- 1 | /** Generated by autorevision - do not hand-hack! */ 2 | 3 | var autorevision = { 4 | VCS_TYPE: "git", 5 | VCS_BASENAME: "autorevision", 6 | VCS_UUID: "da2830f81fec4c6ebce8ebf23f35b0e6b066c149", 7 | VCS_NUM: 424, 8 | VCS_DATE: "2017-09-26T03:57:45Z", 9 | VCS_BRANCH: "topic/gpg", 10 | VCS_TAG: "v/1.20", 11 | VCS_TAG_OPENPGP: "A16E4FE1BFE882DE9D6E28AD0044B6E72C414317", 12 | VCS_TICK: 16, 13 | VCS_EXTRA: "", 14 | 15 | VCS_ACTION_STAMP: "2017-09-26T03:57:45Z!dak180@users.sourceforge.net", 16 | VCS_FULL_HASH: "c009f3afa47dc7cc2bcf789f37cdea8c91a32f5e", 17 | VCS_COMMIT_OPENPGP: "A16E4FE1BFE882DE9D6E28AD0044B6E72C414317", 18 | VCS_SHORT_HASH: "c009f3a", 19 | 20 | VCS_WC_MODIFIED: false 21 | }; 22 | 23 | /** Node.js compatibility */ 24 | if (typeof module !== 'undefined') { 25 | module.exports = autorevision; 26 | } 27 | 28 | /** end */ 29 | -------------------------------------------------------------------------------- /examples/autorevision.json: -------------------------------------------------------------------------------- 1 | { 2 | "_comment": "Generated by autorevision - do not hand-hack!", 3 | "VCS_TYPE": "git", 4 | "VCS_BASENAME": "autorevision", 5 | "VCS_UUID": "da2830f81fec4c6ebce8ebf23f35b0e6b066c149", 6 | "VCS_NUM": 424, 7 | "VCS_DATE": "2017-09-26T03:57:45Z", 8 | "VCS_BRANCH":"topic/gpg", 9 | "VCS_TAG": "v/1.20", 10 | "VCS_TAG_OPENPGP": "A16E4FE1BFE882DE9D6E28AD0044B6E72C414317", 11 | "VCS_TICK": 16, 12 | "VCS_EXTRA": "", 13 | 14 | "VCS_ACTION_STAMP": "2017-09-26T03:57:45Z!dak180@users.sourceforge.net", 15 | "VCS_FULL_HASH": "c009f3afa47dc7cc2bcf789f37cdea8c91a32f5e", 16 | "VCS_COMMIT_OPENPGP": "A16E4FE1BFE882DE9D6E28AD0044B6E72C414317", 17 | "VCS_SHORT_HASH": "c009f3a", 18 | 19 | "VCS_WC_MODIFIED": false 20 | } 21 | -------------------------------------------------------------------------------- /examples/autorevision.lua: -------------------------------------------------------------------------------- 1 | -- Generated by autorevision - do not hand-hack! 2 | 3 | VCS_TYPE = "git" 4 | VCS_BASENAME = "autorevision" 5 | VCS_UUID = "da2830f81fec4c6ebce8ebf23f35b0e6b066c149" 6 | VCS_NUM = 424 7 | VCS_DATE = "2017-09-26T03:57:45Z" 8 | VCS_BRANCH = "topic/gpg" 9 | VCS_TAG = "v/1.20" 10 | VCS_TAG_OPENPGP = "A16E4FE1BFE882DE9D6E28AD0044B6E72C414317" 11 | VCS_TICK = 16 12 | VCS_EXTRA = "" 13 | 14 | VCS_ACTION_STAMP = "2017-09-26T03:57:45Z!dak180@users.sourceforge.net" 15 | VCS_FULL_HASH = "c009f3afa47dc7cc2bcf789f37cdea8c91a32f5e" 16 | VCS_COMMIT_OPENPGP = "A16E4FE1BFE882DE9D6E28AD0044B6E72C414317" 17 | VCS_SHORT_HASH = "c009f3a" 18 | 19 | VCS_WC_MODIFIED = false 20 | 21 | -- end 22 | -------------------------------------------------------------------------------- /examples/autorevision.m4: -------------------------------------------------------------------------------- 1 | dnl Generated by autorevision - do not hand-hack! 2 | define(`VCS_TYPE', `git')dnl 3 | define(`VCS_BASENAME', `autorevision')dnl 4 | define(`VCS_UUID', `da2830f81fec4c6ebce8ebf23f35b0e6b066c149')dnl 5 | define(`VCS_NUM', `424')dnl 6 | define(`VCS_DATE', `2017-09-26T03:57:45Z')dnl 7 | define(`VCS_BRANCH', `topic/gpg')dnl 8 | define(`VCS_TAG', `v/1.20')dnl 9 | define(`VCS_TAG_OPENPGP', `A16E4FE1BFE882DE9D6E28AD0044B6E72C414317')dnl 10 | define(`VCS_TICK', `16')dnl 11 | define(`VCS_EXTRA', `')dnl 12 | define(`VCS_ACTIONSTAMP', `2017-09-26T03:57:45Z!dak180@users.sourceforge.net')dnl 13 | define(`VCS_FULLHASH', `c009f3afa47dc7cc2bcf789f37cdea8c91a32f5e')dnl 14 | define(`VCS_COMMIT_OPENPGP', `A16E4FE1BFE882DE9D6E28AD0044B6E72C414317')dnl 15 | define(`VCS_SHORTHASH', `c009f3a')dnl 16 | define(`VCS_WC_MODIFIED', `0')dnl 17 | -------------------------------------------------------------------------------- /examples/autorevision.matlab: -------------------------------------------------------------------------------- 1 | % Generated by autorevision - do not hand-hack! 2 | 3 | VCS_TYPE = 'git'; 4 | VCS_BASENAME = 'autorevision'; 5 | VCS_UUID = 'da2830f81fec4c6ebce8ebf23f35b0e6b066c149'; 6 | VCS_NUM = 424; 7 | VCS_DATE = '2017-09-26T03:57:45Z'; 8 | VCS_BRANCH = 'topic/gpg'; 9 | VCS_TAG = 'v/1.20'; 10 | VCS_TAG_OPENPGP = 'A16E4FE1BFE882DE9D6E28AD0044B6E72C414317'; 11 | VCS_TICK = 16; 12 | VCS_EXTRA = ''; 13 | 14 | VCS_ACTION_STAMP = '2017-09-26T03:57:45Z!dak180@users.sourceforge.net'; 15 | VCS_FULL_HASH = 'c009f3afa47dc7cc2bcf789f37cdea8c91a32f5e'; 16 | VCS_COMMIT_OPENPGP = 'A16E4FE1BFE882DE9D6E28AD0044B6E72C414317'; 17 | VCS_SHORT_HASH = 'c009f3a'; 18 | 19 | VCS_WC_MODIFIED = FALSE; 20 | 21 | % end 22 | -------------------------------------------------------------------------------- /examples/autorevision.octave: -------------------------------------------------------------------------------- 1 | % Generated by autorevision - do not hand-hack! 2 | 3 | VCS_TYPE = 'git'; 4 | VCS_BASENAME = 'autorevision'; 5 | VCS_UUID = 'da2830f81fec4c6ebce8ebf23f35b0e6b066c149'; 6 | VCS_NUM = 424; 7 | VCS_DATE = '2017-09-26T03:57:45Z'; 8 | VCS_BRANCH = 'topic/gpg'; 9 | VCS_TAG = 'v/1.20'; 10 | VCS_TAG_OPENPGP = 'A16E4FE1BFE882DE9D6E28AD0044B6E72C414317'; 11 | VCS_TICK = 16; 12 | VCS_EXTRA = ''; 13 | 14 | VCS_ACTION_STAMP = '2017-09-26T03:57:45Z!dak180@users.sourceforge.net'; 15 | VCS_FULL_HASH = 'c009f3afa47dc7cc2bcf789f37cdea8c91a32f5e'; 16 | VCS_COMMIT_OPENPGP = 'A16E4FE1BFE882DE9D6E28AD0044B6E72C414317'; 17 | VCS_SHORT_HASH = 'c009f3a'; 18 | 19 | VCS_WC_MODIFIED = 0; 20 | 21 | % end 22 | -------------------------------------------------------------------------------- /examples/autorevision.php: -------------------------------------------------------------------------------- 1 | "git", 6 | "VCS_BASENAME" => "autorevision", 7 | "VCS_UUID" => "da2830f81fec4c6ebce8ebf23f35b0e6b066c149", 8 | "VCS_NUM" => 424, 9 | "VCS_DATE" => "2017-09-26T03:57:45Z", 10 | "VCS_BRANCH" => "topic/gpg", 11 | "VCS_TAG" => "v/1.20", 12 | "VCS_TAG_OPENPGP" => "A16E4FE1BFE882DE9D6E28AD0044B6E72C414317", 13 | "VCS_TICK" => 16, 14 | "VCS_EXTRA" => "", 15 | "VCS_ACTION_STAMP" => "2017-09-26T03:57:45Z!dak180@users.sourceforge.net", 16 | "VCS_FULL_HASH" => "c009f3afa47dc7cc2bcf789f37cdea8c91a32f5e", 17 | "VCS_COMMIT_OPENPGP" => "A16E4FE1BFE882DE9D6E28AD0044B6E72C414317", 18 | "VCS_SHORT_HASH" => "c009f3a", 19 | "VCS_WC_MODIFIED" => false 20 | ); 21 | 22 | # end 23 | ?> 24 | -------------------------------------------------------------------------------- /examples/autorevision.pl: -------------------------------------------------------------------------------- 1 | # Generated by autorevision - do not hand-hack! 2 | 3 | $VCS_TYPE = 'git'; 4 | $VCS_BASENAME = 'autorevision'; 5 | $VCS_UUID = 'da2830f81fec4c6ebce8ebf23f35b0e6b066c149'; 6 | $VCS_NUM = 424; 7 | $VCS_DATE = '2017-09-26T03:57:45Z'; 8 | $VCS_BRANCH = 'topic/gpg'; 9 | $VCS_TAG = 'v/1.20'; 10 | $VCS_TAG_OPENPGP = 'A16E4FE1BFE882DE9D6E28AD0044B6E72C414317'; 11 | $VCS_TICK = 16; 12 | $VCS_EXTRA = ''; 13 | 14 | $VCS_ACTION_STAMP = '2017-09-26T03:57:45Z!dak180@users.sourceforge.net'; 15 | $VCS_FULL_HASH = 'c009f3afa47dc7cc2bcf789f37cdea8c91a32f5e'; 16 | $VCS_COMMIT_OPENPGP = 'A16E4FE1BFE882DE9D6E28AD0044B6E72C414317'; 17 | $VCS_SHORT_HASH = 'c009f3a'; 18 | 19 | $VCS_WC_MODIFIED = 0; 20 | 21 | # end 22 | 1; 23 | -------------------------------------------------------------------------------- /examples/autorevision.py: -------------------------------------------------------------------------------- 1 | # Generated by autorevision - do not hand-hack! 2 | 3 | VCS_TYPE = "git" 4 | VCS_BASENAME = "autorevision" 5 | VCS_UUID = "da2830f81fec4c6ebce8ebf23f35b0e6b066c149" 6 | VCS_NUM = 424 7 | VCS_DATE = "2017-09-26T03:57:45Z" 8 | VCS_BRANCH = "topic/gpg" 9 | VCS_TAG = "v/1.20" 10 | VCS_TAG_OPENPGP = "A16E4FE1BFE882DE9D6E28AD0044B6E72C414317" 11 | VCS_TICK = 16 12 | VCS_EXTRA = "" 13 | 14 | VCS_ACTION_STAMP = "2017-09-26T03:57:45Z!dak180@users.sourceforge.net" 15 | VCS_FULL_HASH = "c009f3afa47dc7cc2bcf789f37cdea8c91a32f5e" 16 | VCS_COMMIT_OPENPGP = "A16E4FE1BFE882DE9D6E28AD0044B6E72C414317" 17 | VCS_SHORT_HASH = "c009f3a" 18 | 19 | VCS_WC_MODIFIED = False 20 | 21 | # end 22 | -------------------------------------------------------------------------------- /examples/autorevision.rpm: -------------------------------------------------------------------------------- 1 | # Generated by autorevision - do not hand-hack! 2 | %define vcs_type git 3 | %define vcs_basename autorevision 4 | %define vcs_uuid da2830f81fec4c6ebce8ebf23f35b0e6b066c149 5 | %define vcs_num 424 6 | %define vcs_date 2017-09-26T03:57:45Z 7 | %define vcs_branch topic/gpg 8 | %define vcs_tag_openpgp A16E4FE1BFE882DE9D6E28AD0044B6E72C414317 9 | %define vcs_tag v/1.20 10 | %define vcs_tick 16 11 | 12 | 13 | %define vcs_action_stamp 2017-09-26T03:57:45Z!dak180@users.sourceforge.net 14 | %define vcs_full_hash c009f3afa47dc7cc2bcf789f37cdea8c91a32f5e 15 | %define vcs_commit_openpgp A16E4FE1BFE882DE9D6E28AD0044B6E72C414317 16 | %define vcs_short_hash c009f3a 17 | 18 | %define vcs_wc_modified 0 19 | # end 20 | -------------------------------------------------------------------------------- /examples/autorevision.scheme: -------------------------------------------------------------------------------- 1 | ;; Generated by autorevision - do not hand-hack! 2 | (define VCS_TYPE "git") 3 | (define VCS_BASENAME "autorevision") 4 | (define VCS_UUID "da2830f81fec4c6ebce8ebf23f35b0e6b066c149") 5 | (define VCS_NUM 424) 6 | (define VCS_DATE "2017-09-26T03:57:45Z") 7 | (define VCS_BRANCH "topic/gpg") 8 | (define VCS_TAG "v/1.20") 9 | (define VCS_TAG_OPENPGP "A16E4FE1BFE882DE9D6E28AD0044B6E72C414317") 10 | (define VCS_TICK 16) 11 | (define VCS_EXTRA "") 12 | 13 | (define VCS_ACTION_STAMP "2017-09-26T03:57:45Z!dak180@users.sourceforge.net") 14 | (define VCS_FULL_HASH "c009f3afa47dc7cc2bcf789f37cdea8c91a32f5e") 15 | (define VCS_COMMIT_OPENPGP "A16E4FE1BFE882DE9D6E28AD0044B6E72C414317") 16 | (define VCS_SHORT_HASH "c009f3a") 17 | 18 | (define VCS_WC_MODIFIED #f) 19 | ;; end 20 | -------------------------------------------------------------------------------- /examples/autorevision.sed: -------------------------------------------------------------------------------- 1 | # Generated by autorevision - do not hand-hack! 2 | 3 | s|@VCS_TYPE@|git|g 4 | s|@VCS_BASENAME@|autorevision|g 5 | s|@VCS_UUID@|da2830f81fec4c6ebce8ebf23f35b0e6b066c149|g 6 | s|@VCS_NUM@|424|g 7 | s|@VCS_DATE@|2017-09-26T03:57:45Z|g 8 | s|@VCS_BRANCH@|topic/gpg|g 9 | s|@VCS_TAG@|v/1.20|g 10 | s|@VCS_TAG_OPENPGP@|A16E4FE1BFE882DE9D6E28AD0044B6E72C414317|g 11 | s|@VCS_TICK@|16|g 12 | s|@VCS_EXTRA@||g 13 | 14 | s|@VCS_ACTION_STAMP@|2017-09-26T03:57:45Z!dak180@users.sourceforge.net|g 15 | s|@VCS_FULL_HASH@|c009f3afa47dc7cc2bcf789f37cdea8c91a32f5e|g 16 | s|@VCS_COMMIT_OPENPGP@|A16E4FE1BFE882DE9D6E28AD0044B6E72C414317|g 17 | s|@VCS_SHORT_HASH@|c009f3a|g 18 | 19 | s|@VCS_WC_MODIFIED@|0|g 20 | 21 | # end 22 | -------------------------------------------------------------------------------- /examples/autorevision.sh: -------------------------------------------------------------------------------- 1 | # Generated by autorevision - do not hand-hack! 2 | 3 | VCS_TYPE="git" 4 | VCS_BASENAME="autorevision" 5 | VCS_UUID="da2830f81fec4c6ebce8ebf23f35b0e6b066c149" 6 | VCS_NUM="424" 7 | VCS_DATE="2017-09-26T03:57:45Z" 8 | VCS_BRANCH="topic/gpg" 9 | VCS_TAG="v/1.20" 10 | VCS_TAG_OPENPGP="A16E4FE1BFE882DE9D6E28AD0044B6E72C414317" 11 | VCS_TICK="16" 12 | VCS_EXTRA="" 13 | 14 | VCS_ACTION_STAMP="2017-09-26T03:57:45Z!dak180@users.sourceforge.net" 15 | VCS_FULL_HASH="c009f3afa47dc7cc2bcf789f37cdea8c91a32f5e" 16 | VCS_COMMIT_OPENPGP="A16E4FE1BFE882DE9D6E28AD0044B6E72C414317" 17 | VCS_SHORT_HASH="c009f3a" 18 | 19 | VCS_WC_MODIFIED="0" 20 | 21 | # end 22 | -------------------------------------------------------------------------------- /examples/autorevision.swift: -------------------------------------------------------------------------------- 1 | /* Generated by autorevision - do not hand-hack! */ 2 | 3 | let VCS_TYPE = "git" 4 | let VCS_BASENAME = "autorevision" 5 | let VCS_UUID: String? = "da2830f81fec4c6ebce8ebf23f35b0e6b066c149" 6 | let VCS_NUM: Int = 424 7 | let VCS_DATE = "2017-09-26T03:57:45Z" 8 | let VCS_BRANCH: String = "topic/gpg" 9 | let VCS_TAG: String? = "v/1.20" 10 | let VCS_TAG_OPENPGP: String? = "A16E4FE1BFE882DE9D6E28AD0044B6E72C414317" 11 | let VCS_TICK: Int? = 16 12 | let VCS_EXTRA: String? = nil 13 | 14 | let VCS_ACTION_STAMP: String? = "2017-09-26T03:57:45Z!dak180@users.sourceforge.net" 15 | let VCS_FULL_HASH: String = "c009f3afa47dc7cc2bcf789f37cdea8c91a32f5e" 16 | let VCS_COMMIT_OPENPGP: String? = "A16E4FE1BFE882DE9D6E28AD0044B6E72C414317" 17 | let VCS_SHORT_HASH: String = "c009f3a" 18 | 19 | let VCS_WC_MODIFIED: Bool = false 20 | 21 | /* end */ 22 | -------------------------------------------------------------------------------- /examples/autorevision.tex: -------------------------------------------------------------------------------- 1 | % Generated by autorevision - do not hand-hack! 2 | \def \vcsType {git} 3 | \def \vcsBasename {autorevision} 4 | \def \vcsUUID {da2830f81fec4c6ebce8ebf23f35b0e6b066c149} 5 | \def \vcsNum {424} 6 | \def \vcsDate {2017-09-26T03:57:45Z} 7 | \def \vcsBranch {topic/gpg} 8 | \def \vcsTag {v/1.20} 9 | \def \vcsTagOpenpgp {A16E4FE1BFE882DE9D6E28AD0044B6E72C414317} 10 | \def \vcsTick {16} 11 | \def \vcsExtra {} 12 | \def \vcsACTIONSTAMP {2017-09-26T03:57:45Z!dak180@users.sourceforge.net} 13 | \def \vcsFullHash {c009f3afa47dc7cc2bcf789f37cdea8c91a32f5e} 14 | \def \vcsCommitOpenpgp {A16E4FE1BFE882DE9D6E28AD0044B6E72C414317} 15 | \def \vcsShortHash {c009f3a} 16 | \def \vcsWCModified {false} 17 | \endinput 18 | -------------------------------------------------------------------------------- /examples/autorevision.xcode: -------------------------------------------------------------------------------- 1 | /* Generated by autorevision - do not hand-hack! */ 2 | #ifndef AUTOREVISION_H 3 | #define AUTOREVISION_H 4 | 5 | #define VCS_TYPE git 6 | #define VCS_BASENAME autorevision 7 | #define VCS_UUID da2830f81fec4c6ebce8ebf23f35b0e6b066c149 8 | #define VCS_NUM 424 9 | #define VCS_DATE 2017-09-26T03:57:45Z 10 | #define VCS_BRANCH topic/gpg 11 | #define VCS_TAG v/1.20 12 | #define VCS_TAG_OPENPGP A16E4FE1BFE882DE9D6E28AD0044B6E72C414317 13 | #define VCS_TICK 16 14 | #define VCS_EXTRA 15 | 16 | #define VCS_ACTION_STAMP 2017-09-26T03:57:45Z!dak180@users.sourceforge.net 17 | #define VCS_FULL_HASH c009f3afa47dc7cc2bcf789f37cdea8c91a32f5e 18 | #define VCS_COMMIT_OPENPGP A16E4FE1BFE882DE9D6E28AD0044B6E72C414317 19 | #define VCS_SHORT_HASH c009f3a 20 | 21 | #define VCS_WC_MODIFIED 0 22 | 23 | #endif 24 | 25 | /* end */ 26 | -------------------------------------------------------------------------------- /examples/mkexamp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # List of formats (short names). 4 | read -d '' formats << EOF 5 | c 6 | clojure 7 | cmake 8 | csharp 9 | h 10 | hpp 11 | ini 12 | java 13 | javaprop 14 | js 15 | json 16 | lua 17 | m4 18 | matlab 19 | octave 20 | php 21 | pl 22 | py 23 | rpm 24 | scheme 25 | sed 26 | sh 27 | swift 28 | tex 29 | xcode 30 | EOF 31 | 32 | cd "$(git rev-parse --show-toplevel)" 33 | 34 | ./autorevision.sh -o autorevision.cache -t h 35 | 36 | for type in ${formats}; do 37 | ./autorevision.sh -o autorevision.cache -f -t "${type}" > "examples/autorevision.${type}" 38 | done 39 | -------------------------------------------------------------------------------- /logo.svg.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | #define VCS_TYPE                    "@VCS_TYPE@" 13 | #define VCS_BASENAME        "@VCS_BASENAME@" 14 | #define VCS_UUID                    "@VCS_UUID@" 15 | #define VCS_NUM                    @VCS_NUM@ 16 | #define VCS_DATE                    "@VCS_DATE@" 17 | #define VCS_BRANCH            "@VCS_BRANCH@" 18 | #define VCS_TAG                    "@VCS_TAG@" 19 | #define VCS_TICK                    @VCS_TICK@ 20 | #define VCS_FULL_HASH            "@VCS_FULL_HASH@" 21 | #define VCS_SHORT_HASH        "@VCS_SHORT_HASH@" 22 | #define VCS_WC_MODIFIED        @VCS_WC_MODIFIED@ 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This test script makes a number of assumptions about its environment 4 | # and therefore is not meant to be portable or even to be run from 5 | # outside Autorevision's repository. 6 | 7 | # Prep 8 | set -e 9 | export VCS_EXTRA="test" 10 | make tarball 11 | 12 | # Configure 13 | testPath="$(cd "$(dirname "$0")"; pwd -P)" 14 | vers="$(./autorevision -fo ./autorevision.cache -s VCS_TAG | sed -e 's:v/::')" 15 | tdir="autorevision-${vers}" 16 | tarball="${tdir}.tgz" 17 | tmpdir="$(mktemp -dqt autorevision)" 18 | 19 | 20 | # Copy the tarball to a temp directory 21 | cp -a "${tarball}" "${tmpdir}" 22 | 23 | cd "${tmpdir}" 24 | 25 | # Decompress 26 | tar -xf "${tarball}" 27 | 28 | cd "${tdir}" 29 | 30 | # Poke it to see it does anything 31 | make clean 32 | 33 | # Test out of repo results. 34 | cmp "autorevision.cache" "${testPath}/autorevision.cache" 35 | 36 | 37 | # Test cache pollution. 38 | cd "${testPath}" 39 | 40 | ./autorevision.sh -o "./autorevision.cache" -t "swift" -e "TEST" 41 | 42 | cmp "autorevision.cache" "${tmpdir}/${tdir}/autorevision.cache" 43 | --------------------------------------------------------------------------------