Skip to content

Commit 45370d4

Browse files
committed
Fix potential freezes when generating patches
- Make sure the process output is read before waiting for the process - Add --no-pager to ensure it doesn't open an interactive window
1 parent b45420e commit 45370d4

File tree

1 file changed

+6
-4
lines changed
  • src/main/groovy/net/minecrell/gitpatcher

1 file changed

+6
-4
lines changed

src/main/groovy/net/minecrell/gitpatcher/Git.groovy

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class Git {
4444
}
4545

4646
Command run(String name, Object input) {
47-
return new Command(['git', name.replace('_' as char, '-' as char), *input].execute(null as String[], repo))
47+
return new Command(['git', '--no-pager', name.replace('_' as char, '-' as char), *input].execute(null as String[], repo))
4848
}
4949

5050
@Override
@@ -57,7 +57,7 @@ class Git {
5757
final Process process
5858

5959
private Command(Process process) {
60-
this.process = process;
60+
this.process = process
6161
}
6262

6363
int run() {
@@ -94,13 +94,15 @@ class Git {
9494

9595
String getText() {
9696
setup(null, System.err)
97+
def text = process.inputStream.text.trim()
9798
execute()
98-
return process.inputStream.text.trim()
99+
return text
99100
}
100101

101102
String readText() {
102103
setup(null, System.err)
103-
return run() == 0 ? process.inputStream.text.trim() : null;
104+
def text = process.inputStream.text.trim()
105+
return run() == 0 ? text : null
104106
}
105107

106108
}

0 commit comments

Comments
 (0)