Add `git_config` fact.
@@ -8,5 +8,25 @@ from pyinfra.api.facts import FactBase
class GitBranch(FactBase):
- def command(self, name):
- return 'cd {0} && git rev-parse --abbrev-ref HEAD'.format(name)
+ @staticmethod
+ def command(repo):
+ return 'cd {0} && git rev-parse --abbrev-ref HEAD'.format(repo)
+
+
+class GitConfig(FactBase):
+ @staticmethod
+ def command(repo=None):
+ if repo is None:
+ return 'git config --global -l'
+
+ return 'cd {0} && git config --local -l'.format(repo)
+
+ @staticmethod
+ def process(output):
+ items = {}
+
+ for line in output:
+ key, value = line.split('=', 1)
+ items[key] = value
+
+ return items
