Skip to content

Commit 5b21c7b

Browse files
bors[bot]matklad
andauthored
Merge #5923
5923: "How I survived Git" tips r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
2 parents c31a43d + dddd580 commit 5b21c7b

File tree

2 files changed

+32
-10
lines changed

2 files changed

+32
-10
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
uses: actions/checkout@v2
3333
with:
3434
ref: ${{ github.event.pull_request.head.sha }}
35-
fetch-depth: 5
35+
fetch-depth: 20
3636

3737
# We need to disable the existing toolchain to avoid updating rust-docs
3838
# which takes a long time. The fastest way to do this is to rename the

xtask/tests/tidy.rs

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,37 @@ fn rust_files_are_tidy() {
5252

5353
#[test]
5454
fn check_merge_commits() {
55-
let cmd_output =
56-
run!("git rev-list --merges --invert-grep --author 'bors\\[bot\\]' HEAD~4.."; echo = false);
57-
match cmd_output {
58-
Ok(out) => {
59-
if !out.is_empty() {
60-
panic!("Please rebase your branch on top of master by running `git rebase master`");
61-
}
62-
}
63-
Err(e) => panic!("{}", e),
55+
let stdout = run!("git rev-list --merges --invert-grep --author 'bors\\[bot\\]' HEAD~19.."; echo = false)
56+
.unwrap();
57+
if !stdout.is_empty() {
58+
panic!(
59+
"
60+
Merge commits are not allowed in the history.
61+
62+
When updating a pull-request, please rebase your feature branch
63+
on top of master by running `git rebase master`. If rebase fails,
64+
you can re-apply your changes like this:
65+
66+
# Abort in-progress rebase, if any.
67+
$ git rebase --abort
68+
69+
# Make the branch point to the latest commit from master,
70+
# while maintaining your local changes uncommited.
71+
$ git reset --soft origin/master
72+
73+
# Commit all changes in a single batch.
74+
$ git commit -am'My changes'
75+
76+
# Push the changes. We did a rebase, so we need `--force` option.
77+
# `--force-with-lease` is a more safe (Rusty) version of `--force`.
78+
$ git push --force-with-lease
79+
80+
And don't fear to mess something up during a rebase -- you can
81+
always restore the previous state using `git ref-log`:
82+
83+
https://github.blog/2015-06-08-how-to-undo-almost-anything-with-git/#redo-after-undo-local
84+
"
85+
);
6486
}
6587
}
6688

0 commit comments

Comments
 (0)