GithubHelp home page GithubHelp logo

walmartdigital / commit-message-formatter Goto Github PK

View Code? Open in Web Editor NEW
34.0 3.0 11.0 141 KB

CMF is a simple-2-use utility to standardize commit messages on projects

License: MIT License

Go 99.54% Makefile 0.46%
cmf flow jira commit-message-formatter git commit

commit-message-formatter's People

Contributors

rodrigonavarro23 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

commit-message-formatter's Issues

Extract JIRA task from branch name

Hey, first of kudos for the nice work. I really like the functionality that you have put together with this branch.

I would like to know if you would be open to receive a PR with some added behavior for the JIRA template.

Let me know what you think of the suggestion and the approach and if you prefer I can open a PR with a draft and we discuss there.

Context

Internally we use a specific naming convention for branches. Would you consider to expand the current functionality to extract the JIRA_TASK based on a regex?

E.g., a branch with name feature/PRJ-0001 would become PRJ-0001 if I would pass the regex that would group the ID that I want.

Possible approach

With my approach I expect a valid regex to be defined in the config yaml (if the regex is not valid it will fail running CMF) and I also expect a group named JIRA_TASK to be available inside the regex (if not provided it returns the original branch name).

Rough sample (The Go Playground):

package main

import (
	"fmt"
	"regexp"
)

func findKey(names []string) int {
	key := "JIRA_TASK"
	
	for i, v := range names {
		if v == key {
			return i
		}
	}
	
	return 0
}

func getGitBranchName() string {
	// Current behaviour to fetch the branch name
	return "feature/PRJ-0001"
}


func getBranchName(regex string) (string, error) {
	branchName := getGitBranchName()
	
	r, err := regexp.Compile(regex)
	if err == nil {
		// Position of the group we expect (defaults to 0 to be the entire branch name)
		pos := findKey(r.SubexpNames())
	
		// Extracts the branch name
		branchName = r.FindStringSubmatch(branchName)[pos]
	}
	
	return branchName, err
}

func main() {
	jiraTaskRegex := "feature/(?P<JIRA_TASK>PRJ-[0-9]+)(-.*)?"
	
	branchName, err := getBranchName(jiraTaskRegex)
	if err == nil {
		fmt.Println("Branch name: ", branchName)
	} else {
		fmt.Println("Error: ", err)
	}
}

give feedback to the user :P

i love if you give more feedback in the terminal, because when i finish the cmf wizard, i dont now somethings important things like:

  • checking if the commit (gaa) was changed
  • the final commit message created by the tool :P

Selective story for task ID

When prompt task ID show "Jira task from branch", short branch name (cut in second dash), "NO-STORY" or custom with default branch name text

When commit has errors the message say OK

Having project with lint/test errors and add husky (npm run lint && npm run test)
Usin git

git commit -m "message"

The command execute my hooks and prevent commit/push when execution result has errors.

When use cmf, no execute commit but say is OK.

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.