Skip to content

Commit ede58cb

Browse files
authored
Merge pull request #631 from rust-lang/revert-630-bors-squash
Revert "Implement `@bors squash` command"
2 parents 5f4c27f + 6fa78bf commit ede58cb

11 files changed

Lines changed: 17 additions & 344 deletions

File tree

src/bors/command/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,4 @@ pub enum BorsCommand {
134134
Retry,
135135
/// Cancel an auto build currently running on a given PR (without removing it from the queue).
136136
Cancel,
137-
/// Squash all commits of a pull request into a single commit.
138-
Squash,
139137
}

src/bors/command/parser.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ const DEFAULT_PARSERS: &[ParserFn] = &[
138138
parser_retry,
139139
parser_tree_ops,
140140
parser_cancel,
141-
parser_squash,
142141
];
143142

144143
fn parse_command(input: &str, parsers: &[ParserFn]) -> ParseResult {
@@ -443,14 +442,6 @@ fn parser_cancel(command: &CommandPart<'_>, _parts: &[CommandPart<'_>]) -> Parse
443442
}
444443
}
445444

446-
/// Parses `@bors squash` command.
447-
fn parser_squash(command: &CommandPart<'_>, _parts: &[CommandPart<'_>]) -> ParseResult {
448-
match command {
449-
CommandPart::Bare("squash") => Some(Ok(BorsCommand::Squash)),
450-
_ => None,
451-
}
452-
}
453-
454445
#[cfg(test)]
455446
mod tests {
456447
use crate::bors::command::parser::{CommandParseError, CommandParser};
@@ -1363,13 +1354,6 @@ for the crater",
13631354
assert_eq!(cmds[0], Ok(BorsCommand::Cancel));
13641355
}
13651356

1366-
#[test]
1367-
fn parse_squash() {
1368-
let cmds = parse_commands("@bors squash");
1369-
assert_eq!(cmds.len(), 1);
1370-
assert_eq!(cmds[0], Ok(BorsCommand::Squash));
1371-
}
1372-
13731357
#[test]
13741358
fn parse_in_html_command() {
13751359
let cmds = parse_commands(

src/bors/handlers/help.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ mod tests {
5252
- `try cancel`: Cancel a running try build on the current PR.
5353
- `retry`: Clear a failed auto build status from an approved PR. This will cause the merge queue to eventually attempt to merge the PR again.
5454
- `cancel` | `yield`: Cancel a running auto build on the current PR.
55-
- `squash`: Squash the commits of a PR into a single commit.
5655
- `info`: Get information about the current PR
5756
5857
## Repository management

src/bors/handlers/mod.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use crate::bors::handlers::refresh::{
1515
use crate::bors::handlers::review::{
1616
command_approve, command_close_tree, command_open_tree, command_unapprove,
1717
};
18-
use crate::bors::handlers::squash::command_squash;
1918
use crate::bors::handlers::trybuild::{command_try_build, command_try_cancel};
2019
use crate::bors::handlers::workflow::{handle_workflow_completed, handle_workflow_started};
2120
use crate::bors::labels::handle_label_trigger;
@@ -47,7 +46,6 @@ mod ping;
4746
mod pr_events;
4847
mod refresh;
4948
mod review;
50-
mod squash;
5149
mod trybuild;
5250
mod workflow;
5351

@@ -537,12 +535,6 @@ async fn handle_comment(
537535
.instrument(span)
538536
.await
539537
}
540-
BorsCommand::Squash => {
541-
let span = tracing::info_span!("Squash");
542-
command_squash(repo, database, pr, &comment.author, ctx.parser.prefix())
543-
.instrument(span)
544-
.await
545-
}
546538
};
547539
if result.is_err() {
548540
return result.context("Cannot execute Bors command");

src/bors/handlers/squash.rs

Lines changed: 0 additions & 144 deletions
This file was deleted.

src/bors/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ pub fn format_help() -> &'static str {
7878
BorsCommand::TreeClosed(_) => {}
7979
BorsCommand::Retry => {}
8080
BorsCommand::Cancel => {}
81-
BorsCommand::Squash => {}
8281
}
8382

8483
r#"
@@ -107,7 +106,6 @@ You can use the following commands:
107106
- `try cancel`: Cancel a running try build on the current PR.
108107
- `retry`: Clear a failed auto build status from an approved PR. This will cause the merge queue to eventually attempt to merge the PR again.
109108
- `cancel` | `yield`: Cancel a running auto build on the current PR.
110-
- `squash`: Squash the commits of a PR into a single commit.
111109
- `info`: Get information about the current PR
112110
113111
## Repository management

src/database/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,6 @@ pub fn pr_needs_update_in_db(db_pr: &PullRequestModel, gh_pr: &PullRequest) -> b
697697
number: _,
698698
head_label: _,
699699
head,
700-
head_repository: _,
701700
base,
702701
title,
703702
// It seems that when we query PRs in bulk from GitHub, the mergeability status is
@@ -709,7 +708,6 @@ pub fn pr_needs_update_in_db(db_pr: &PullRequestModel, gh_pr: &PullRequest) -> b
709708
status,
710709
labels: _,
711710
html_url: _,
712-
commit_count: _,
713711
} = gh_pr;
714712
if status != db_status {
715713
return true;

src/github/api/client.rs

Lines changed: 3 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -187,50 +187,6 @@ impl GithubRepositoryClient {
187187
Ok(prs)
188188
}
189189

190-
pub async fn get_pull_request_commits(
191-
&self,
192-
number: PullRequestNumber,
193-
) -> anyhow::Result<Vec<Commit>> {
194-
let commits = perform_retryable(
195-
"get_pull_request_commits",
196-
RetryMethod::default(),
197-
|| async {
198-
let response = self
199-
.client
200-
.pulls(self.repository().owner(), self.repository().name())
201-
.pr_commits(number.0)
202-
.per_page(100)
203-
.send()
204-
.await
205-
.map_err(|error| {
206-
anyhow::anyhow!(
207-
"Could not get PR {}#{number}: {error:?}",
208-
self.repository()
209-
)
210-
})?;
211-
212-
let mut commits = Vec::new();
213-
let mut stream = std::pin::pin!(response.into_stream(&self.client));
214-
while let Some(gh_commit) = stream.try_next().await? {
215-
let commit = Commit {
216-
sha: CommitSha(gh_commit.sha),
217-
parents: gh_commit
218-
.parents
219-
.into_iter()
220-
.filter_map(|p| p.sha.map(CommitSha))
221-
.collect(),
222-
tree: TreeSha(gh_commit.commit.tree.sha),
223-
author: CommitAuthor::from_gh(gh_commit.commit.author),
224-
};
225-
commits.push(commit);
226-
}
227-
anyhow::Ok(commits)
228-
},
229-
)
230-
.await?;
231-
Ok(commits)
232-
}
233-
234190
/// Post a comment to the pull request with the given number.
235191
/// The comment will be posted as the Github App user of the bot.
236192
pub async fn post_comment(
@@ -264,34 +220,7 @@ impl GithubRepositoryClient {
264220
force: ForcePush,
265221
) -> Result<(), crate::github::api::operations::BranchUpdateError> {
266222
perform_retryable("set_branch_to_sha", RetryMethod::default(), || async {
267-
set_branch_to_commit(self, self.repository(), branch.to_string(), sha, force)
268-
.await
269-
.map_err(|e| match e {
270-
error @ (BranchUpdateError::Conflict(_)
271-
| BranchUpdateError::ValidationFailed(_)) => ShouldRetry::No(error),
272-
error => ShouldRetry::Yes(error),
273-
})
274-
})
275-
.await
276-
.map_err(|error| match error {
277-
RetryableOpError::Err(error) => error,
278-
RetryableOpError::AllAttemptsExhausted(_) => BranchUpdateError::Timeout,
279-
})
280-
}
281-
282-
/// Set the given branch **of a fork** to a commit with the given `sha`.
283-
/// Must not be called on the same repository of this client.
284-
pub async fn set_fork_branch_to_sha(
285-
&self,
286-
repo: &GithubRepoName,
287-
branch: &str,
288-
sha: &CommitSha,
289-
force: ForcePush,
290-
) -> Result<(), crate::github::api::operations::BranchUpdateError> {
291-
assert_ne!(self.repository(), repo);
292-
293-
perform_retryable("set_fork_branch_to_sha", RetryMethod::default(), || async {
294-
set_branch_to_commit(self, repo, branch.to_string(), sha, force)
223+
set_branch_to_commit(self, branch.to_string(), sha, force)
295224
.await
296225
.map_err(|e| match e {
297226
error @ (BranchUpdateError::Conflict(_)
@@ -310,7 +239,7 @@ impl GithubRepositoryClient {
310239
pub async fn create_branch(&self, branch: &str, sha: &CommitSha) -> anyhow::Result<()> {
311240
perform_retryable("create_branch", RetryMethod::default(), || async {
312241
anyhow::Ok(
313-
create_branch(self, self.repository(), branch.to_string(), sha)
242+
create_branch(self, branch.to_string(), sha)
314243
.await
315244
.map_err(|err| anyhow::anyhow!("{err}"))?,
316245
)
@@ -800,27 +729,12 @@ pub struct CheckRunOutput {
800729
pub summary: String,
801730
}
802731

803-
#[derive(Debug, Clone, PartialEq, Eq)]
732+
#[derive(Debug)]
804733
pub struct CommitAuthor {
805734
pub name: String,
806735
pub email: String,
807736
}
808737

809-
impl CommitAuthor {
810-
pub fn from_gh(gh_author: Option<octocrab::models::repos::CommitAuthor>) -> Option<Self> {
811-
if let Some(author) = gh_author
812-
&& let Some(email) = author.email
813-
{
814-
Some(Self {
815-
name: author.name,
816-
email,
817-
})
818-
} else {
819-
None
820-
}
821-
}
822-
}
823-
824738
#[cfg(test)]
825739
mod tests {
826740
use crate::github::GithubRepoName;

0 commit comments

Comments
 (0)