Skip to content

Commit 1060398

Browse files
authored
Merge pull request #1964 from Urgau/silence-reminder-for-member
Silence the `ready` reminder when the author is a member of repository
2 parents e914e5d + dc922c3 commit 1060398

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

src/github.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use bytes::Bytes;
44
use chrono::{DateTime, FixedOffset, Utc};
55
use futures::{future::BoxFuture, FutureExt};
66
use hyper::header::HeaderValue;
7-
use octocrab::models::Author;
7+
use octocrab::models::{Author, AuthorAssociation};
88
use regex::Regex;
99
use reqwest::header::{AUTHORIZATION, USER_AGENT};
1010
use reqwest::{Client, Request, RequestBuilder, Response, StatusCode};
@@ -396,6 +396,9 @@ pub struct Issue {
396396
pub milestone: Option<Milestone>,
397397
/// Whether a PR has merge conflicts.
398398
pub mergeable: Option<bool>,
399+
400+
/// How the author is associated with the repository
401+
pub author_association: AuthorAssociation,
399402
}
400403

401404
#[derive(Debug, serde::Deserialize, Eq, PartialEq)]

src/handlers/shortcut.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use crate::{
99
handlers::Context,
1010
interactions::ErrorComment,
1111
};
12+
use octocrab::models::AuthorAssociation;
1213
use parser::command::shortcut::ShortcutCommand;
1314

1415
/// Key for the state in the database
@@ -65,7 +66,16 @@ pub(super) async fn handle_command(
6566
}
6667

6768
// We add a small reminder for the author to use `@bot ready` when ready
68-
if matches!(input, ShortcutCommand::Author) {
69+
//
70+
// Except if the author is a member (or the owner) of the repository, as
71+
// the author should already know about the `ready` command and already
72+
// have the required permissions to update the labels manually anyway.
73+
if matches!(input, ShortcutCommand::Author)
74+
&& !matches!(
75+
issue.author_association,
76+
AuthorAssociation::Member | AuthorAssociation::Owner
77+
)
78+
{
6979
// Get the state of the author reminder for this PR
7080
let mut db = ctx.db.get().await;
7181
let mut state: IssueData<'_, AuthorReminderState> =

src/tests/github.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ pub fn issue(
7171
state,
7272
milestone: None,
7373
mergeable: None,
74+
author_association: octocrab::models::AuthorAssociation::None,
7475
}
7576
}
7677

0 commit comments

Comments
 (0)