Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions docs/config/.gitvote.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const CMD_CHECK_VOTE: &str = "check-vote";

/// Regex used to detect commands in issues/prs comments.
static CMD: LazyLock<Regex> = 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.
Expand Down
17 changes: 17 additions & 0 deletions src/cmd/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading