about summary refs log tree commit diff
path: root/src/bootstrap/bin
diff options
context:
space:
mode:
authorMara Bos <m-ou.se@m-ou.se>2022-02-07 14:08:29 +0000
committerGitHub <noreply@github.com>2022-02-07 14:08:29 +0000
commitaee13fb7c50faba1db567736c1b17cbc4716c74d (patch)
treea8e3966b484f7b8075acf6b689a894390ca09c49 /src/bootstrap/bin
parent926e7843eaa1794f15948395588eddedfb74a0d8 (diff)
parent9d664b24f92fbbe22b3243014bb98f6878db30a9 (diff)
downloadrust-aee13fb7c50faba1db567736c1b17cbc4716c74d.tar.gz
rust-aee13fb7c50faba1db567736c1b17cbc4716c74d.zip
Rollup merge of #88313 - jyn514:pre-push, r=Mark-Simulacrum
Make the pre-commit script pre-push instead

This should make it substantially less annoying, and hopefully more
people will find it useful. In particular, it will no longer run tidy
each time you run `git commit --amend` or rebase a branch.

This also warns if you have the old script in pre-commit; see the HACK
comment for details.

r? ````@Mark-Simulacrum```` cc ````@caass````
Diffstat (limited to 'src/bootstrap/bin')
-rw-r--r--src/bootstrap/bin/main.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/bootstrap/bin/main.rs b/src/bootstrap/bin/main.rs
index e730a2557e0..9c41ab69c8b 100644
--- a/src/bootstrap/bin/main.rs
+++ b/src/bootstrap/bin/main.rs
@@ -30,6 +30,7 @@ fn main() {
         println!("{}", suggestion);
     }
 
+    let pre_commit = config.src.join(".git").join("hooks").join("pre-commit");
     Build::new(config).build();
 
     if suggest_setup {
@@ -42,6 +43,19 @@ fn main() {
         println!("{}", suggestion);
     }
 
+    // Give a warning if the pre-commit script is in pre-commit and not pre-push.
+    // HACK: Since the commit script uses hard links, we can't actually tell if it was installed by x.py setup or not.
+    // We could see if it's identical to src/etc/pre-push.sh, but pre-push may have been modified in the meantime.
+    // Instead, look for this comment, which is almost certainly not in any custom hook.
+    if std::fs::read_to_string(pre_commit).map_or(false, |contents| {
+        contents.contains("https://github.com/rust-lang/rust/issues/77620#issuecomment-705144570")
+    }) {
+        println!(
+            "warning: You have the pre-push script installed to .git/hooks/pre-commit. \
+                  Consider moving it to .git/hooks/pre-push instead, which runs less often."
+        );
+    }
+
     if suggest_setup || changelog_suggestion.is_some() {
         println!("note: this message was printed twice to make it more likely to be seen");
     }