Ejemplo n.º 1
0
    def finish_feature(self, feature_name, delete_on_remote=False):
        repo_name = self.utils.current_repo_name()
        if not feature_name:
            feature_name = self.utils.current_feature_name()
        self.utils.assert_is_not_dirty()
        self.utils.assert_feature_exists(feature_name)
        Error.abort_if(feature_name == "master",
                       "You cannot finish your master feature")
        Error.abort_if(
            self.tfs.has_active_pull_request(repo_name, feature_name),
            "You have an active pull request on that branch.\nPlease complete it or abandon it to continue"
        )
        Confirmation.show_if(self.utils.has_unpushed_commits(feature_name),
                             "You have unpushed commits on this branch")

        if feature_name == self.utils.current_feature_name():
            self.move_to_feature("master")

        try:
            self.git.branch("-D", feature_name)
            if delete_on_remote:
                self.git.push("origin", "--delete", feature_name)
            if self.utils.current_feature_name() == "master":
                Utils.print_encoded(click.style("Updating master", bold=True))
                self.update_feature(silent=True)

            Utils.print_encoded("Finished feature " +
                                click.style(feature_name, bold=True))
        except git.exc.GitCommandError as command_error:
            Utils.print_encoded(command_error.stderr.decode("UTF-8"))
            Error.abort("Couldn't finish feature")
Ejemplo n.º 2
0
def cr(ctx):
	try:
		if (not Configuration.exists()):
			Utils.print_encoded("Please inform your TFS' information\n")
			ctx.invoke(configure, url=click.prompt("Url"), username=click.prompt("Username"), password=click.prompt("Password"))
			ctx.exit()
		repo = git.Repo('.')
		ctx.obj = Repository(repo, RepositoryUtils(repo), Tfs(Configuration.load()))
	except git.exc.InvalidGitRepositoryError:
		Error.abort("You're not on a valid git repository")
Ejemplo n.º 3
0
 def move_to_feature(self, feature_name):
     self.utils.assert_is_not_dirty()
     self.utils.assert_feature_exists(feature_name)
     try:
         self.git.checkout(feature_name)
         Utils.print_encoded("Moved to feature " +
                             click.style(feature_name, bold=True))
     except git.exc.GitCommandError as command_error:
         Utils.print_encoded(command_error.stderr.decode("UTF-8"))
         Error.abort("Couldn't move to feature")
Ejemplo n.º 4
0
 def share_feature(self, silent=False):
     current_feature = self.utils.current_feature_name()
     Error.abort_if(current_feature == "master",
                    "You cannot push changes on master")
     try:
         output = self.git.push("--set-upstream", "origin", current_feature)
         if not silent:
             Utils.print_encoded(
                 click.style("Feature shared successfully", bold=True))
     except git.exc.GitCommandError as command_error:
         Utils.print_encoded(command_error.stderr.decode("UTF-8"))
         Error.abort("Couldn't share feature")
Ejemplo n.º 5
0
def cr(ctx):
    try:
        if (not Configuration.exists()):
            Utils.print_encoded("Please inform your TFS' information\n")
            ctx.invoke(configure,
                       url=click.prompt("Url"),
                       username=click.prompt("Username"),
                       password=click.prompt("Password"))
            ctx.exit()
        repo = git.Repo('.')
        ctx.obj = Repository(repo, RepositoryUtils(repo),
                             Tfs(Configuration.load()))
    except git.exc.InvalidGitRepositoryError:
        Error.abort("You're not on a valid git repository")
Ejemplo n.º 6
0
    def create_feature(self, feature_name):
        self.utils.assert_is_not_dirty()
        self.utils.assert_feature_does_not_exists(feature_name)
        try:
            self.git.checkout("-B", feature_name, "master")
            self.git.checkout("master")
            self.repo.head.reset(commit="origin/master", working_tree=True)
            self.git.checkout(feature_name)

            Utils.print_encoded(
                click.style("New feature created successfully", bold=True))
        except git.exc.GitCommandError as command_error:
            Utils.print_encoded(command_error.stderr.decode("UTF-8"))
            Error.abort("Couldn't create new feature")
Ejemplo n.º 7
0
 def update_feature(self, silent=False):
     try:
         output = self.git.pull("origin", "master")
         if not silent:
             Utils.print_encoded(
                 click.style("\nFeature successfully updated", bold=True))
     except git.exc.GitCommandError as command_error:
         if command_error.status == 1:
             Utils.print_encoded(
                 click.style("\nFeature updated but conflicts were found",
                             bold=True))
             Utils.print_encoded(
                 click.style(
                     "Fix them up in the work tree, and then use 'git add/rm <file>' as appropriate"
                 ))
         else:
             Utils.print_encoded(command_error.stderr.decode("UTF-8"))
             Error.abort("Couldn't update feature")