diff --git a/README.md b/README.md index 78788aa..6bc6d3c 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ The command **must** be on a line by itself. Please note that GitVote only detec ![create-vote](docs/screenshots/create-vote.png) -Alternatively, if you have setup multiple configuration profiles, you can also start votes using any of them with the command `/vote-PROFILE`. +Alternatively, if you have setup multiple configuration profiles, you can also start votes using any of them with the command `/vote-PROFILE`. The profile name can contain letters, digits, hyphens and underscores. > [!NOTE] > Only repositories collaborators can create votes. For organization-owned repositories, the list of collaborators includes outside collaborators, organization members that are direct collaborators, organization members with access through team memberships, organization members with access through default organization permissions, and organization owners. diff --git a/docs/config/.gitvote.yml b/docs/config/.gitvote.yml index bfb7aa8..d951f90 100644 --- a/docs/config/.gitvote.yml +++ b/docs/config/.gitvote.yml @@ -252,6 +252,8 @@ profiles: # different profile you can use the command /vote-PROFILE. In the case below, # the command would be /vote-profile1 # + # Profile names can contain letters, digits, hyphens and underscores. + # # Please note that each profile must contain all required fields. The default # profile is used when using the /vote command, but its values are not used as # default values when they are not provided on other profiles. diff --git a/src/cmd.rs b/src/cmd.rs index da80d6f..ac3c2d4 100644 --- a/src/cmd.rs +++ b/src/cmd.rs @@ -21,7 +21,7 @@ const CMD_CHECK_VOTE: &str = "check-vote"; /// Regex used to detect commands in issues/prs comments. static CMD: LazyLock = LazyLock::new(|| { - Regex::new(r"(?m)^/(vote|cancel-vote|check-vote)-?([a-zA-Z0-9]*)\s*$").expect("invalid CMD regexp") + Regex::new(r"(?m)^/(vote|cancel-vote|check-vote)-?([a-zA-Z0-9_-]*)\s*$").expect("invalid CMD regexp") }); /// Represents a command to be executed, usually created from a GitHub event. diff --git a/src/cmd/tests.rs b/src/cmd/tests.rs index 703e05d..fb06be0 100644 --- a/src/cmd/tests.rs +++ b/src/cmd/tests.rs @@ -582,6 +582,23 @@ fn manual_command_from_issue_comment_event_check_vote_cmd() { ); } +#[test] +fn manual_command_from_issue_comment_event_profile_with_dash_and_underscore() { + for profile in ["supply-chain-removal", "my_profile", "my-profile_1"] { + // Setup event + let mut event = setup_test_issue_comment_event(); + event.action = IssueCommentEventAction::Created; + event.comment.body = Some(format!("/{CMD_CREATE_VOTE}-{profile}")); + let event = Event::IssueComment(event); + + // Run and check the manual command is returned with the full profile + assert_eq!( + Command::from_event_manual(&event), + Some(Command::CreateVote(CreateVoteInput::new(Some(profile), &event))) + ); + } +} + #[test] fn manual_command_from_issue_comment_event_cmd_in_issue_body_is_ignored() { // Setup event with command only in issue body