-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make dependencies more compact (#342)
- Loading branch information
Showing
3 changed files
with
67 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import subprocess | ||
|
||
from dbt.logger import GLOBAL_LOGGER as logger | ||
|
||
|
||
def log_cmd(cmd): | ||
logger.debug('Executing "{}"'.format(' '.join(cmd))) | ||
|
||
|
||
def run_cmd(cwd, cmd): | ||
log_cmd(cmd) | ||
proc = subprocess.Popen( | ||
cmd, | ||
cwd=cwd, | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE) | ||
|
||
return proc.communicate() | ||
|
||
|
||
def clone(repo, cwd): | ||
return run_cmd(cwd, ['git', 'clone', '--depth', '1', repo]) | ||
|
||
|
||
def checkout(cwd, branch=None): | ||
if branch is None: | ||
branch = 'master' | ||
|
||
remote_branch = 'origin/{}'.format(branch) | ||
|
||
logger.info(' Checking out branch {}.'.format(branch)) | ||
|
||
run_cmd(cwd, ['git', 'remote', 'set-branches', 'origin', branch]) | ||
run_cmd(cwd, ['git', 'fetch', '--depth', '1', 'origin', branch]) | ||
run_cmd(cwd, ['git', 'reset', '--hard', remote_branch]) | ||
|
||
|
||
def get_current_sha(cwd): | ||
out, err = run_cmd(cwd, ['git', 'rev-parse', 'HEAD']) | ||
|
||
return out.decode('utf-8') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters