mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-25 04:23:25 +00:00
"How I survived Git" tips
This commit is contained in:
parent
c31a43d360
commit
dddd580651
2 changed files with 32 additions and 10 deletions
2
.github/workflows/ci.yaml
vendored
2
.github/workflows/ci.yaml
vendored
|
@ -32,7 +32,7 @@ jobs:
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
ref: ${{ github.event.pull_request.head.sha }}
|
ref: ${{ github.event.pull_request.head.sha }}
|
||||||
fetch-depth: 5
|
fetch-depth: 20
|
||||||
|
|
||||||
# We need to disable the existing toolchain to avoid updating rust-docs
|
# We need to disable the existing toolchain to avoid updating rust-docs
|
||||||
# which takes a long time. The fastest way to do this is to rename the
|
# which takes a long time. The fastest way to do this is to rename the
|
||||||
|
|
|
@ -52,15 +52,37 @@ fn rust_files_are_tidy() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn check_merge_commits() {
|
fn check_merge_commits() {
|
||||||
let cmd_output =
|
let stdout = run!("git rev-list --merges --invert-grep --author 'bors\\[bot\\]' HEAD~19.."; echo = false)
|
||||||
run!("git rev-list --merges --invert-grep --author 'bors\\[bot\\]' HEAD~4.."; echo = false);
|
.unwrap();
|
||||||
match cmd_output {
|
if !stdout.is_empty() {
|
||||||
Ok(out) => {
|
panic!(
|
||||||
if !out.is_empty() {
|
"
|
||||||
panic!("Please rebase your branch on top of master by running `git rebase master`");
|
Merge commits are not allowed in the history.
|
||||||
}
|
|
||||||
}
|
When updating a pull-request, please rebase your feature branch
|
||||||
Err(e) => panic!("{}", e),
|
on top of master by running `git rebase master`. If rebase fails,
|
||||||
|
you can re-apply your changes like this:
|
||||||
|
|
||||||
|
# Abort in-progress rebase, if any.
|
||||||
|
$ git rebase --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'
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
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
|
||||||
|
"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue