Skip to content

Commit

Permalink
Added test for bug #4
Browse files Browse the repository at this point in the history
  • Loading branch information
msiemens committed Jun 5, 2013
1 parent 69f47b1 commit 73cf5e4
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
2 changes: 2 additions & 0 deletions PyGitUp/gitup.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ def rebase_all_branches(self):
except ValueError:
# Remote branch doesn't exist!
print(colored('error: remote branch doesn\'t exist', 'red'))
self.states.append('remote branch doesn\'t exist')

continue

if remote.commit.hexsha == branch.commit.hexsha:
Expand Down
57 changes: 57 additions & 0 deletions tests/test_remote_branch_deleted.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# System imports
import os
from os.path import join

# 3rd party libs
from nose.tools import *
from git import *

# PyGitup imports
from PyGitUp.git_wrapper import GitError
from tests import basepath, write_file, init_master, update_file, testfile_name

test_name = 'remote-branch-deleted'
new_branch_name = test_name + '.2'

repo_path = join(basepath, test_name + os.sep)

def _read_file(path):
with open(path) as f:
return f.read()


def setup():
master_path, master = init_master(test_name)

# Prepare master repo
master.git.checkout(b=test_name)

# Create new branch
master.git.checkout(b=new_branch_name)

# Clone to test repo
path = join(basepath, test_name)

master.clone(path, b=test_name)
repo = Repo(path, odbt=GitCmdObjectDB)

assert repo.working_dir == path

# Checkout new branch in cloned repo
repo.git.checkout(new_branch_name, 'origin/' + new_branch_name, b=True)

# Remove branch from master again
master.git.checkout(test_name)
master.git.branch(new_branch_name, d=True)


def test_ahead_of_upstream():
""" Run 'git up' with remotely deleted branch """
os.chdir(repo_path)

from PyGitUp.gitup import GitUp
gitup = GitUp()
gitup.run(testing=True)

assert_equal(len(gitup.states), 2)
assert_equal(gitup.states[1], 'remote branch doesn\'t exist')

0 comments on commit 73cf5e4

Please sign in to comment.