From c5204087316a79be9e39d9944cd5380313fe095e Mon Sep 17 00:00:00 2001 From: Amos Wenger Date: Wed, 20 Jul 2022 15:49:40 +0200 Subject: [PATCH 1/3] Allow merge commits when 'in-rust-tree' feature is enabled This adds an `in-rust-tree` feature that will be enabled when rust-analyzer is built from `rust-lang/rust`. Due to the way "git subtree" works, that test _will_ find merge commits and fail, so we simply skip it. --- crates/rust-analyzer/Cargo.toml | 1 + crates/rust-analyzer/tests/slow-tests/tidy.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml index c37a0d17491d..6998209a078e 100644 --- a/crates/rust-analyzer/Cargo.toml +++ b/crates/rust-analyzer/Cargo.toml @@ -84,3 +84,4 @@ mbe = { path = "../mbe" } [features] jemalloc = ["jemallocator", "profile/jemalloc"] force-always-assert = ["always-assert/force"] +in-rust-tree = [] diff --git a/crates/rust-analyzer/tests/slow-tests/tidy.rs b/crates/rust-analyzer/tests/slow-tests/tidy.rs index 1d666fdf0f3d..63337214cd62 100644 --- a/crates/rust-analyzer/tests/slow-tests/tidy.rs +++ b/crates/rust-analyzer/tests/slow-tests/tidy.rs @@ -142,6 +142,7 @@ fn check_cargo_toml(path: &Path, text: String) { } } +#[cfg(not(feature = "in-rust-tree"))] #[test] fn check_merge_commits() { let sh = &Shell::new().unwrap(); From d5b1ae66c21e354f062916d477d8bd2f0f21a8ff Mon Sep 17 00:00:00 2001 From: Amos Wenger Date: Wed, 20 Jul 2022 15:57:13 +0200 Subject: [PATCH 2/3] Remove check_merge_commits test altogether Rationale: Merge commits will probably end up in `rust-lang/rust-analyzer` when doing "rust=>ra" syncs anyway. It could be changed to only check for merge commits in non-sync PRs, but it's "probably not worth the hassle" --- crates/rust-analyzer/tests/slow-tests/tidy.rs | 51 ------------------- 1 file changed, 51 deletions(-) diff --git a/crates/rust-analyzer/tests/slow-tests/tidy.rs b/crates/rust-analyzer/tests/slow-tests/tidy.rs index 63337214cd62..dc3c5539c2cb 100644 --- a/crates/rust-analyzer/tests/slow-tests/tidy.rs +++ b/crates/rust-analyzer/tests/slow-tests/tidy.rs @@ -142,57 +142,6 @@ fn check_cargo_toml(path: &Path, text: String) { } } -#[cfg(not(feature = "in-rust-tree"))] -#[test] -fn check_merge_commits() { - let sh = &Shell::new().unwrap(); - - let bors = cmd!(sh, "git rev-list --merges --author 'bors' HEAD~19..").read().unwrap(); - let all = cmd!(sh, "git rev-list --merges HEAD~19..").read().unwrap(); - if bors != all { - panic!( - " -Merge commits are not allowed in the history. - -When updating a pull-request, please rebase your feature branch -on top of master by running `git rebase master`. If rebase fails, -you can re-apply your changes like this: - - # Just look around to see the current state. - $ git status - $ git log - - # Abort in-progress rebase and merges, if any. - $ git rebase --abort - $ git merge --abort - - # Make the branch point to the latest commit from master, - # while maintaining your local changes uncommited. - $ git reset --soft origin/master - - # Commit all changes in a single batch. - $ git commit -am'My changes' - - # Verify that everything looks alright. - $ git status - $ git log - - # Push the changes. We did a rebase, so we need `--force` option. - # `--force-with-lease` is a more safe (Rusty) version of `--force`. - $ git push --force-with-lease - - # Verify that both local and remote branch point to the same commit. - $ git log - -And don't fear to mess something up during a rebase -- you can -always restore the previous state using `git ref-log`: - -https://github.blog/2015-06-08-how-to-undo-almost-anything-with-git/#redo-after-undo-local -" - ); - } -} - fn deny_clippy(path: &Path, text: &str) { let ignore = &[ // The documentation in string literals may contain anything for its own purposes From 244f29b1e7747c97922918c1d03df7ec96c2b965 Mon Sep 17 00:00:00 2001 From: Amos Wenger Date: Wed, 20 Jul 2022 15:58:56 +0200 Subject: [PATCH 3/3] Remove in-rust-tree feature Since it's unused for now -it'll be re-introduced along with the upcoming `proc-macro-srv/sysroot` feature. --- crates/rust-analyzer/Cargo.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml index 6998209a078e..c37a0d17491d 100644 --- a/crates/rust-analyzer/Cargo.toml +++ b/crates/rust-analyzer/Cargo.toml @@ -84,4 +84,3 @@ mbe = { path = "../mbe" } [features] jemalloc = ["jemallocator", "profile/jemalloc"] force-always-assert = ["always-assert/force"] -in-rust-tree = []