Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
dumux
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dumux-repositories
dumux
Commits
9ecda465
Commit
9ecda465
authored
3 years ago
by
Dennis Gläser
Browse files
Options
Downloads
Patches
Plain Diff
[bin][getchangedfiles] prefer subprocess' cwd over chdir
parent
65f3548b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!2626
feature/refactor-test-selection
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bin/testing/getchangedfiles.py
+11
-11
11 additions, 11 deletions
bin/testing/getchangedfiles.py
with
11 additions
and
11 deletions
bin/testing/getchangedfiles.py
+
11
−
11
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
"
)
This diff is collapsed.
Click to expand it.
Dennis Gläser
@DennisGlaeser
mentioned in commit
bffd84f3
·
3 years ago
mentioned in commit
bffd84f3
mentioned in commit bffd84f3e6ec5ada85159c7e22c9ac6906e7c60b
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment