rkrahl / git-props Goto Github PK
View Code? Open in Web Editor NEWDetermine some properties from a git repository
License: Apache License 2.0
Determine some properties from a git repository
License: Apache License 2.0
Add documentation.
Review the test cases to make the test suite more concise and at the same time to make sure all relevant situations are covered.
The functions get_version()
, get_last_release()
and get_date()
defined in __init__.py
, e.g. at package level, are intended to provide a high level API. They raise LookupError
if they are unable to provide the requested information, for instance on any error returned from git, which usually happens if invoked outside of a git repository. This is the intended behavior. But if git itself is not installed, the GitRepo()
constructor raises FileNotFoundError
, which is not caught:
Traceback (most recent call last):
File "/home/abuild/test/pytest-dependency-0.6.0/setup.py", line 26, in <module>
release = str(gitprops.get_last_release())
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/python/lib/python3.12/site-packages/gitprops/__init__.py", line 31, in get_last_release
repo = _get_repo(root)
^^^^^^^^^^^^^^^
File "/opt/python/lib/python3.12/site-packages/gitprops/__init__.py", line 17, in _get_repo
_repo_cache[root] = GitRepo(root)
^^^^^^^^^^^^^
File "/opt/python/lib/python3.12/site-packages/gitprops/repo.py", line 41, in __init__
self.git_version = self._exec("git version")
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/python/lib/python3.12/site-packages/gitprops/repo.py", line 25, in _exec
proc = subprocess.run(cmd.split(),
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/python/lib/python3.12/subprocess.py", line 548, in run
with Popen(*popenargs, **kwargs) as process:
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/python/lib/python3.12/subprocess.py", line 1026, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/opt/python/lib/python3.12/subprocess.py", line 1950, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'git'
This should also be translated to LookupError
, because that belongs to the same class of errors from the callers perspective.
Consider the following simple history:
* commit bec5f8f (HEAD -> simple)
| Author: Someone <[email protected]>
| Date: Mon Jan 1 18:41:38 2024 +0000
|
| Edit README, now for case simple
|
* commit 3e999aa
| Author: Someone <[email protected]>
| Date: Mon Jan 1 18:37:29 2024 +0000
|
| Add stuff to the pile
|
* commit 4ce18d6 (tag: v1.0)
| Author: Someone <[email protected]>
| Date: Mon Jan 1 18:33:37 2024 +0000
|
| Add README for case ver
|
* commit 0e65d11
Author: Someone <[email protected]>
Date: Mon Jan 1 18:33:07 2024 +0000
Add stuff to the pile
Running gitprops version
on that yields the expected result:
$ python3 -m gitprops version
1.1.dev2+gbec5f8f
But now consider the case that the corresponding commit has more than one version tag, as in:
* commit bec5f8f (HEAD -> simple)
| Author: Someone <[email protected]>
| Date: Mon Jan 1 18:41:38 2024 +0000
|
| Edit README, now for case simple
|
* commit 3e999aa
| Author: Someone <[email protected]>
| Date: Mon Jan 1 18:37:29 2024 +0000
|
| Add stuff to the pile
|
* commit 4ce18d6 (tag: v1.0b1, tag: v1.0)
| Author: Someone <[email protected]>
| Date: Mon Jan 1 18:33:37 2024 +0000
|
| Add README for case ver
|
* commit 0e65d11
Author: Someone <[email protected]>
Date: Mon Jan 1 18:33:07 2024 +0000
Add stuff to the pile
In that case, gitprops version
should yield the same result. But apparently, it fails to recognize any version tag in the history:
$ python3 -m gitprops version
0.1.dev4+gbec5f8f
This package has been created with the intention to replace setuptools_scm
for my own packages. It should thus also be used in this package itself to manage the version number.
Obviously this seem to create a circular dependency if git-props
is needed to build git-props
itself. But in fact, this is not really a problem, because any version of git-props
will do. So we may use the already released version git-props
0.1 to build newer versions of git-props
starting with 0.2.
Add a __main__.py file to provide a command line interface.
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.