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

feat: Add label + assignee select in PR submission #39

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

clabby
Copy link
Owner

@clabby clabby commented Nov 4, 2024

Overview

Adds two more selects to the PR submission process to select labels and assignees for the PR.

Example

Screen.Recording.2024-11-04.at.12.10.23.PM.mov

Metadata

closes #36

@clabby clabby added the enhancement New feature or request label Nov 4, 2024
@clabby
Copy link
Owner Author

clabby commented Nov 4, 2024

📚 $\text{Stack Overview}$

Pulls submitted in this stack:

This comment was automatically generated by st.

Comment on lines +304 to +317
let set_assignee = inquire::Confirm::new("Would you like to assign the pull request?")
.with_default(false)
.prompt()?;
let assignees = set_assignee
.then(|| {
let answer = inquire::Text::new("Assignees (comma-separated):")
.prompt()?
.replace(' ', "")
.split(',')
.map(ToString::to_string)
.collect();
Ok::<_, StError>(answer)
})
.transpose()?;
Copy link
Collaborator

@refcell refcell Nov 5, 2024

Choose a reason for hiding this comment

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

Still think it would be cool if there was an environment variable or global setting that allowed you to automagically set a default assignee.

e.g. if I have ST_DEFAULT_ASSIGNEE=refcell set, st doesn't prompt me for an assignee here.

@refcell refcell self-requested a review November 5, 2024 13:14
Copy link
Collaborator

@refcell refcell left a comment

Choose a reason for hiding this comment

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

One small bug, otherwise nice work

Comment on lines +294 to +299
Some(
selected_labels
.into_iter()
.map(|label| label.name)
.collect(),
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

There's an issue here. Octocrab will error if it gets an empty vec. This should return Option::None if selected_labels is empty.

e.g. error response:

🐙 octocrab error: GitHub { source: GitHubError { documentation_url: Some("https://docs.github.com/rest/issues/labels#add-labels-to-an-issue"), errors: None, message: "Invalid request.\n\nNo subschema in \"anyOf\" matched.\nFor 'anyOf/0', {\"labels\"=>[]} is not an array.\nFor 'anyOf/1', {\"labels\"=>[]} is not an array.\n1 item required; only 0 were supplied.", status_code: 422 }, backtrace: <disabled> }

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

Successfully merging this pull request may close these issues.

feat(submit): Prompt to Assign PR to Current User
2 participants