Skip to content

Commit

Permalink
fixup! [WIP] pyinfra/operations: git.config to manage system-level …
Browse files Browse the repository at this point in the history
…config
  • Loading branch information
Pirols committed Sep 26, 2024
1 parent 29a3063 commit 12cf8da
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions pyinfra/facts/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ def process(self, output):
class GitConfig(GitFactBase):
default = dict

def command(self, repo=None) -> str:
def command(self, repo=None, system=False) -> str:
if repo is None:
return "git config --global -l || true"
level = "--system" if system else "--global"
return f"git config {level} -l || true"

return "! test -d {0} || (cd {0} && git config --local -l)".format(repo)

Expand Down
2 changes: 1 addition & 1 deletion pyinfra/operations/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def config(key: str, value: str, multi_value=False, repo: str | None = None, sys
existing_config = {}

if not repo:
existing_config = host.get_fact(GitConfig)
existing_config = host.get_fact(GitConfig, system=system)

# Only get the config if the repo exists at this stage
elif host.get_fact(Directory, path=unix_path_join(repo, ".git")):
Expand Down

0 comments on commit 12cf8da

Please sign in to comment.