def test_create_branches(self): repo = create_git_repo(self) gitflow = GitFlow(repo).init() gitflow.create('feature', 'foo', None, fetch=False) self.assertIn('feature/foo', [h.name for h in gitflow.repo.branches]) gitflow.create('release', '1.0', None, fetch=False) self.assertIn('release/1.0', [h.name for h in gitflow.repo.branches])
def test_finish_in_new_sandbox_without_commit(self): sandbox = create_sandbox(self) gitflow = GitFlow(sandbox).init() gitflow.create('feature', 'wow-feature', base=None, fetch=False) gitflow.finish('feature', 'wow-feature', False, False, False, False, None) self.assertNotIn('feature/wow-feature', gitflow.repo.branches)
def test_finish_in_new_sandbox(self): sandbox = create_sandbox(self) gitflow = GitFlow(sandbox).init() gitflow.create('feature', 'wow-feature', base=None, fetch=False) self.assertEqual(gitflow.repo.active_branch.name, 'feature/wow-feature') fake_commit(gitflow.repo, 'Yet another commit') gitflow.finish('feature', 'wow-feature', False, False, False, False, None) self.assertNotIn('feature/wow-feature', gitflow.repo.branches)
def test_gitflow_publish_creates_sets_tracking_branch(self): gitflow = GitFlow(self.repo).init() gitflow.create('feature', 'circular', 'devel', fetch=False) gitflow.publish('feature', 'circular') self.assertTrue(self.repo.branches['feat/circular'].tracking_branch()) self.assertTrue(self.repo.branches['feat/circular'].tracking_branch().name, 'my-remote/feat/circular')
def _test_create_branches_from_alt_base(self): repo = create_git_repo(self) gitflow = GitFlow(repo).init() gitflow.create('feature', 'foo', 'master', fetch=False) self.assertIn('feature/foo', [h.name for h in gitflow.repo.branches]) gitflow.repo.index.commit('Foo') gitflow.create('release', '1.0', 'feature/foo', fetch=False) self.assertIn('release/1.0', [h.name for h in gitflow.repo.branches])
def test_create_branches(self): repo = create_git_repo(self) gitflow = GitFlow(repo).init() gitflow.create('feature', 'foo', None, fetch=False) self.assertIn('feature/foo', [h.name for h in gitflow.repo.branches]) gitflow.create('release', '1.0', None, fetch=False) self.assertIn('release/1.0', [h.name for h in gitflow.repo.branches])
def _release_version_with_git_flow(version_tag): from os import curdir from gitflow.core import GitFlow from gitpy import LocalRepository gitflow = GitFlow() gitflow.create("release", version_tag, base=None, fetch=False) gitflow.finish("release", version_tag, fetch=False, rebase=False, keep=False, force_delete=True, tagging_info=dict(sign=False, message=version_tag)) repository = LocalRepository(curdir)
def test_gitflow_publish_creates_sets_tracking_branch(self): gitflow = GitFlow(self.repo).init() gitflow.create('feature', 'circular', 'devel', fetch=False) gitflow.publish('feature', 'circular') self.assertTrue(self.repo.branches['feat/circular'].tracking_branch()) self.assertTrue( self.repo.branches['feat/circular'].tracking_branch().name, 'my-remote/feat/circular')
def _test_create_branches_from_alt_base(self): repo = create_git_repo(self) gitflow = GitFlow(repo).init() gitflow.create('feature', 'foo', 'master', fetch=False) self.assertIn('feature/foo', [h.name for h in gitflow.repo.branches]) gitflow.repo.index.commit('Foo') gitflow.create('release', '1.0', 'feature/foo', fetch=False) self.assertIn('release/1.0', [h.name for h in gitflow.repo.branches])
def test_finish_in_new_sandbox(self): sandbox = create_sandbox(self) gitflow = GitFlow(sandbox).init() gitflow.create('feature', 'wow-feature', base=None, fetch=False) self.assertEqual(gitflow.repo.active_branch.name, 'feature/wow-feature') fake_commit(gitflow.repo, 'Yet another commit') gitflow.finish('feature', 'wow-feature', False, False, False, False, None) self.assertNotIn('feature/wow-feature', gitflow.repo.branches)
def _release_version_with_git_flow(version_tag): from gitflow.core import GitFlow gitflow = GitFlow() gitflow.create("release", version_tag, base=None, fetch=False) gitflow.finish("release", version_tag, fetch=False, rebase=False, keep=False, force_delete=True, tagging_info=dict(sign=False, message=version_tag))
def test_gitflow_publish_really_pushes(self): gitflow = GitFlow(self.repo).init() gitflow.create('feature', 'circular', 'devel', fetch=False) change = fake_commit(self.repo, "Another commit") all_local_commits = all_commits(self.repo) self.assertIn(change, all_local_commits) gitflow.publish('feature', 'circular') all_remote_commits = all_commits(self.remote) self.assertEqual(all_remote_commits, all_remote_commits) self.assertIn(change, all_remote_commits)
def test_gitflow_publish_really_pushes(self): gitflow = GitFlow(self.repo).init() gitflow.create('feature', 'circular', 'devel', fetch=False) change = fake_commit(self.repo, "Another commit") all_local_commits = all_commits(self.repo) self.assertIn(change, all_local_commits) gitflow.publish('feature', 'circular') all_remote_commits = all_commits(self.remote) self.assertEqual(all_remote_commits, all_remote_commits) self.assertIn(change, all_remote_commits)
def test_create(self): create_git_repo(self) gitflow = GitFlow() self.assertEquals([], self.repo.branches) gitflow.init() self.assertEquals(['develop', 'master'], [b.name for b in self.repo.branches]) gitflow.create('feature', 'foo')
def test_create(self): create_git_repo(self) gitflow = GitFlow() self.assertEquals([], self.repo.branches) gitflow.init() self.assertEquals( ['develop', 'master'], [b.name for b in self.repo.branches]) gitflow.create('feature', 'foo')
def _release_version_with_git_flow(version_tag): from os import curdir from gitflow.core import GitFlow from gitpy import LocalRepository gitflow = GitFlow() gitflow.create("release", version_tag, base=None, fetch=False) gitflow.finish("release", version_tag, fetch=False, rebase=False, keep=False, force_delete=True, tagging_info=dict(sign=False, message=version_tag)) repository = LocalRepository(curdir)
def run_start(args): gitflow = GitFlow() # :fixme: Why does the sh-version not require a clean working dir? # NB: `args.name` is required since the branch must not yet exist # :fixme: get default value for `base` gitflow.start_transaction('create feature branch %s (from %s)' % (args.name, args.base)) try: branch = gitflow.create('feature', args.name, args.base, fetch=args.fetch) except (NotInitialized, BaseNotOnBranch): # printed in main() raise except Exception as e: die("Could not create feature branch %r" % args.name, e) print() print("Summary of actions:") print("- A new branch", branch, "was created, based on", args.base) print("- You are now on branch", branch) print("") print("Now, start committing on your feature. When done, use:") print("") print(" git flow feature finish", args.name) print()
def run_start(args): gitflow = GitFlow() # NB: `args.version` is required since the branch must not yet exist # :fixme: get default value for `base` gitflow.start_transaction('create hotfix branch %s (from %s)' % (args.version, args.base)) try: branch = gitflow.create('hotfix', args.version, args.base, fetch=args.fetch) except (NotInitialized, BranchTypeExistsError, BaseNotOnBranch): # printed in main() raise except Exception as e: die("Could not create hotfix branch %r" % args.version, e) print() print("Summary of actions:") print("- A new branch", branch, "was created, based on", args.base) print("- You are now on branch", branch) print("") print("Follow-up actions:") print("- Bump the version number now!") print("- Start committing your hot fixes") print("- When done, run:") print() print(" git flow hotfix finish", args.version)
def test_finish_fetch_does_not_change_repo(self): remote = GitFlow(self.remote).init() rc0 = remote.develop().commit gitflow = GitFlow(self.repo).init() c0 = gitflow.develop().commit self.assertEqual(rc0, c0) gitflow.create('feature', 'wow-feature', base=None, fetch=False) c1 = gitflow.develop().commit self.assertEqual(c0, c1) gitflow.finish('feature', 'wow-feature', True, False, False, False, None) c2 = gitflow.develop().commit self.assertEqual(c0, c2) fh = self.__get_fetch_head(self.repo) self.assertEqual(fh, c0)
def test_finish_fetch_does_not_change_repo(self): remote = GitFlow(self.remote).init() rc0 = remote.develop().commit gitflow = GitFlow(self.repo).init() c0 = gitflow.develop().commit self.assertEqual(rc0, c0) gitflow.create('feature', 'wow-feature', base=None, fetch=False) c1 = gitflow.develop().commit self.assertEqual(c0, c1) gitflow.finish('feature', 'wow-feature', True, False, False, False, None) c2 = gitflow.develop().commit self.assertEqual(c0, c2) fh = self.__get_fetch_head(self.repo) self.assertEqual(fh, c0)
def run_start(args): gitflow = GitFlow() # NB: `args.version` is required since the branch must not yet exist # :fixme: get default value for `base` gitflow.start_transaction('create release branch %s (from %s)' % (args.version, args.base)) try: gitflow.create('release', args.version, args.base, fetch=args.fetch) except (NotInitialized, BranchTypeExistsError, BaseNotOnBranch): # printed in main() raise except Exception as e: die("Could not create release branch %r" % args.version, e) print("Follow-up actions:") print("- Bump the version number now!") print("- Start committing last-minute fixes in preparing your release") print("- When done, run:") print() print(" git flow release finish", args.version)
def test_finish_fetch_fetches_from_remote(self): remote = GitFlow(self.remote).init() rc0 = remote.develop().commit gitflow = GitFlow(self.repo).init() c0 = gitflow.develop().commit self.assertEqual(rc0, c0) gitflow.create('feature', 'wow-feature', base=None, fetch=False) c1 = gitflow.develop().commit self.assertEqual(c0, c1) fake_commit(gitflow.repo, 'Yet another commit') gitflow.finish('feature', 'wow-feature', True, False, False, False, None) c2 = gitflow.develop().commit self.assertNotEqual(c0, c2) fh = self.__get_fetch_head(self.repo) self.assertEqual(fh, c0) self.assertNotEqual(fh, c2)
def test_finish_fetch_fetches_from_remote(self): remote = GitFlow(self.remote).init() rc0 = remote.develop().commit gitflow = GitFlow(self.repo).init() c0 = gitflow.develop().commit self.assertEqual(rc0, c0) gitflow.create('feature', 'wow-feature', base=None, fetch=False) c1 = gitflow.develop().commit self.assertEqual(c0, c1) fake_commit(gitflow.repo, 'Yet another commit') gitflow.finish('feature', 'wow-feature', True, False, False, False, None) c2 = gitflow.develop().commit self.assertNotEqual(c0, c2) fh = self.__get_fetch_head(self.repo) self.assertEqual(fh, c0) self.assertNotEqual(fh, c2)
def run_start(args): gitflow = GitFlow() # NB: `args.version` is required since the branch must not yet exist # :fixme: get default value for `base` gitflow.start_transaction('create release branch %s (from %s)' % (args.version, args.base)) try: gitflow.create('release', args.version, args.base, fetch=args.fetch) except (NotInitialized, BranchTypeExistsError, BaseNotOnBranch): # printed in main() raise except Exception as e: die("Could not create release branch %r" % args.version, e) print("Follow-up actions:") print("- Bump the version number now!") print("- Start committing last-minute fixes in preparing your release") print("- When done, run:") print() print(" git flow release finish", args.version)
def run_start(args): gitflow = GitFlow() # NB: `args.name` is required since the branch must not yet exist # :fixme: get default value for `base` gitflow.start_transaction('create support branch %s (from %s)' % (args.name, args.base)) try: branch = gitflow.create('support', args.name, args.base, fetch=args.fetch) except (NotInitialized, BranchTypeExistsError, BaseNotOnBranch): # printed in main() raise except Exception, e: die("Could not create support branch %r" % args.name, e)
def run_start(args): gitflow = GitFlow() # :fixme: Why does the sh-version not require a clean working dir? # NB: `args.name` is required since the branch must not yet exist # :fixme: get default value for `base` gitflow.start_transaction('create feature branch %s (from %s)' % \ (args.name, args.base)) try: branch = gitflow.create('feature', args.name, args.base, fetch=args.fetch) except (NotInitialized, BaseNotOnBranch): # printed in main() raise except Exception, e: die("Could not create feature branch %r" % args.name, e)
def run_start(args): gitflow = GitFlow() # NB: `args.name` is required since the branch must not yet exist # :fixme: get default value for `base` gitflow.start_transaction('create support branch %s (from %s)' % (args.name, args.base)) try: branch = gitflow.create('support', args.name, args.base, fetch=args.fetch) except (NotInitialized, BranchTypeExistsError, BaseNotOnBranch): # printed in main() raise except Exception, e: die("Could not create support branch %r" % args.name, e)
def run_start(args): gitflow = GitFlow() # :fixme: Why does the sh-version not require a clean working dir? # NB: `args.name` is required since the branch must not yet exist # :fixme: get default value for `base` gitflow.start_transaction('create feature branch %s (from %s)' % \ (args.name, args.base)) try: branch = gitflow.create('feature', args.name, args.base, fetch=args.fetch) except (NotInitialized, BaseNotOnBranch): # printed in main() raise except Exception, e: die("Could not create feature branch %r" % args.name, e)
def run_start(args): gitflow = GitFlow() base = gitflow.develop_name() #+ Pivotal Tracker modifications. pivotal.prompt_user_to_confirm_release(args.version) #+ Git modifications. sys.stdout.write('Creating release branch (base being %s) ... ' \ % base) try: branch = gitflow.create('release', args.version, base, fetch=(not args.no_fetch)) except BranchExistsError: sys.stdout.write('branch already exists ... ') except (NotInitialized, BranchTypeExistsError, BaseNotOnBranch): # printed in main() raise except Exception, e: die("could not create release branch %r" % args.version, e)
def run_start(args): gitflow = GitFlow() base = gitflow.develop_name() #+ Pivotal Tracker modifications. pivotal.prompt_user_to_confirm_release(args.version) #+ Git modifications. sys.stdout.write('Creating release branch (base being %s) ... ' \ % base) try: branch = gitflow.create('release', args.version, base, fetch=(not args.no_fetch)) except BranchExistsError: sys.stdout.write('branch already exists ... ') except (NotInitialized, BranchTypeExistsError, BaseNotOnBranch): # printed in main() raise except Exception, e: die("could not create release branch %r" % args.version, e)
def run_start(args): gitflow = GitFlow() # :fixme: Why does the sh-version not require a clean working dir? # NB: `args.name` is required since the branch must not yet exist # :fixme: get default value for `base` gitflow.start_transaction( 'create feature branch %s (from %s)' % (args.name, args.base)) try: branch = gitflow.create('feature', args.name, args.base, fetch=args.fetch) except (NotInitialized, BaseNotOnBranch): # printed in main() raise except Exception as e: die("Could not create feature branch %r" % args.name, e) print() print("Summary of actions:") print("- A new branch", branch, "was created, based on", args.base) print("- You are now on branch", branch) print("") print("Now, start committing on your feature. When done, use:") print("") print(" git flow feature finish", args.name) print()
def run_start(args): gitflow = GitFlow() # NB: `args.version` is required since the branch must not yet exist # :fixme: get default value for `base` gitflow.start_transaction('create hotfix branch %s (from %s)' % (args.version, args.base)) try: branch = gitflow.create('hotfix', args.version, args.base, fetch=args.fetch) except (NotInitialized, BranchTypeExistsError, BaseNotOnBranch): # printed in main() raise except Exception as e: die("Could not create hotfix branch %r" % args.version, e) print() print("Summary of actions:") print("- A new branch", branch, "was created, based on", args.base) print("- You are now on branch", branch) print("") print("Follow-up actions:") print("- Bump the version number now!") print("- Start committing your hot fixes") print("- When done, run:") print() print(" git flow hotfix finish", args.version)
def test_gitflow_publish_existing_remote_branch_raises_error(self): gitflow = GitFlow(self.repo).init() gitflow.create('feature', 'even', 'devel', fetch=False) self.assertRaises(BranchExistsError, gitflow.publish, 'feature', 'even')
def test_gitflow_publish_returns_branch_name(self): gitflow = GitFlow(self.repo).init() gitflow.create('feature', 'circular', 'devel', fetch=False) name = gitflow.publish('feature', 'circular') self.assertEqual(name, 'feat/circular')
def run_start(args): if args.for_release: pivotal.check_version_format(args.for_release) gitflow = GitFlow() git = gitflow.git base = None if args.for_release is not None: # Make sure --for-release matches the requirements. pivotal.check_version_format(args.for_release) base = gitflow.get_prefix('release') + args.for_release else: base = gitflow.managers['feature'].default_base() if not args.no_fetch: sys.stderr.write('Fetching origin ... ') gitflow.origin().fetch() print 'OK' # Check if the base exists and is in sync as soon as possible. sys.stdout.write('Checking the base branch ({0}) ... '.format(base)) origin_base = gitflow.require_origin_branch(base) try: gitflow.must_be_uptodate(base) except NoSuchBranchError: sys.stdout.write('found remote counterpart ... ') git.branch(base, origin_base.name) print('OK') [story, name] = pivotal.prompt_user_to_select_story(match=args.match) sys.stdout.write('Setting myself as the story owner ... ') try: story.set_me_as_owner() except: print('FAIL') print('OK') if args.for_release is not None: sys.stdout.write( 'Assigning the chosen story to release {0} ... '.format( args.for_release)) story.assign_to_release(args.for_release) print('OK') if story.is_rejected(): sid = str(story.get_id()) gitflow.start_transaction('restart story {0}'.format(sid)) sys.stdout.write('Checking out the feature branch ... ') try: gitflow.checkout('feature', sid) print('OK') except NoSuchBranchError as e: print('FAIL') raise InconsistencyDetected( 'The branch is missing for story {0}.'.format(sid)) sys.stdout.write('Updating Pivotal Tracker ... ') story.start() print('OK') return # :fixme: Why does the sh-version not require a clean working dir? gitflow.start_transaction('start feature branch %s (from %s)' % \ (name, base)) try: # fetch=False because we are already fetching at the beginning. branch = gitflow.create('feature', name, base, fetch=False) except (NotInitialized, BaseNotOnBranch): # printed in main() raise except Exception, e: die("Could not create feature branch %r" % name, e)
def test_gitflow_publish_returns_branch_name(self): gitflow = GitFlow(self.repo).init() gitflow.create('feature', 'circular', 'devel', fetch=False) name = gitflow.publish('feature', 'circular') self.assertEqual(name, 'feat/circular')
def test_gitflow_publish_creates_remote_branch(self): gitflow = GitFlow(self.repo).init() gitflow.create('feature', 'circular', 'devel', fetch=False) gitflow.publish('feature', 'circular') self.assertIn('feat/circular', self.remote.branches)
def run_start(args): if args.for_release: pivotal.check_version_format(args.for_release) gitflow = GitFlow() git = gitflow.git base = None if args.for_release is not None: # Make sure --for-release matches the requirements. pivotal.check_version_format(args.for_release) base = gitflow.get_prefix('release') + args.for_release else: base = gitflow.managers['feature'].default_base() if not args.no_fetch: sys.stderr.write('Fetching origin ... ') gitflow.origin().fetch() print 'OK' # Check if the base exists and is in sync as soon as possible. sys.stdout.write('Checking the base branch ({0}) ... '.format(base)) origin_base = gitflow.require_origin_branch(base) try: gitflow.must_be_uptodate(base) except NoSuchBranchError: sys.stdout.write('found remote counterpart ... ') git.branch(base, origin_base.name) print('OK') [story, name] = pivotal.prompt_user_to_select_story(match=args.match) sys.stdout.write('Setting myself as the story owner ... ') try: story.set_me_as_owner() except: print('FAIL') print('OK') if args.for_release is not None: sys.stdout.write('Assigning the chosen story to release {0} ... '.format(args.for_release)) story.assign_to_release(args.for_release) print('OK') if story.is_rejected(): sid = str(story.get_id()) gitflow.start_transaction('restart story {0}'.format(sid)) sys.stdout.write('Checking out the feature branch ... ') try: gitflow.checkout('feature', sid) print('OK') except NoSuchBranchError as e: print('FAIL') raise InconsistencyDetected( 'The branch is missing for story {0}.'.format(sid)) sys.stdout.write('Updating Pivotal Tracker ... ') story.start() print('OK') return # :fixme: Why does the sh-version not require a clean working dir? gitflow.start_transaction('start feature branch %s (from %s)' % \ (name, base)) try: # fetch=False because we are already fetching at the beginning. branch = gitflow.create('feature', name, base, fetch=False) except (NotInitialized, BaseNotOnBranch): # printed in main() raise except Exception, e: die("Could not create feature branch %r" % name, e)
def test_finish_in_new_sandbox_without_commit(self): sandbox = create_sandbox(self) gitflow = GitFlow(sandbox).init() gitflow.create('feature', 'wow-feature', base=None, fetch=False) gitflow.finish('feature', 'wow-feature', False, False, False, False, None) self.assertNotIn('feature/wow-feature', gitflow.repo.branches)
def test_gitflow_publish_creates_remote_branch(self): gitflow = GitFlow(self.repo).init() gitflow.create('feature', 'circular', 'devel', fetch=False) gitflow.publish('feature', 'circular') self.assertIn('feat/circular', self.remote.branches)
def test_create_in_new_sandbox(self): sandbox = create_sandbox(self) gitflow = GitFlow(sandbox).init() gitflow.create('feature', 'wow-feature', base=None, fetch=False) self.assertIn('feature/wow-feature', gitflow.repo.branches)
def test_gitflow_publish_existing_remote_branch_raises_error(self): gitflow = GitFlow(self.repo).init() gitflow.create('feature', 'even', 'devel', fetch=False) self.assertRaises(BranchExistsError, gitflow.publish, 'feature', 'even')
def test_create_in_new_sandbox(self): sandbox = create_sandbox(self) gitflow = GitFlow(sandbox).init() gitflow.create('feature', 'wow-feature', base=None, fetch=False) self.assertIn('feature/wow-feature', gitflow.repo.branches)
def _release_version_with_git_flow(version_tag): from gitflow.core import GitFlow gitflow = GitFlow() gitflow.create("release", version_tag, base=None, fetch=False) gitflow.finish("release", version_tag, fetch=False, rebase=False, keep=False, force_delete=True, tagging_info=dict(sign=False, message=version_tag))