Skip to content

Commit

Permalink
Merge pull request ESCOMP#198 from johnpaulalex/gitdir
Browse files Browse the repository at this point in the history
Replace a lot of chdir's with git -C $dirname

There are still some left in the code.

There are still 6 calls to os.getcwd in manic/ (at least 1 is ok, the one in checkout.py), and 6 calls to os.chdir (2 in repository_svn, 4 in sourcetree). At least some of those can probably go away too.

And loads of dependencies on cwd in test/ code, but many if not all could be fixed in the same way (with the -C option)

User interface changes?: No

Fixes: No

Testing:
test removed: no
unit tests: 'make utest'
system tests: 'make stest'
manual testing: none
  • Loading branch information
billsacks authored Mar 3, 2023
2 parents 927ce3a + d9c14bf commit 7b6d92e
Show file tree
Hide file tree
Showing 6 changed files with 219 additions and 248 deletions.
6 changes: 2 additions & 4 deletions manic/externals_description.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,8 @@ def git_submodule_status(repo_dir):
"""Run the git submodule status command to obtain submodule hashes.
"""
# This function is here instead of GitRepository to avoid a dependency loop
cwd = os.getcwd()
os.chdir(repo_dir)
cmd = ['git', 'submodule', 'status']
cmd = 'git -C {repo_dir} submodule status'.format(
repo_dir=repo_dir).split()
git_output = execute_subprocess(cmd, output_to_caller=True)
submodules = {}
submods = git_output.split('\n')
Expand All @@ -168,7 +167,6 @@ def git_submodule_status(repo_dir):

submodules[items[1]] = {'hash':items[0], 'status':status, 'tag':tag}

os.chdir(cwd)
return submodules

def parse_submodules_desc_section(section_items, file_path):
Expand Down
Loading

0 comments on commit 7b6d92e

Please sign in to comment.