From f48f84224be04522e5387568a1e76b27c7ae1e03 Mon Sep 17 00:00:00 2001 From: Eric Allen Date: Wed, 11 Nov 2020 18:47:12 -0500 Subject: [PATCH] feat(main-branch): add support for Github main branch This implements support for the "main" branch name that is now used by Github in place of "master" but falls back to master if main isn't found. --- commitizen.config.js | 3 ++- commitlint.config.js | 3 --- src/jlegrone.gitconfig | 9 ++++++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/commitizen.config.js b/commitizen.config.js index 1cdcbae..c608b1c 100644 --- a/commitizen.config.js +++ b/commitizen.config.js @@ -63,7 +63,8 @@ const scopes = [ 'status', 'branch-name', 'develop-branch', - 'upstream-or-origin' + 'upstream-or-origin', + 'main-branch' ].map(name => ({ name })); module.exports = { diff --git a/commitlint.config.js b/commitlint.config.js index e0cbeef..d40f213 100644 --- a/commitlint.config.js +++ b/commitlint.config.js @@ -14,8 +14,5 @@ module.exports = { // Apply valid scopes and types 'scope-enum': [scopeValidationLevel, 'always', validScopes], 'type-enum': [2, 'always', validTypes], - - // Disable language rule - lang: [0, 'always', 'eng'] } }; diff --git a/src/jlegrone.gitconfig b/src/jlegrone.gitconfig index ad6e024..65bda08 100644 --- a/src/jlegrone.gitconfig +++ b/src/jlegrone.gitconfig @@ -22,7 +22,7 @@ # Start a hotfix branch based off of latest master branch # Usage: git hotfix - hotfix = "!sh -c \"git checkout master && git pull && git cb hotfix/$1\" -" + hotfix = "!sh -c \"git checkout $(git main-branch) && git pull && git cb hotfix/$1\" -" # Create a "work in progress" commit with your current changes # Usage: git wip @@ -67,7 +67,7 @@ # Delete merged branches # Usage: git cleanup - cleanup = "!git branch --merged | grep -v '\\*\\|master\\|develop' | xargs -n 1 git branch -d" + cleanup = "!git branch --merged | grep -v '\\*\\|main\\|master\\|develop' | xargs -n 1 git branch -d" # Create a new branch # Usage: git cb @@ -85,7 +85,10 @@ branch-name = "!git rev-parse --abbrev-ref HEAD" # Get the develop branch (used in other aliases) - develop-branch = "!(git show-ref --quiet refs/heads/develop && echo develop) || echo master" + develop-branch = "!(git show-ref --quiet refs/heads/develop && echo develop) || echo $(git main-branch)" # Get remote name (prefer upstream over origin) upstream-or-origin = "!(git remote | grep upstream) || echo origin" + + # Get main branch name (prefer main over master) + main-branch="!(git show-ref --quiet refs/heads/main && echo main) || echo master"