def run_append(args): # Print info and ask for confirmation. pivotal.prompt_user_to_confirm_release(args.version) # Merge, push and insert PT labels. gitflow = GitFlow() git = gitflow.git current_branch = gitflow.repo.active_branch develop = gitflow.develop_name() gitflow.name_or_current('release', args.version) release = gitflow.get_prefix('release') + str(args.version) print('') sys.stdout.write('Merging develop into ' + release + ' ... ') gitflow.checkout('release', str(args.version)) git.merge(gitflow.develop_name()) print('OK') sys.stdout.write('Pushing ' + release + ' ... ') gitflow.origin().push([release]) print('OK') sys.stdout.write('Moving back to ' + str(current_branch) + ' ... ') current_branch.checkout() print('OK') sys.stdout.write('Marking Pivotal Tracker stories ... ') pivotal.start_release(args.version) print('OK')
def test_gitflow_nameprefix_or_current_defaults_to_current(self): gitflow = GitFlow(self.repo).init() active_branch = self.repo.active_branch gitflow.checkout('feature', 'even') self.assertNotEqual(gitflow.repo.active_branch.name, active_branch) self.assertEqual(gitflow.repo.active_branch.name, 'feat/even')
def run_checkout(args): gitflow = GitFlow() # NB: Does not default to the current branch as `nameprefix` is required name = gitflow.nameprefix_or_current('feature', args.nameprefix) gitflow.start_transaction('checking out feature branch %s' % name) gitflow.checkout('feature', name)
def run_checkout(args): gitflow = GitFlow() # NB: Does not default to the current branch as `nameprefix` is required branch = gitflow.checkout('feature', args.nameprefix) print 'Checking out feature {0}.'.format(branch.name)
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 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)