Skip to content

Instantly share code, notes, and snippets.

@Lazercat
Forked from sbimochan/unique-branches.md
Created January 10, 2023 23:26
Show Gist options
  • Select an option

  • Save Lazercat/5529e5af92e7c89bc81d96ff3403da7b to your computer and use it in GitHub Desktop.

Select an option

Save Lazercat/5529e5af92e7c89bc81d96ff3403da7b to your computer and use it in GitHub Desktop.
Get All unique commits going to staging branch from dev or other

Make sure you pulled all the commits in dev and staging branch

Approriately change if needed for master and staging.

git log origin/staging..origin/dev --oneline --no-merges

Press enter and grab all the result in clipboard

Fire up the console

Store the result in a variable like this. Make sure there are no tilds in the result.

const commits = `CPT-1233: I did something
CPT-4312: You did something`

Modify CPT or DGN according to your jira prefix

const regex = /[CPT,DGN,AP,MBC,DVOP]{2,}-\d{2,}/g
const branches = commits.match(regex)
const set = new Set(branches)
Array.from(set).join(', ')

You get the unique branches that are going to staging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment