Add a rebase script for safer rebasing
What does this MR do?
I've been getting very frustrated with red masters breaking pipelines on branches when I try to rebase up to master before merging. This MR adds a fairly simple bash script that will help rebase to the last known successful commit on a branch. This requires the jq
package to be installed for parsing JSON.
Currently it can be used like this:
./scripts/git/rebase master some-branch
# Optionally you can provide a project ID
./scripts/git/rebase 11111 master some-branch
This is a bit of a naive implementation as I don't write much bash, so suggestions are welcome.
Example
⋊> ~/D/g/g/gitlab on git-scripts ⨯ ./scripts/git/rebase master git-scripts 10:13:04
jq detected: jq-1.5-1-a5b5cbe
Default project ID being used
Project ID: 278964
Will rebase master onto git-scripts
Fetching latest master
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.
remote: Enumerating objects: 41, done.
remote: Counting objects: 100% (41/41), done.
remote: Compressing objects: 100% (20/20), done.
remote: Total 52 (delta 23), reused 26 (delta 21), pack-reused 11
Unpacking objects: 100% (52/52), 133.77 KiB | 4.61 MiB/s, done.
From gitlab.com:gitlab-org/gitlab
* branch master -> FETCH_HEAD
d53d3a72b77..b9940c46cf0 master -> origin/master
Updating d53d3a72b77..b9940c46cf0
Fast-forward
app/assets/javascripts/ide/components/commit_sidebar/form.vue | 12 +++---------
app/assets/javascripts/ide/components/file_row_extra.vue | 15 ++++-----------
app/assets/javascripts/ide/stores/actions.js | 9 ++-------
app/assets/javascripts/ide/stores/actions/file.js | 4 +---
app/controllers/ide_controller.rb | 4 ----
locale/gitlab.pot | 6 ------
spec/frontend/ide/stores/actions/file_spec.js | 68 ++++++++------------------------------------------------------------
spec/frontend/ide/stores/integration_spec.js | 15 +++++----------
spec/javascripts/ide/components/commit_sidebar/form_spec.js | 2 +-
spec/javascripts/ide/components/file_row_extra_spec.js | 2 +-
spec/javascripts/ide/stores/actions_spec.js | 101 ++++++++++++++---------------------------------------------------------------------------------------
11 files changed, 39 insertions(+), 199 deletions(-)
Fetching last successful pipeline run for master
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 4981 100 4981 0 0 7390 0 --:--:-- --:--:-- --:--:-- 7379
Rebasing up to d53d3a72b773ae8d251cc25f5e86df55a3ac505a
Switched to branch 'git-scripts'
First, rewinding head to replay your work on top of it...
Fast-forwarded git-scripts to d53d3a72b773ae8d251cc25f5e86df55a3ac505a.
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team
Edited by Robert May