Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix git command for dep which points to a tag #481

Merged
merged 4 commits into from
Jul 6, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions dbt/clients/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,30 @@ def clone(repo, cwd, dirname=None):
return run_cmd(cwd, clone_cmd)


def list_tags(cwd):
out, err = run_cmd(cwd, ['git', 'tag', '--list'])
tags = set(out.decode('utf-8').strip().split("\n"))
return tags
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clever



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])
run_cmd(cwd, ['git', 'fetch', '--tags', '--depth', '1', 'origin', branch])

tags = list_tags(cwd)

# Prefer tags to branches if one exists
if branch in tags:
spec = 'tags/{}'.format(branch)
else:
spec = 'origin/{}'.format(branch)

run_cmd(cwd, ['git', 'reset', '--hard', spec])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you also check the output of this and fail if this fails?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cmcarthur good idea!



def get_current_sha(cwd):
Expand Down