Skip to content

Commit

Permalink
add support for "env" parameter to system.run_cmd, make every git com…
Browse files Browse the repository at this point in the history
…mand that parses output use it
  • Loading branch information
Jacob Beck committed Jan 24, 2019
1 parent 7d332aa commit a4b77e4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
11 changes: 6 additions & 5 deletions core/dbt/clients/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def clone(repo, cwd, dirname=None, remove_git_dir=False):
if dirname is not None:
clone_cmd.append(dirname)

result = run_cmd(cwd, clone_cmd)
result = run_cmd(cwd, clone_cmd, env={'LC_ALL': 'C'})

if remove_git_dir:
rmdir(os.path.join(dirname, '.git'))
Expand All @@ -21,7 +21,7 @@ def clone(repo, cwd, dirname=None, remove_git_dir=False):


def list_tags(cwd):
out, err = run_cmd(cwd, ['git', 'tag', '--list'])
out, err = run_cmd(cwd, ['git', 'tag', '--list'], env={'LC_ALL': 'C'})
tags = out.decode('utf-8').strip().split("\n")
return tags

Expand All @@ -40,7 +40,8 @@ def _checkout(cwd, repo, branch):
else:
spec = 'origin/{}'.format(branch)

out, err = run_cmd(cwd, ['git', 'reset', '--hard', spec])
out, err = run_cmd(cwd, ['git', 'reset', '--hard', spec],
env={'LC_ALL': 'C'})
return out, err


Expand All @@ -55,13 +56,13 @@ def checkout(cwd, repo, branch=None):


def get_current_sha(cwd):
out, err = run_cmd(cwd, ['git', 'rev-parse', 'HEAD'])
out, err = run_cmd(cwd, ['git', 'rev-parse', 'HEAD'], env={'LC_ALL': 'C'})

return out.decode('utf-8')


def remove_remote(cwd):
return run_cmd(cwd, ['git', 'remote', 'rm', 'origin'])
return run_cmd(cwd, ['git', 'remote', 'rm', 'origin'], env={'LC_ALL': 'C'})


def clone_and_checkout(repo, cwd, dirname=None, remove_git_dir=False,
Expand Down
5 changes: 3 additions & 2 deletions core/dbt/clients/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def _interpret_oserror(exc, cwd, cmd):
)


def run_cmd(cwd, cmd):
def run_cmd(cwd, cmd, env=None):
logger.debug('Executing "{}"'.format(' '.join(cmd)))
if len(cmd) == 0:
raise dbt.exceptions.CommandError(cwd, cmd)
Expand All @@ -278,7 +278,8 @@ def run_cmd(cwd, cmd):
cmd,
cwd=cwd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stderr=subprocess.PIPE,
env=env)

out, err = proc.communicate()
except OSError as exc:
Expand Down

0 comments on commit a4b77e4

Please sign in to comment.