Skip to content

Commit

Permalink
Remove command resync.
Browse files Browse the repository at this point in the history
- The naming is confusing.
- The resync command is not frequently used as sync.
- It is incompletely implemented (restricted to master branch).

This commit closes #202.
  • Loading branch information
weakish committed Jul 19, 2017
1 parent f2ce724 commit b42bf45
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 66 deletions.
7 changes: 0 additions & 7 deletions README.rst
Expand Up @@ -30,13 +30,6 @@ The Interface
Stash, Fetch, Auto-Merge/Rebase, Push, and Unstash.
You can only sync published branches. (alias: ``sy``)

``resync <upstream-branch>``
Stashes unstaged changes,
Fetches, Auto-Merge/Rebase upstream data from specified upstream branch,
Performs smart pull+merge for current branch,
Pushes local commits up, and Unstashes changes.
Default upstream branch is 'master'. (alias: ``rs``)

``switch <branch>``
Switches to specified branch.
Defaults to current branch.
Expand Down
6 changes: 2 additions & 4 deletions extra/bash-completion/legit
Expand Up @@ -4,7 +4,7 @@ _legit()
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="branches graft publish sprout switch sync resync unpublish harvest"
opts="branches graft publish sprout switch sync unpublish harvest"
local running=`git for-each-ref --format='%(refname:short)' --sort='refname:short' refs/heads`

case "${prev}" in
Expand Down Expand Up @@ -32,7 +32,7 @@ _legit()
COMPREPLY=( $(compgen -W "${running}" -- ${cur}) )
return 0
;;
unp|unpublish|rs|resync)
unp|unpublish|rs)
local running=$(for x in `git ls-remote 2>/dev/null | grep refs/heads | awk '{ print $2 }' | sed -e 's/refs\/heads\///g'`; do echo ${x} ; done )
COMPREPLY=( $(compgen -W "${running}" -- ${cur}) )
return 0
Expand Down Expand Up @@ -68,15 +68,13 @@ _complete_with_git_branch()
}

function _git_sync { _complete_with_git_branch; }
function _git_resync { _complete_with_git_branch; }
function _git_switch { _complete_with_git_branch; }
function _git_sprout { _complete_with_git_branch; }
function _git_graft { _complete_with_git_branch; }
function _git_harvest { _complete_with_git_branch; }
function _git_publish { _complete_with_git_branch; }

complete -F _git_sync git-sync
complete -F _git_resync git-resync
complete -F _git_switch git-switch
complete -F _git_sprout git-sprout
complete -F _git_graft git-graft
Expand Down
7 changes: 0 additions & 7 deletions extra/man/legit.1
Expand Up @@ -58,13 +58,6 @@ Synchronizes the given branch. Defaults to current branch.
Stash, Fetch, Auto\-Merge/Rebase, Push, and Unstash.
You can only sync published branches.
.TP
.B \fBresync <upstream\-branch>\fP
Stashes unstaged changes,
Fetches, Auto\-Merge/Rebase upstream data from specified upstream branch,
Performs smart pull+merge for current branch,
Pushes local commits up, and Unstashes changes.
Default upstream branch is \(aqmaster\(aq.
.TP
.B \fBswitch <branch>\fP
Switches to specified branch.
Defaults to current branch.
Expand Down
3 changes: 1 addition & 2 deletions extra/zsh-completion/_legit
Expand Up @@ -28,7 +28,6 @@ _legit ()
'settings: Display and edit the current Legit settings.'
'branches: Get a nice pretty list of available branches.'
'sync: Synchronizes the given branch. Defaults to current branch. Stash, Fetch, Auto-Merge/Rebase, Push, and Unstash. You can only sync published branches.'
'resync: Re-synchronize current branch with specified upstream branch.'
'switch: Switches to specified branch. Defaults to current branch. Automatically stashes and unstashes any changes.'
'sprout: Creates a new branch off of the specified branch. Switches to it immediately.'
'graft: Merges specified branch into the second branch, and removes it. You can only graft unpublished branches.'
Expand All @@ -47,7 +46,7 @@ _legit ()
case $line[1] in
(settings|branches)
;;
(sy|sync|sw|switch|pub|publish|unp|unpublish|rs|resync)
(sy|sync|sw|switch|pub|publish|unp|unpublish|rs)
_arguments \
':branch:__git_branch_names'
;;
Expand Down
46 changes: 0 additions & 46 deletions legit/cli.py
Expand Up @@ -144,41 +144,6 @@ def cmd_switch(args):
status_log(unstash_it, 'Restoring local changes.')


def cmd_resync(args):
"""Stashes unstaged changes,
Fetches, Auto-Merge/Rebase upstream data from specified upstream branch,
Performs smart pull+merge for current branch,
Pushes local commits up, and Unstashes changes.
Default upstream branch is 'master'.
"""
if args.get(0):
upstream = fuzzy_match_branch(args.get(0))
if upstream:
is_external = True
original_branch = get_current_branch_name()
else:
print("{0} doesn't exist. Use a branch that does.".format(
colored.yellow(args.get(0))))
sys.exit(1)
else:
upstream = "master"
original_branch = get_current_branch_name()
if repo.is_dirty():
status_log(stash_it, 'Saving local changes.', sync=True)
# Update upstream branch
switch_to(upstream)
status_log(smart_pull, 'Pulling commits from the server.')
# Update original branch with upstream
switch_to(original_branch)
status_log(smart_merge, 'Grafting commits from {0}.'.format(
colored.yellow(upstream)), upstream, allow_rebase=False)
if unstash_index(sync=True):
status_log(unstash_it, 'Restoring local changes.', sync=True)
# Sync original_branch
status_log(smart_pull, 'Pulling commits from the server.')
status_log(push, 'Pushing commits to the server.', original_branch)


def cmd_sync(args):
"""Stashes unstaged changes, Fetches remote data, Performs smart
pull+merge, Pushes local commits up, and Unstashes changes.
Expand Down Expand Up @@ -329,7 +294,6 @@ def cmd_install(args):
'unpublish',
'sync',
'switch',
'resync',
'undo'
]

Expand Down Expand Up @@ -559,16 +523,6 @@ def def_cmd(name=None, short=None, fn=None, usage=None, help=None):
help=('Synchronizes the given branch. Defaults to current branch. Stash, '
'Fetch, Auto-Merge/Rebase, Push, and Unstash.'))

def_cmd(
name='resync',
short=['rs'],
fn=cmd_resync,
usage='resync <upstream-branch>',
help=('Re-synchronize current branch with specified upstream branch. '
"Default upstream branch is 'master'. "
'Fetch, Auto-Merge/Rebase for upstream, '
'Fetch, Auto-Merge/Rebase, Push, and Unstash for current branch.'))

def_cmd(
name='unpublish',
short=['unp'],
Expand Down

0 comments on commit b42bf45

Please sign in to comment.