From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 9404E1581E7 for ; Fri, 26 Apr 2024 22:06:08 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 54C39E29D5; Fri, 26 Apr 2024 22:06:07 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 2C411E29CF for ; Fri, 26 Apr 2024 22:06:07 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 24CEB340806 for ; Fri, 26 Apr 2024 22:06:06 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 7FC2B173B for ; Fri, 26 Apr 2024 22:06:04 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1714169148.381fad5e3554ec94ec5626e8c17874f32b30b752.sam@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: lib/portage/ X-VCS-Repository: proj/portage X-VCS-Files: lib/portage/__init__.py X-VCS-Directories: lib/portage/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: 381fad5e3554ec94ec5626e8c17874f32b30b752 X-VCS-Branch: master Date: Fri, 26 Apr 2024 22:06:04 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 0b816bbe-f8a1-455f-8b5f-17ea1e48c684 X-Archives-Hash: 36b30b95a3fca4ea7fdc800440da05f2 commit: 381fad5e3554ec94ec5626e8c17874f32b30b752 Author: Sam James gentoo org> AuthorDate: Tue Aug 29 07:26:36 2023 +0000 Commit: Sam James gentoo org> CommitDate: Fri Apr 26 22:05:48 2024 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=381fad5e lib: use more pure git-describe output for --version Use `git describe --dirty` output rather than mangling git-describe and reinventing --dirty by manually checking for changes post-commit. We no longer mangle the 7th commit post-tag into _p7, but instead do: ${tag}-7-${last_commit}. This is similar to gnulib's git-version-gen (which we may still want to import, not sure, this seems enough for now) and is familiar output for developers. Example: * Old: 3.0.51_p7 * New: 3.0.51-7-g098b30548 Bug: https://bugs.gentoo.org/912209 Signed-off-by: Sam James gentoo.org> lib/portage/__init__.py | 35 ++++------------------------------- 1 file changed, 4 insertions(+), 31 deletions(-) diff --git a/lib/portage/__init__.py b/lib/portage/__init__.py index aa81bdb4c2..a468eeaff3 100644 --- a/lib/portage/__init__.py +++ b/lib/portage/__init__.py @@ -720,10 +720,7 @@ if installation.TYPE == installation.TYPES.SOURCE: BASH_BINARY, "-c", ( - f"cd {_shell_quote(PORTAGE_BASE_PATH)} ; git describe --match 'portage-*' || exit $? ; " - 'if [ -n "`git diff-index --name-only --diff-filter=M HEAD`" ] ; ' - "then echo modified ; git rev-list --format=%%ct -n 1 HEAD ; fi ; " - "exit 0" + f"cd {_shell_quote(PORTAGE_BASE_PATH)} ; git describe --dirty --match 'portage-*' || exit $? ; " ), ] cmd = [ @@ -735,33 +732,9 @@ if installation.TYPE == installation.TYPES.SOURCE: output = _unicode_decode(proc.communicate()[0], encoding=encoding) status = proc.wait() if os.WIFEXITED(status) and os.WEXITSTATUS(status) == os.EX_OK: - output_lines = output.splitlines() - if output_lines: - version_split = output_lines[0].split("-") - if len(version_split) > 1: - VERSION = version_split[1] - patchlevel = False - if len(version_split) > 2: - patchlevel = True - VERSION = f"{VERSION}_p{version_split[2]}" - if len(output_lines) > 1 and output_lines[1] == "modified": - head_timestamp = None - if len(output_lines) > 3: - try: - head_timestamp = int(output_lines[3]) - except ValueError: - pass - timestamp = int(time.time()) - if ( - head_timestamp is not None - and timestamp > head_timestamp - ): - timestamp = timestamp - head_timestamp - if not patchlevel: - VERSION = f"{VERSION}_p0" - VERSION = f"{VERSION}_p{timestamp}" - return VERSION - VERSION = "HEAD" + VERSION = output.lstrip('portage-').strip() + else: + VERSION = "HEAD" return VERSION VERSION = _LazyVersion()