Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add undo-commit command #115

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

rustiever
Copy link

#64

@rustiever
Copy link
Author

Hi @chriswalz, can you review and tell me what i'm missing in this PR

@chriswalz
Copy link
Owner

Hi @rustiever nice job I think you're pretty close although I haven't tested your code.

Here is the key change. The api should be: bit fix undo-commit and right now it looks like the code is setup as bit undo-commit

In terms of changing the code anywhere you have undo-commit you'll want to change that to fix.

Suggestion tree for fix will look like this

st.Sub["fix"] = &complete.CompTree{
	Args: map[string]*complete.CompTree{
		"undo-commit": {Desc: "soft undos last commit if not pushed already"},
	},
}

log.Debug().Err(err).Send()
}
}
},
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After this line you'll need Args: cobra.ExactArgs(1), to force the user to pass in a subcommand for bit fix

Copy link
Author

@rustiever rustiever Oct 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @chriswalz i added fix as command and undo-commit as sub command to fix command. Hence i added cobra.NoArgs. Pls check and test the code. Tell me if something wrong. I'm happy to take your suggestions

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chriswalz could you take look into this?

Short: "Undo your previous commit if it is not yet pushed to repository",
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {
if IsAheadOfCurrent() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From lines 13-17 should be wrapped in this code

arg := args[0]
if (arg == "undo-commit") {
// undo commit code
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants