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

Works with repos without remotes. #206

Merged
merged 2 commits into from Apr 4, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions legit/cli.py
Expand Up @@ -183,6 +183,8 @@ def cmd_sync(args):
Defaults to current branch.
"""

repo_check(require_remote=True)

if args.get(0):
# Optional branch specifier.
branch = fuzzy_match_branch(args.get(0))
Expand Down Expand Up @@ -306,6 +308,7 @@ def cmd_graft(args):
def cmd_publish(args):
"""Pushes an unpublished branch to a remote repository."""

repo_check(require_remote=True)
branch = fuzzy_match_branch(args.get(0))

if not branch:
Expand All @@ -331,6 +334,7 @@ def cmd_publish(args):
def cmd_unpublish(args):
"""Removes a published branch from the remote repository."""

repo_check(require_remote=True)
branch = fuzzy_match_branch(args.get(0))

if not branch:
Expand Down
25 changes: 15 additions & 10 deletions legit/scm.py
Expand Up @@ -226,20 +226,23 @@ def get_repo():

def get_remote():

repo_check(require_remote=True)
repo_check()

reader = repo.config_reader()

# If there is no remote option in legit section, return default
if not reader.has_option('legit', 'remote'):
return repo.remotes[0]
if repo.remotes:
# If there is no remote option in legit section, return default
if not reader.has_option('legit', 'remote'):
return repo.remotes[0]

remote_name = reader.get('legit', 'remote')
if not remote_name in [r.name for r in repo.remotes]:
raise ValueError('Remote "{0}" does not exist! Please update your git '
'configuration.'.format(remote_name))
remote_name = reader.get('legit', 'remote')
if not remote_name in [r.name for r in repo.remotes]:
raise ValueError('Remote "{0}" does not exist! Please update your git '
'configuration.'.format(remote_name))

return repo.remote(remote_name)
return repo.remote(remote_name)
else:
return None


def get_current_branch_name():
Expand All @@ -255,7 +258,9 @@ def get_branches(local=True, remote_branches=True):

repo_check()

# print local
if not repo.remotes:
remote_branches = False

branches = []

if remote_branches:
Expand Down