Skip to content

Extract the Jira Issue Key(e.g. GWT-1) from current git branch name(e.g. GWT-1-ci-cd-tests).

License

Notifications You must be signed in to change notification settings

flashios09/jira-issue-key

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jira Issue Key

CI Status GitHub release (latest by date)

Extract the Jira Issue Key(e.g. GWT-1) from current git branch name(e.g. GWT-1-ci-cd-tests).

Installation

# Clone the repo
git clone https://github.com/flashios09/jira-issue-key.git
# CD to `jira-issue-key` folder
cd jira-issue-key
# Make `script.sh` executable
chmod +x ./script.sh
# Create a symlink inside a bin dir, e.g. `/usr/local/bin`(must be in your path)
ln -s "$PWD/script.sh" /usr/local/bin/jik
# Check jik is installed, must output `/usr/local/bin/jik` !
which jik

Usage

jik [OPTIONS]               execute the script with the specified options
jik -h|--help               display this output
jik -v|--version            display the script version

Options:

--sed-regex|-E <regex>      the sed regex expression used to extract the jira issue key from branch name
                            (default sed regex 's/[a-z_]*\/*([A-Z]+-[0-9]+).*/\1/p')
                            e.g. jik -E 's/[a-z_]*\/*([A-Z]+-[0-9]+).*/\1/p'

Examples of git branch names*

  • GWT-1-ci-cd
  • feature/GWT-1-ci-cd
  • hotfix/GWT-1-ci-cd
  • bugfix/GWT-1-ci-cd
  • any_branch_prefix/GWT-1-ci-cd

-> jik will always return GWT-1.

Check the ci.yml github action for more examples and tests.

*captured with default sed regex expression

Using with git commit

# bash, zsh
git commit -m "$(jik) The commit message here ..."
# fish
JIRA_ISSUE_KEY=(jik) git commit -m "$JIRA_ISSUE_KEY The commit message here ..."

Abbr for fish:

Just add a gcm abbr to your ~/.config/fish/config.fish file:

if status is-interactive
    # your abbr(s)
    # ...
    abbr --add gcm 'JIRA_ISSUE_KEY=(jik) git commit -m "$JIRA_ISSUE_KEY'
end

Source your ~/.config/fish/config.fish file after adding the gcm abbr:

source ~/.config/fish/config.fish

Now just type gcm and it will be expanded to JIRA_ISSUE_KEY=(jik) git commit -m "$JIRA_ISSUE_KEY .

Contributing

Just clone or fork the repository :)

We are using shellcheck as script analysis tool and shfmt for script formatting.

Linting:

# used on `ci.yml` github action
shellcheck ./script.sh
shfmt -i 4 -d ./script.sh

License

This project is licensed under the MIT License.

About

Extract the Jira Issue Key(e.g. GWT-1) from current git branch name(e.g. GWT-1-ci-cd-tests).

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages