Skip to content

Commit

Permalink
Merge pull request #206 from weakish/without-remote
Browse files Browse the repository at this point in the history
Works with repos without remotes.
  • Loading branch information
kennethreitz committed Apr 4, 2017
2 parents c1c1737 + e64dec7 commit 7be8429
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
4 changes: 4 additions & 0 deletions legit/cli.py
Expand Up @@ -186,6 +186,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 @@ -236,6 +238,7 @@ def cmd_undo(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 @@ -261,6 +264,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
16 changes: 9 additions & 7 deletions legit/scm.py
Expand Up @@ -103,7 +103,7 @@ def unstash_it(sync=False, branch=None):
def smart_pull():
'git log --merges origin/master..master'

repo_check()
repo_check(require_remote=True)

branch = get_current_branch_name()

Expand Down Expand Up @@ -137,7 +137,7 @@ def smart_merge(branch, allow_rebase=True):

def push(branch=None):

repo_check()
repo_check(require_remote=True)

if branch is None:
return repo.git.execute([git, 'push'])
Expand Down Expand Up @@ -187,7 +187,7 @@ def graft_branch(branch):
def unpublish_branch(branch):
"""Unpublishes given branch."""

repo_check()
repo_check(require_remote=True)

try:
return repo.git.execute([git,
Expand All @@ -201,7 +201,7 @@ def unpublish_branch(branch):
def publish_branch(branch):
"""Publishes given branch."""

repo_check()
repo_check(require_remote=True)

return repo.git.execute([git,
'push', '-u', remote.name, branch])
Expand All @@ -218,7 +218,7 @@ def get_repo():

def get_remote():

repo_check(require_remote=True)
repo_check()

reader = repo.config_reader()

Expand All @@ -229,7 +229,7 @@ def get_remote():
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))
'configuration.'.format(remote_name))

return repo.remote(remote_name)

Expand All @@ -247,7 +247,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

0 comments on commit 7be8429

Please sign in to comment.