Giter VIP home page Giter VIP logo

node-branch-merge-util's Introduction

Git Branch Auto Merge

Utility to automatically merge branches based on semver version number. It's meant to be run either as a Jenkins job, or locally.

For example, if you have a branch for release/v3.4.0, hotfix/v3.2.0 and a main branch called develop. The utility will first merge hotfix/v3.2.0 -> release/v3.4.0 due to the lower version from the hotfix branch. It will then take the release/v3.4.0 branch and it will merge it into develop (your main branch).

The version comparion is done using the semver version library that npm uses. So it will be done in a consistent manner as long as proper branch semver versioning conventions are followed.

In addition to the auto merging cabilility, the utility will also setup a merge strategy to ignore merge conflicts around the app-version.json file. This is to ensure that we can keep the version from the host branch and not overwrite it or fail the auto merge due to having different versions across branches. You can read more about merge strategies and the .gitattributes file here

Getting Started

> npm i
> node ./branch-merge.js --branchPrefixList=release_test --masterBranch=develop_test

Prerequisites

Make sure that you have your git account setup locally since it'll run git commands under your name.

Args

--gitUrl (string)

The .git url for the repo you are running the merge commands agains't. Keep in mind that the username on the git url must have permission to pull and push change to the repo

--branchPrefixList (string list space - delimited)

Will scope your branch list for merging based on the naming specified.

Example Usage:

node ./branch-merge.js --branchPrefixList=release_test support_test--masterBranch=develop_test

The utility will only merge the branches that start with release_test/* and support_test/*. It will ignore all other branches on your repo.

NOTE: If you don't specify this arg, the utility will assume you want to merge any branch with the following naming convention name/v[0-9].[0-9].[0-9].

--masterBranch (string - required)

Specifies the master branch where the highest versioned branch will be merged into.

For example, if release/v3.4.0 is the highest version you have on your repo, then release/v3.4.0 will be merged into your master branch.

Example Usage:

node ./branch-merge.js --masterBranch=develop_test

--push (optional)

If specified, it will actually push the merge changes to the host branch. If not specified, it will perform a dry-run of the commands it will execute and print them to the console, and will not push your merge changes.

Please keep in mind that if you have merge priviledge on your branch, and you do add the flag, it will perform the merge operation and will push the changes. So make sure you know what you are doing if you do specify it locally ๐Ÿ’ช

Debugging

If you'd like to debug the script locally and are running VSCode, you can use the following debug config:

{
      "type": "node",
      "request": "launch",
      "name": "Branch merge",
      "program": "${workspaceFolder}/branch-merge-cli/branch-merge.js",
      "args": ["--branchPrefixList=release_test", "--masterBranch=develop_test"],
      "cwd": "${workspaceFolder}",
      "autoAttachChildProcesses": true
}

node-branch-merge-util's People

Contributors

babilog avatar babiloniagabriel avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.