grim/local-pipelines

Parents f5dcfe140c79
Children 5ebfb03a8864
vcs: add generic method that will run git and hg commands
--- a/pipelines/vcs.py Thu Jul 28 13:55:01 2016 -0500
+++ b/pipelines/vcs.py Wed Jul 27 22:15:09 2016 -0700
@@ -28,6 +28,23 @@
}
+def run_command(cmd, path):
+ env = os.environ.copy()
+
+ # ignore user's config
+ env['HGRCPATH'] = '/dev/null'
+ env['HOME'] = '/tmp'
+ env['GIT_CONFIG_NOSYSTEM'] = '1'
+
+ try:
+ return subprocess.check_output(cmd.split(),
+ env=env,
+ stderr=open(os.devnull, 'w'),
+ cwd=path).strip()
+ except subprocess.CalledProcessError:
+ return ''
+
+
def get_branch(path):
branch = None
env = os.environ.copy()