Skip to content

Github action to enforce rebasing

Notifications You must be signed in to change notification settings

cyberark/enforce-rebase

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

"Enforce Rebase" Github Action

This action enforces clean, "single-bump" git history that looks like this:

It will fail any pushed PR branches if:

  1. A PR branch contains any merge commits.

    Specifically, this rule prevents developers from merging master into their branch as a way of making it up-to-date. This creates foxtrot commits and unsightly git log graphs.

    This also makes it illegal to update your branch using the Github UI's "Update Branch" button, which cannot be disabled and is a tempting way to merge master into your branch.

  2. The branch is not sitting on top of master.

    That is, it requires developers to rebase their work on the up-to-date master branch before merging.

Example use

Here's an example action.yml file. Note that you must explicitly include the actions/checkout@v2 step as well as the enforce-rebase@v2 step:

name: Enforce Rebasing

on: [push]

jobs:
  rebase_job:
    runs-on: ubuntu-latest
    name: Enforce rebasing

    steps:
    - name: Check out code
      uses: actions/checkout@v2
      with:
        fetch-depth: 0
    - name: Is Rebased on master?
      uses: cyberark/enforce-rebase@v2

default-branch

You can also specify the name of the branch which you want to enforce rebase on by using the default-branch parameter. By default this will force rebase onto master

e.g. For specifying main as the default branch.

- name: Is Rebased on master?
  uses: cyberark/enforce-rebase@v2
  with:
    default-branch: main

How is this different from the "Require Linear History" status check?

"Require linear history" does not allow the feature branch to merge into master. Thus while it keeps the history clean and rebased, it doesn't give you the "bump" to signify which commits are related as a single feature.

This action, by contrast, makes the related commits clear at glance while still keeping the history clean and rebased.

About

Github action to enforce rebasing

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%