diff options
author | spreis <spreis@yandex-team.ru> | 2022-05-04 16:07:57 +0300 |
---|---|---|
committer | spreis <spreis@yandex-team.ru> | 2022-05-04 16:07:57 +0300 |
commit | 2bf267dc25ea20521a562ebca8bf5c57af7be290 (patch) | |
tree | f07850976fccf00bd42d90be15c12576eee3b0cf /library/python/svn_version | |
parent | 4b3463e0a8c1b2c11eb8cd38f359e554f63e7a33 (diff) | |
download | ydb-2bf267dc25ea20521a562ebca8bf5c57af7be290.tar.gz |
Introduce method to get vcs in library/python/svn_version
ref:3cdcb0b0558a4896ab20082ec37672275dfe59b9
Diffstat (limited to 'library/python/svn_version')
-rw-r--r-- | library/python/svn_version/__init__.py | 2 | ||||
-rw-r--r-- | library/python/svn_version/__svn_version.pyx | 4 | ||||
-rw-r--r-- | library/python/svn_version/ut/test_simple.py | 10 |
3 files changed, 12 insertions, 4 deletions
diff --git a/library/python/svn_version/__init__.py b/library/python/svn_version/__init__.py index 7ef7d6dac7..7eeb9573e8 100644 --- a/library/python/svn_version/__init__.py +++ b/library/python/svn_version/__init__.py @@ -1 +1 @@ -from .__svn_version import svn_version, commit_id, svn_revision, svn_last_revision, hash, svn_branch, svn_tag, patch_number # noqa +from .__svn_version import svn_version, commit_id, svn_revision, svn_last_revision, hash, svn_branch, svn_tag, patch_number, vcs # noqa diff --git a/library/python/svn_version/__svn_version.pyx b/library/python/svn_version/__svn_version.pyx index d66bc09d24..95f74f525e 100644 --- a/library/python/svn_version/__svn_version.pyx +++ b/library/python/svn_version/__svn_version.pyx @@ -1,6 +1,7 @@ import future.utils as fu cdef extern from "library/cpp/svnversion/svnversion.h": + cdef const char* GetVCS() except +; cdef const char* GetProgramSvnVersion() except +; cdef int GetProgramSvnRevision() except +; cdef int GetArcadiaLastChangeNum() except +; @@ -33,3 +34,6 @@ def svn_tag(): def patch_number(): return GetArcadiaPatchNumber() + +def vcs(): + return fu.bytes_to_native_str(GetVCS()) diff --git a/library/python/svn_version/ut/test_simple.py b/library/python/svn_version/ut/test_simple.py index 0eb94ccbbc..50fa78f55d 100644 --- a/library/python/svn_version/ut/test_simple.py +++ b/library/python/svn_version/ut/test_simple.py @@ -5,12 +5,16 @@ def test_simple(): assert sv.svn_version() assert isinstance(sv.svn_version(), str) - # svn_revision() will be equal to zero on non-trunk commits - assert sv.svn_revision() >= 0 + assert sv.vcs() + assert isinstance(sv.vcs(), str) + + # svn_revision() will be -1 on non-trunk commits via arc + # svn revision of 0 technically may exist, but practiacally it will never appear here + assert sv.svn_revision() >= 0 or (sv.vcs() != "svn" and sv.svn_revision() == -1) assert isinstance(sv.svn_revision(), int) # svn_last_revision() will be equal to zero on non-trunk commits - assert sv.svn_last_revision() >= 0 + assert sv.svn_last_revision() >= 0 or (sv.vcs() != "svn" and sv.svn_last_revision() == -1) assert isinstance(sv.svn_last_revision(), int) assert sv.commit_id() |