Skip to content

Commit

Permalink
chore: cargo fmt everything
Browse files Browse the repository at this point in the history
  • Loading branch information
quodlibetor committed Sep 21, 2024
1 parent c10ae57 commit 52a1be1
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 31 deletions.
4 changes: 3 additions & 1 deletion spr/src/commands/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,9 @@ fn validate_branch_prefix(branch_prefix: &str) -> Result<()> {
}

if branch_prefix.contains("//") || branch_prefix.starts_with('/') {
return Err(Error::new("Branch prefix contains multiple consecutive slashes or starts with slash."));
return Err(Error::new(
"Branch prefix contains multiple consecutive slashes or starts with slash.",
));
}

if branch_prefix.contains("@{") {
Expand Down
4 changes: 2 additions & 2 deletions spr/src/commands/land.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,10 @@ pub async fn land(

if git.get_tree_oid_for_commit(merge_commit)? != our_tree_oid {
return Err(Error::new(formatdoc!(
"This commit has been updated and/or rebased since the pull
"This commit has been updated and/or rebased since the pull
request was last updated. Please run `spr diff` to update the pull
request and then try `spr land` again!"
)));
)));
}
};

Expand Down
4 changes: 3 additions & 1 deletion spr/src/commands/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ fn print_pr_info(
let term = console::Term::stdout();
for pr in response_body.data?.search.nodes? {
let pr = match pr {
Some(crate::commands::list::search_query::SearchQuerySearchNodes::PullRequest(pr)) => pr,
Some(crate::commands::list::search_query::SearchQuerySearchNodes::PullRequest(pr)) => {
pr
}
_ => continue,
};
let dummy: String;
Expand Down
4 changes: 3 additions & 1 deletion spr/src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ pub struct Git {
impl Git {
pub fn new(repo: git2::Repository) -> Self {
Self {
hooks: std::sync::Arc::new(std::sync::Mutex::new(git2_ext::hooks::Hooks::with_repo(&repo).unwrap())),
hooks: std::sync::Arc::new(std::sync::Mutex::new(
git2_ext::hooks::Hooks::with_repo(&repo).unwrap(),
)),
repo: std::sync::Arc::new(std::sync::Mutex::new(repo)),
}
}
Expand Down
35 changes: 17 additions & 18 deletions spr/src/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,8 @@ type GitObjectID = String;
pub struct PullRequestMergeabilityQuery;

impl GitHub {
pub fn new(
config: crate::config::Config,
git: crate::git::Git,
) -> Self {
Self {
config,
git,
}
pub fn new(config: crate::config::Config, git: crate::git::Git) -> Self {
Self { config, git }
}

pub async fn get_github_user(login: String) -> Result<UserWithName> {
Expand All @@ -159,10 +153,7 @@ impl GitHub {
}

pub async fn get_pull_request(self, number: u64) -> Result<PullRequest> {
let GitHub {
config,
git,
} = self;
let GitHub { config, git } = self;

let variables = pull_request_query::Variables {
name: config.repo.clone(),
Expand Down Expand Up @@ -226,17 +217,25 @@ impl GitHub {
let user_name = review.author.as_ref()?.login.clone();
let status = match review.state {
pull_request_query::PullRequestReviewState::APPROVED => ReviewStatus::Approved,
pull_request_query::PullRequestReviewState::CHANGES_REQUESTED => ReviewStatus::Rejected,
pull_request_query::PullRequestReviewState::CHANGES_REQUESTED => {
ReviewStatus::Rejected
}
_ => ReviewStatus::Requested,
};
Some((user_name, status))
})
.collect();

let review_status = match pr.review_decision {
Some(pull_request_query::PullRequestReviewDecision::APPROVED) => Some(ReviewStatus::Approved),
Some(pull_request_query::PullRequestReviewDecision::CHANGES_REQUESTED) => Some(ReviewStatus::Rejected),
Some(pull_request_query::PullRequestReviewDecision::REVIEW_REQUIRED) => Some(ReviewStatus::Requested),
Some(pull_request_query::PullRequestReviewDecision::APPROVED) => {
Some(ReviewStatus::Approved)
}
Some(pull_request_query::PullRequestReviewDecision::CHANGES_REQUESTED) => {
Some(ReviewStatus::Rejected)
}
Some(pull_request_query::PullRequestReviewDecision::REVIEW_REQUIRED) => {
Some(ReviewStatus::Requested)
}
_ => None,
};

Expand Down Expand Up @@ -421,8 +420,8 @@ impl GitHub {
_ => None,
},
merge_commit: pr
.merge_commit
.and_then(|sha| git2::Oid::from_str(&sha.oid).ok()),
.merge_commit
.and_then(|sha| git2::Oid::from_str(&sha.oid).ok()),
})
}
}
Expand Down
13 changes: 5 additions & 8 deletions spr/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,7 @@ enum Commands {

#[derive(Debug, thiserror::Error)]
pub enum OptionsError {
#[error(
"GitHub repository must be given as 'OWNER/REPO', but given value was '{0}'"
)]
#[error("GitHub repository must be given as 'OWNER/REPO', but given value was '{0}'")]
InvalidRepository(String),
}

Expand Down Expand Up @@ -137,7 +135,9 @@ pub async fn spr() -> Result<()> {
let branch_prefix = cli
.branch_prefix
.map_or_else(|| git_config.get_string("spr.branchPrefix"), Ok)
.map_err(|e| Error::new(format!("spr.branchPrefix must be configured: {e:?}")))?;
.map_err(|e| {
Error::new(format!("spr.branchPrefix must be configured: {e:?}"))
})?;
let require_approval = git_config
.get_bool("spr.requireApproval")
.ok()
Expand Down Expand Up @@ -185,10 +185,7 @@ pub async fn spr() -> Result<()> {
format!("Bearer {}", github_auth_token).parse()?,
);

let mut gh = spr::github::GitHub::new(
config.clone(),
git.clone(),
);
let mut gh = spr::github::GitHub::new(config.clone(), git.clone());

match cli.command {
Commands::Diff(opts) => {
Expand Down

0 comments on commit 52a1be1

Please sign in to comment.