ansemjo / version.sh Goto Github PK
View Code? Open in Web Editor NEWoutput identical version strings from repository clones or downloaded archives
License: MIT License
output identical version strings from repository clones or downloaded archives
License: MIT License
it seems the script doesn't work for an empty git repo.
it reports:
fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git [...] -- [...]'
fatal: bad revision 'HEAD'
version : commit
commit : unknown
When running Travis jobs on OSX and testing with SH=dash
it leads to weird sed
errors. See the Travis log.
Installing dash
via homebrew yields dash 0.5.10.2
and there are loads of errors like sed: 1: "s\/\-\\(\[0\-9\]\*\\)\- ...": substitute pattern can not be delimited by newline or backslash
. However, this is not what's in the script? There are no backslashes and the string is enclosed in single-quotes.
Does dash
do some transformations to the script upon running? Using dash 0.5.7-4ubuntu1
on Linux is fine ..
See 04186f9 for the relevant README update. There's a couple things to decide:
dash
and ksh
or shall I prefer bash
-specific constructs like BASH_REMATCH
?git
versions? This new change will require at least 3.32 .. just error out an require a new version or add fallbacks again and build the describe string manually as before?Omitting fallbacks and simply requiring modern versions of bash
and git
might make the script a lot more terse and readable.
Also I might take some "inspiration" from Kubernetes. I especially like the [[ '$Format:%%$' == "%" ]]
test to check if we're working from an archive directly.
in most cases a full 40 chars long commit id is not necessary, the leading 7 chars is long enough to distinguish it from others.
also, you limit the length to 7 by 'printf '%s%s%.7s\n' "$(version)" "$COMMIT_SEPERATOR" "$(commit)";' what if working space is dirty? (the "-dirty" will be truncated)
so why not using --abbrev=7 in git describe ?
also, to make it more brief, i think '--dirty=M --broken=W' is better than just '--dirty'.
i also suggest to show the branch name somewhere.
Originally posted by @zzuzhp in #4 (comment)
Afaik, the branch name is always present in the subsituted REFS
variable and can be trivially found if we're in a git repository.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.