Skip to content

Commit 6b7711a

Browse files
authored
Update git.py
1 parent 10c23fe commit 6b7711a

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

inlineplz/util/git.py

+13-12
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
# -*- coding: utf-8 -*-
22

3+
import os
34
import subprocess
45

56

67
def current_sha():
78
return (
8-
subprocess.check_output(["git", "rev-parse", "HEAD"])
9+
subprocess.check_output(["git", "rev-parse", "HEAD"], env=os.environ)
910
.strip()
1011
.decode("utf-8", errors="replace")
1112
)
1213

1314

1415
def diff(start, end):
1516
return subprocess.check_output(
16-
["git", "diff", "-M", "{}..{}".format(start, end)]
17+
["git", "diff", "-M", "{}..{}".format(start, end)], env=os.environ
1718
).decode("utf-8", errors="replace")
1819

1920

2021
def parent_sha(sha):
2122
return (
22-
subprocess.check_output(["git", "rev-list", "--parents", "-n", "1", sha])
23+
subprocess.check_output(["git", "rev-list", "--parents", "-n", "1", sha], env=os.environ)
2324
.strip()
2425
.split()[1]
2526
.decode("utf-8", errors="replace")
@@ -28,47 +29,47 @@ def parent_sha(sha):
2829

2930
def current_branch():
3031
return (
31-
subprocess.check_output(["git", "rev-parse", "--abbrev-ref", "HEAD"])
32+
subprocess.check_output(["git", "rev-parse", "--abbrev-ref", "HEAD"], env=os.environ)
3233
.strip()
3334
.decode("utf-8", errors="replace")
3435
)
3536

3637

3738
def url():
3839
return (
39-
subprocess.check_output(["git", "config", "--get", "remote.origin.url"])
40+
subprocess.check_output(["git", "config", "--get", "remote.origin.url"], env=os.environ)
4041
.strip()
4142
.decode("utf-8", errors="replace")
4243
)
4344

4445

4546
def fetch(git_url):
4647
return (
47-
subprocess.check_output(["git", "fetch", git_url])
48+
subprocess.check_output(["git", "fetch", git_url], env=os.environ)
4849
.strip()
4950
.decode("utf-8", errors="replace")
5051
)
5152

5253

5354
def add(filename):
5455
return (
55-
subprocess.check_output(["git", "add", filename])
56+
subprocess.check_output(["git", "add", filename], env=os.environ)
5657
.strip()
5758
.decode("utf-8", errors="replace")
5859
)
5960

6061

6162
def commit(message):
6263
return (
63-
subprocess.check_output(["git", "commit", "-m", message])
64+
subprocess.check_output(["git", "commit", "-m", message], env=os.environ)
6465
.strip()
6566
.decode("utf-8", errors="replace")
6667
)
6768

6869

6970
def push(branch):
7071
return (
71-
subprocess.check_output(["git", "push", "origin", "{}".format(branch)])
72+
subprocess.check_output(["git", "push", "origin", "{}".format(branch)], env=os.environ)
7273
.strip()
7374
.decode("utf-8", errors="replace")
7475
)
@@ -78,7 +79,7 @@ def files_changed(files):
7879
files_with_changes = []
7980
for filename in files:
8081
if (
81-
subprocess.check_output(["git", "diff", "--name-only", filename])
82+
subprocess.check_output(["git", "diff", "--name-only", filename], env=os.environ)
8283
.strip()
8384
.decode("utf-8", errors="replace")
8485
):
@@ -88,7 +89,7 @@ def files_changed(files):
8889

8990
def set_remote(remote):
9091
return (
91-
subprocess.check_output(["git", "config", "remote.origin.url", remote])
92+
subprocess.check_output(["git", "config", "remote.origin.url", remote], env=os.environ)
9293
.strip()
9394
.decode("utf-8", errors="replace")
9495
)
@@ -98,5 +99,5 @@ def command(*args):
9899
git_command = ["git"]
99100
git_command.extend(args)
100101
return (
101-
subprocess.check_output(git_command).strip().decode("utf-8", errors="replace")
102+
subprocess.check_output(git_command, env=os.environ).strip().decode("utf-8", errors="replace")
102103
)

0 commit comments

Comments
 (0)