Skip to content

Commit

Permalink
fix: handle status comment ID greater than i32
Browse files Browse the repository at this point in the history
  • Loading branch information
Srynetix committed Jun 5, 2024
1 parent e5e53d8 commit 6eeb3fa
Show file tree
Hide file tree
Showing 17 changed files with 46 additions and 31 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.25.1]

### Fixes

- Handle status comment IDs as bigint/int8 because of integer overflow (GitHub IDs are just super large!)

## [0.25.0]

### Breaking changes
Expand Down Expand Up @@ -353,7 +359,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Give rights to external accounts on specific repositories
- Simple terminal UI interface to have an overview on pull requests

[Unreleased]: https://github.com/sharingcloud/github-scbot/compare/v0.25.0...HEAD
[Unreleased]: https://github.com/sharingcloud/github-scbot/compare/v0.25.1...HEAD
[0.25.1]: https://github.com/sharingcloud/github-scbot/compare/v0.25.0...v0.25.1
[0.25.0]: https://github.com/sharingcloud/github-scbot/compare/v0.24.0...v0.25.0
[0.24.0]: https://github.com/sharingcloud/github-scbot/compare/v0.23.1...v0.24.0
[0.23.1]: https://github.com/sharingcloud/github-scbot/compare/v0.23.0...v0.23.1
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ mod tests {
let repo_owner: String = "bar".into();

let mut ctx = CommandContextTest::new();
ctx.repo_name = repo_name.clone();
ctx.repo_owner = repo_owner.clone();
ctx.repo_name.clone_from(&repo_name);
ctx.repo_owner.clone_from(&repo_owner);
ctx.db_service
.repositories_create(Repository {
owner: repo_owner.clone(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ impl RenameRepositoryInterface for RenameRepository {
.await?;

if let Some(mut repo) = repo {
repo.owner = new_path.owner().to_owned();
repo.name = new_path.name().to_owned();
new_path.owner().clone_into(&mut repo.owner);
new_path.name().clone_into(&mut repo.name);

let repo = ctx.db_service.repositories_update(repo).await?;
Ok(Some(repo))
Expand Down
6 changes: 3 additions & 3 deletions crates/prbot-database-memory/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,8 @@ impl DbService for MemoryDb {
private_key: &str,
) -> Result<ExternalAccount> {
let mut account = self.external_accounts_get_expect(username).await?;
account.public_key = public_key.to_owned();
account.private_key = private_key.to_owned();
public_key.clone_into(&mut account.public_key);
private_key.clone_into(&mut account.private_key);
self.external_accounts
.write()
.unwrap()
Expand Down Expand Up @@ -874,7 +874,7 @@ impl DbService for MemoryDb {
value: &str,
) -> Result<Repository> {
let mut repository = self.repositories_get_expect(owner, name).await?;
repository.pr_title_validation_regex = value.to_owned();
value.clone_into(&mut repository.pr_title_validation_regex);
self.repositories
.write()
.unwrap()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE pull_request ALTER COLUMN status_comment_id TYPE bigint;
2 changes: 2 additions & 0 deletions crates/prbot-database-pg/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ where
A: Acquire<'a>,
<A::Connection as Deref>::Target: Migrate,
{
info!("Running migrations");

sqlx::migrate!("./migrations")
.run(migrator)
.await
Expand Down
4 changes: 2 additions & 2 deletions crates/prbot-database-pg/src/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ impl DbService for PostgresDb {
.bind(instance.number as i32)
.bind(instance.qa_status.to_string())
.bind(instance.needed_reviewers_count as i32)
.bind(instance.status_comment_id as i32)
.bind(instance.status_comment_id as i64)
.bind(instance.checks_enabled)
.bind(instance.automerge)
.bind(instance.locked)
Expand Down Expand Up @@ -805,7 +805,7 @@ impl DbService for PostgresDb {
)
.bind(instance.qa_status.to_string())
.bind(instance.needed_reviewers_count as i32)
.bind(instance.status_comment_id as i32)
.bind(instance.status_comment_id as i64)
.bind(instance.checks_enabled)
.bind(instance.automerge)
.bind(instance.locked)
Expand Down
4 changes: 2 additions & 2 deletions crates/prbot-database-tests/src/testcase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ where
let full_name = format!("test-bot-{test_name}");
let base_url = get_base_url(&config.database.pg.url);
let new_url = create_db_url(&base_url, &full_name);
config.database.pg.url = new_url.clone();
config.database.pg.url.clone_from(&new_url);
config.database.pg.pool_size = 2;
config.database.pg.connection_timeout = 5;

Expand Down Expand Up @@ -50,7 +50,7 @@ where
let full_name = format!("test-bot-{test_name}");
let base_url = get_base_url(&config.database.pg.url);
let new_url = create_db_url(&base_url, &full_name);
config.database.pg.url = new_url.clone();
config.database.pg.url.clone_from(&new_url);
config.database.pg.pool_size = 2;
config.database.pg.connection_timeout = 5;

Expand Down
2 changes: 1 addition & 1 deletion crates/prbot-ghapi-github/src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ async fn get_or_create_installation_access_token(
// Time to rebuild!
let token = create_installation_access_token(config, api_service).await?;
let mut last_auth = LAST_TOKEN.write().await;
last_auth.token = token.clone();
last_auth.token.clone_from(&token);
last_auth.expiration = now_timestamp + INSTALLATION_TOKEN_LIFETIME_IN_SECONDS;

Ok(token)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::fmt::Display;

use serde::{Deserialize, Serialize};

/// GitHub Review state.
Expand All @@ -17,9 +19,9 @@ pub enum GhReviewState {
Pending,
}

impl ToString for GhReviewState {
fn to_string(&self) -> String {
serde_plain::to_string(&self).unwrap()
impl Display for GhReviewState {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(&serde_plain::to_string(&self).unwrap())
}
}

Expand Down
8 changes: 5 additions & 3 deletions crates/prbot-models/src/checks_status.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::fmt::Display;

use serde::{Deserialize, Serialize};
use thiserror::Error;

Expand Down Expand Up @@ -30,9 +32,9 @@ impl ChecksStatus {
}
}

impl ToString for ChecksStatus {
fn to_string(&self) -> String {
self.to_str().into()
impl Display for ChecksStatus {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(self.to_str())
}
}

Expand Down
8 changes: 4 additions & 4 deletions crates/prbot-models/src/qa_status.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::str::FromStr;
use std::{fmt::Display, str::FromStr};

use serde::{Deserialize, Serialize};
use thiserror::Error;
Expand Down Expand Up @@ -32,9 +32,9 @@ impl QaStatus {
}
}

impl ToString for QaStatus {
fn to_string(&self) -> String {
self.to_str().into()
impl Display for QaStatus {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(self.to_str())
}
}

Expand Down
3 changes: 2 additions & 1 deletion crates/prbot-models/src/repository.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ impl Repository {
.try_into()
.unwrap_or_default();
self.default_needed_reviewers_count = config.default_needed_reviewers_count;
self.pr_title_validation_regex = config.default_pr_title_validation_regex.clone();
self.pr_title_validation_regex
.clone_from(&config.default_pr_title_validation_regex);
self
}
}
8 changes: 4 additions & 4 deletions crates/prbot-models/src/step_label.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Label types.
use std::convert::TryFrom;
use std::{convert::TryFrom, fmt::Display};

use thiserror::Error;

Expand Down Expand Up @@ -41,9 +41,9 @@ impl StepLabel {
}
}

impl ToString for StepLabel {
fn to_string(&self) -> String {
self.to_str().into()
impl Display for StepLabel {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(self.to_str())
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/prbot/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "prbot"
version = "0.25.0"
version = "0.25.1"
authors = ["Denis BOURGE <Srynetix@users.noreply.github.com>"]
edition = "2021"
build = "build.rs"
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "stable"
channel = "1.78.0"
components = ["clippy", "rustfmt", "llvm-tools"]

0 comments on commit 6eeb3fa

Please sign in to comment.