From: "Arthur Zamarin" <arthurzam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/pkgcore/pkgdev:main commit in: src/pkgdev/
Date: Fri, 21 Apr 2023 08:03:19 +0000 (UTC) [thread overview]
Message-ID: <1682064143.a339f3b4891e8e79b1c4b7145431de23b2b78d02.arthurzam@gentoo> (raw)
commit: a339f3b4891e8e79b1c4b7145431de23b2b78d02
Author: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Fri Apr 21 08:02:23 2023 +0000
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Fri Apr 21 08:02:23 2023 +0000
URL: https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=a339f3b4
git: declare PKGDEV=1 env for git commands
Can be used in git hooks to verify if we are running inside a pkgdev
call.
Resolves: https://github.com/pkgcore/pkgdev/issues/133
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>
src/pkgdev/git.py | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/pkgdev/git.py b/src/pkgdev/git.py
index cc96716..55e1fae 100644
--- a/src/pkgdev/git.py
+++ b/src/pkgdev/git.py
@@ -1,3 +1,4 @@
+import os
import subprocess
import sys
@@ -12,6 +13,7 @@ def run(*args, **kwargs):
"""Wrapper for running git via subprocess.run()."""
kwargs.setdefault("check", True)
kwargs.setdefault("text", True)
+ kwargs.setdefault("env", os.environ.copy())["PKGDEV"] = "1"
cmd = ["git"] + list(args)
# output git command that would be run to stderr
@@ -21,7 +23,7 @@ def run(*args, **kwargs):
try:
return subprocess.run(cmd, **kwargs)
- except FileNotFoundError as e:
- raise UserException(str(e))
- except subprocess.CalledProcessError as e:
- raise GitError(e.returncode)
+ except FileNotFoundError as exc:
+ raise UserException(str(exc))
+ except subprocess.CalledProcessError as exc:
+ raise GitError(exc.returncode)
next reply other threads:[~2023-04-21 8:03 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-21 8:03 Arthur Zamarin [this message]
-- strict thread matches above, loose matches on Subject: below --
2025-03-05 6:40 [gentoo-commits] proj/pkgcore/pkgdev:main commit in: src/pkgdev/ Arthur Zamarin
2024-03-21 20:08 Arthur Zamarin
2024-02-10 15:00 Arthur Zamarin
2023-12-07 20:31 Arthur Zamarin
2023-04-22 17:56 Arthur Zamarin
2023-03-17 6:11 Arthur Zamarin
2023-01-13 21:07 Arthur Zamarin
2022-12-02 10:39 Arthur Zamarin
2022-10-14 20:02 Arthur Zamarin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1682064143.a339f3b4891e8e79b1c4b7145431de23b2b78d02.arthurzam@gentoo \
--to=arthurzam@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox