1
1
# -*- coding: utf-8 -*-
2
2
3
+ import os
3
4
import subprocess
4
5
5
6
6
7
def current_sha ():
7
8
return (
8
- subprocess .check_output (["git" , "rev-parse" , "HEAD" ])
9
+ subprocess .check_output (["git" , "rev-parse" , "HEAD" ], env = os . environ )
9
10
.strip ()
10
11
.decode ("utf-8" , errors = "replace" )
11
12
)
12
13
13
14
14
15
def diff (start , end ):
15
16
return subprocess .check_output (
16
- ["git" , "diff" , "-M" , "{}..{}" .format (start , end )]
17
+ ["git" , "diff" , "-M" , "{}..{}" .format (start , end )], env = os . environ
17
18
).decode ("utf-8" , errors = "replace" )
18
19
19
20
20
21
def parent_sha (sha ):
21
22
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 )
23
24
.strip ()
24
25
.split ()[1 ]
25
26
.decode ("utf-8" , errors = "replace" )
@@ -28,47 +29,47 @@ def parent_sha(sha):
28
29
29
30
def current_branch ():
30
31
return (
31
- subprocess .check_output (["git" , "rev-parse" , "--abbrev-ref" , "HEAD" ])
32
+ subprocess .check_output (["git" , "rev-parse" , "--abbrev-ref" , "HEAD" ], env = os . environ )
32
33
.strip ()
33
34
.decode ("utf-8" , errors = "replace" )
34
35
)
35
36
36
37
37
38
def url ():
38
39
return (
39
- subprocess .check_output (["git" , "config" , "--get" , "remote.origin.url" ])
40
+ subprocess .check_output (["git" , "config" , "--get" , "remote.origin.url" ], env = os . environ )
40
41
.strip ()
41
42
.decode ("utf-8" , errors = "replace" )
42
43
)
43
44
44
45
45
46
def fetch (git_url ):
46
47
return (
47
- subprocess .check_output (["git" , "fetch" , git_url ])
48
+ subprocess .check_output (["git" , "fetch" , git_url ], env = os . environ )
48
49
.strip ()
49
50
.decode ("utf-8" , errors = "replace" )
50
51
)
51
52
52
53
53
54
def add (filename ):
54
55
return (
55
- subprocess .check_output (["git" , "add" , filename ])
56
+ subprocess .check_output (["git" , "add" , filename ], env = os . environ )
56
57
.strip ()
57
58
.decode ("utf-8" , errors = "replace" )
58
59
)
59
60
60
61
61
62
def commit (message ):
62
63
return (
63
- subprocess .check_output (["git" , "commit" , "-m" , message ])
64
+ subprocess .check_output (["git" , "commit" , "-m" , message ], env = os . environ )
64
65
.strip ()
65
66
.decode ("utf-8" , errors = "replace" )
66
67
)
67
68
68
69
69
70
def push (branch ):
70
71
return (
71
- subprocess .check_output (["git" , "push" , "origin" , "{}" .format (branch )])
72
+ subprocess .check_output (["git" , "push" , "origin" , "{}" .format (branch )], env = os . environ )
72
73
.strip ()
73
74
.decode ("utf-8" , errors = "replace" )
74
75
)
@@ -78,7 +79,7 @@ def files_changed(files):
78
79
files_with_changes = []
79
80
for filename in files :
80
81
if (
81
- subprocess .check_output (["git" , "diff" , "--name-only" , filename ])
82
+ subprocess .check_output (["git" , "diff" , "--name-only" , filename ], env = os . environ )
82
83
.strip ()
83
84
.decode ("utf-8" , errors = "replace" )
84
85
):
@@ -88,7 +89,7 @@ def files_changed(files):
88
89
89
90
def set_remote (remote ):
90
91
return (
91
- subprocess .check_output (["git" , "config" , "remote.origin.url" , remote ])
92
+ subprocess .check_output (["git" , "config" , "remote.origin.url" , remote ], env = os . environ )
92
93
.strip ()
93
94
.decode ("utf-8" , errors = "replace" )
94
95
)
@@ -98,5 +99,5 @@ def command(*args):
98
99
git_command = ["git" ]
99
100
git_command .extend (args )
100
101
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" )
102
103
)
0 commit comments