LoginSignup
8
2

More than 5 years have passed since last update.

Gitブランチに対応するRedmineチケットを開く

Last updated at Posted at 2017-06-12

うちのチームでは、Gitのブランチに対応するチケットの番号を含めるようにしています。

こんな風に: feature/123456-fix-edit-form-validation

そのため「あれっ?不具合があるのはどの項目のことだっけ?」と思った時は、チケットもすぐ見つけれるんですが、その時にブラウザでRedmineを開いてコミット番号を入力するのは時間の無駄。

なので、こんなスクリプトを使っています(~/bin/redmine などに保存してください)。

#!/bin/bash
BRANCH="$(git branch 2>/dev/null | grep '^\*' | sed -e "s/^* //")"
ISSUE_BASE_URL="https://【うちのRedmineのホスト名】/issues"
if [[ "$BRANCH" =~ ^feature/([0-9]+)-.*$ ]]; then
  open "${ISSUE_BASE_URL}/${BASH_REMATCH[1]}"
else
  echo 'Branch name does not match [feature/123456-some-description]' >&2
  exit 1
fi
8
2
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
2