Skip to content

Commit

Permalink
gittip: Use subprocess.PIPE instead for Python 3.6 compatibility (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
kazarmy authored Aug 6, 2022
1 parent b856363 commit dc8cd44
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
1 change: 0 additions & 1 deletion librz/util/str.c
Original file line number Diff line number Diff line change
Expand Up @@ -4067,7 +4067,6 @@ RZ_API char *rz_str_version(const char *program) {
if (!gittip || !*rz_str_trim_head_ro(gittip)) {
goto done;
}
rz_str_trim(gittip);
rz_strbuf_append(sb, "\n");
rz_strbuf_appendf(sb, "commit: %s", gittip);
done:
Expand Down
1 change: 0 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,6 @@ if git_exe.found() and fs.exists('.git')
build_by_default: true,
output: 'gittip',
command: [py3_exe, git_exe_repo_py, git_exe, repo, 'rev-parse', 'HEAD'],
capture: true,
install: true,
install_dir: rizin_bindir
)
Expand Down
11 changes: 8 additions & 3 deletions sys/meson_git_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@ def isCArgSupported(executable, path):
return False


def simple_git_execution(args):
def simple_git_execution(args, gittip_dir=None):
try:
called = subprocess.run(args, check=True)
called = subprocess.run(args, check=True, stdout=subprocess.PIPE)
if gittip_dir is not None:
os.chdir(gittip_dir)
with open("gittip", "w", encoding="utf8") as f:
f.write(called.stdout.decode("utf8").strip())
sys.exit(called.returncode)
except subprocess.CalledProcessError as e:
sys.exit(e.returncode)
Expand Down Expand Up @@ -53,8 +57,9 @@ def main():
if isCArgSupported(git_exe, repo_path):
simple_git_execution([git_exe, "-C", repo_path] + args)
else:
gittip_dir = os.getcwd()
os.chdir(repo_path)
simple_git_execution([git_exe] + args)
simple_git_execution([git_exe] + args, gittip_dir)


if __name__ == "__main__":
Expand Down

0 comments on commit dc8cd44

Please sign in to comment.