Skip to content

Commit 9d4dd18

Browse files
Backing down on being opinionated
Since Jetbrains IDEs are currently not working with docker --tty I removed forcing the TTY. You will have to add in manually if you need it.
1 parent bfdf909 commit 9d4dd18

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/Hook/Template/Docker.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,14 @@ private function getOptimizeDockerCommand(string $hook): string
113113
$endExec = $position + 11;
114114
$executable = substr($command, 0, $endExec);
115115
$options = substr($command, $endExec);
116-
$tty = Hooks::allowsUserInput($hook) ? ' -t' : '';
117116

117+
// Because this currently breaks working with Jetbrains IDEs I will deactivate it for now
118+
//
119+
// $tty = Hooks::allowsUserInput($hook) ? ' -t' : '';
120+
// $useTTY = !preg_match('# -[a-z]*t| --tty#', $options) ? $tty : '';
121+
122+
$useTTY = '';
118123
$interactive = !preg_match('# -[a-z]*i| --interactive#', $options) ? ' -i' : '';
119-
$useTTY = !preg_match('# -[a-z]*t| --tty#', $options) ? $tty : '';
120124
$env = !preg_match('# (-[a-z]*e|--env)[= ]+GIT_INDEX_FILE#', $options) ? ' -e GIT_INDEX_FILE' : '';
121125
$command = trim($executable) . $interactive . $useTTY . $env . ' ' . trim($options);
122126
}

tests/unit/Hook/Template/DockerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,15 @@ public function testDockerCommandOptimization(string $exec, string $expected, st
117117
public function replacementPossibilities(): array
118118
{
119119
return [
120-
['cap-container', '-i -t -e GIT_INDEX_FILE cap-container', 'none'],
120+
['cap-container', '-i -e GIT_INDEX_FILE cap-container', 'none'],
121121
['-it cap-container', '-e GIT_INDEX_FILE -it cap-container', '-it'],
122122
['-ti cap-container', '-e GIT_INDEX_FILE -ti cap-container', '-ti'],
123123
['--interactive --tty cap-container', '-e GIT_INDEX_FILE --interactive --tty cap-container', 'long it'],
124124
['--tty --interactive cap-container', '-e GIT_INDEX_FILE --tty --interactive cap-container', 'long ti'],
125125
['--tty cap-container', '-i -e GIT_INDEX_FILE --tty cap-container', 'no i'],
126126
['-xit cap-container', '-e GIT_INDEX_FILE -xit cap-container', 'prefixed i'],
127127
['-xite=GIT_INDEX_FILE cap-container', '-xite=GIT_INDEX_FILE cap-container', 'prefixed e'],
128-
['--env=GIT_INDEX_FILE cap-container', '-i -t --env=GIT_INDEX_FILE cap-container', 'long e'],
128+
['--env=GIT_INDEX_FILE cap-container', '-i --env=GIT_INDEX_FILE cap-container', 'long e'],
129129
];
130130
}
131131
}

0 commit comments

Comments
 (0)