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

commit sub-command #14

Open
justinrubek opened this issue May 11, 2024 · 2 comments
Open

commit sub-command #14

justinrubek opened this issue May 11, 2024 · 2 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@justinrubek
Copy link
Owner

The commit command would function similarly to git commit, but perform validation that the given commit is a conventional commit.'

ideas

  • use a similar command structure to regular git
    • -m flag to pass a short commit summary
    • send user to $EDITOR to write the commit. include comments with git instructions + some bomper-specific tips
@justinrubek
Copy link
Owner Author

#12 contains a change that switches the cli to use sub-commands rather than being a single command. This is should be implemented on top of that (f2139d6) as another sub-command.

@justinrubek justinrubek added enhancement New feature or request good first issue Good for newcomers labels May 11, 2024
@justinrubek
Copy link
Owner Author

justinrubek commented May 17, 2024

We now have a function that can be repurposed for this:

bomper/src/app.rs

Lines 364 to 392 in dadf5fd

fn prompt_for_description() -> Result<Option<String>> {
let mut file = tempfile::NamedTempFile::new_in(".")?;
file.write_all(DESCRIPTION_HELP)?;
let editor = std::env::var("EDITOR").map_err(|_| Error::EditorNotSet)?;
Command::new(editor)
.arg(file.path())
.status()
.expect("failed to edit changelog description file");
let description = std::fs::read_to_string(file.path())?;
let description = description
.lines()
.filter(|line| !line.trim().starts_with('#'))
.collect::<Vec<_>>()
.join("\n");
if description.is_empty() {
Ok(None)
} else {
// check if the file only contains whitespace
let description = description.trim();
if description.is_empty() {
Ok(None)
} else {
Ok(Some(description.to_string()))
}
}
}

This function could be renamed and made a bit more generic to support this use-case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant