Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
dumux-repositories
dumux
Commits
9ecda465
Commit
9ecda465
authored
May 20, 2021
by
Dennis Gläser
Browse files
[bin][getchangedfiles] prefer subprocess' cwd over chdir
parent
65f3548b
Changes
1
Hide whitespace changes
Inline
Side-by-side
bin/testing/getchangedfiles.py
View file @
9ecda465
...
...
@@ -9,23 +9,24 @@ import subprocess
from
argparse
import
ArgumentParser
def
getCommandOutput
(
command
):
return
subprocess
.
check_output
(
command
,
encoding
=
'ascii'
)
def
getCommandOutput
(
command
,
cwd
=
None
):
return
subprocess
.
check_output
(
command
,
encoding
=
'ascii'
,
cwd
=
cwd
)
# get the files that differ between two trees in a git repo
def
getChangedFiles
(
gitFolder
,
sourceTree
,
targetTree
):
owd
=
os
.
getcwd
()
os
.
chdir
(
os
.
path
.
abspath
(
gitFolder
))
root
=
getCommandOutput
([
'git'
,
'rev-parse'
,
'--show-toplevel'
]).
strip
(
'
\n
'
)
gitFolder
=
os
.
path
.
abspath
(
gitFolder
)
root
=
getCommandOutput
(
command
=
[
'git'
,
'rev-parse'
,
'--show-toplevel'
],
cwd
=
gitFolder
).
strip
(
'
\n
'
)
changedFiles
=
getCommandOutput
(
[
"git"
,
"diff-tree"
,
"-r"
,
"--name-only"
,
sourceTree
,
targetTree
],
command
=
[
"git"
,
"diff-tree"
,
"-r"
,
"--name-only"
,
sourceTree
,
targetTree
],
cwd
=
gitFolder
).
splitlines
()
changedFiles
=
[
os
.
path
.
join
(
root
,
file
)
for
file
in
changedFiles
]
os
.
chdir
(
owd
)
return
changedFiles
return
[
os
.
path
.
join
(
root
,
file
)
for
file
in
changedFiles
]
if
__name__
==
'__main__'
:
...
...
@@ -54,5 +55,4 @@ if __name__ == '__main__':
with
open
(
args
[
'outfile'
],
'w'
)
as
outFile
:
for
file
in
changedFiles
:
outFile
.
write
(
os
.
path
.
abspath
(
file
))
outFile
.
write
(
'
\n
'
)
outFile
.
write
(
f
"
{
os
.
path
.
abspath
(
file
)
}
\n
"
)
Dennis Gläser
@DennisGlaeser
mentioned in commit
bffd84f3
·
Jun 02, 2021
mentioned in commit
bffd84f3
mentioned in commit bffd84f3e6ec5ada85159c7e22c9ac6906e7c60b
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment