Skip to content

Commit

Permalink
Git: Smart commits #time 30m
Browse files Browse the repository at this point in the history
  • Loading branch information
astromatt committed Sep 30, 2022
1 parent 9fb1dad commit 9cd1f38
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 23 deletions.
15 changes: 9 additions & 6 deletions docker/_solution/ecosystem.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
networks:
ecosystem:

volumes:
gitea_config:
gitea_data:
jenkins_data:

services:

gitea:
Expand Down Expand Up @@ -36,10 +44,5 @@ services:
- jenkins_data:/var/jenkins_home
- /run/user/1000/docker.sock:/var/run/docker.sock

volumes:
gitea_config:
gitea_data:
jenkins_data:

networks:
ecosystem:
# docker compose up
33 changes: 33 additions & 0 deletions git/commit/smart-commits.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,39 @@
Smart Commits
*************

* Log in to Jira Software as a user with administrative permissions.
* Go to Administration > Applications > DVCS accounts.
* Check (or clear) the Smart Commits option for a repository.
* https://support.atlassian.com/bitbucket-cloud/docs/enable-smart-commits/
* https://confluence.atlassian.com/fisheye/using-smart-commits-960155400.html

.. code-block:: sh
$ git commit -m "MYPROJECT-13 #comment zrobione #time 20m #done"
.. code-block:: text
:caption: Jira
MYPROJECT-13 #comment corrected indent issue
MYPROJECT-13 #time 1w 2d 4h 30m Total work logged
MYPROJECT-13 #time 360m Total work logged
MYPROJECT-13 #close Fixed this today
MYPROJECT-13 #start-progress Fixed this today
MYPROJECT-13 #start-review Fixed this today
MYPROJECT-13 #time 2d 5h #comment Task completed ahead of schedule #resolve
MYPROJECT-13 #comment Imagine that this is a really, and I mean really, long comment #time 2d 5h
MYPROJECT-13 MYPROJECT-69 MYPROJECT-128 #resolve
MYPROJECT-13 MYPROJECT-69 MYPROJECT-128 #resolve #time 2d 5h #comment Task completed ahead of schedule
.. code-block:: text
:caption: Crucible
Fix a bug +review CR-MYPROJECT
Fix a bug +review CR-MYPROJECT @mwatney @jtwardowski
Implement rework on past work +review CR-MYPROJECT-128
.. todo:: Smart commits images


Log Work
========
Expand Down
54 changes: 37 additions & 17 deletions jira/end-user/automation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ Smart Commits
* https://support.atlassian.com/bitbucket-cloud/docs/enable-smart-commits/
* https://confluence.atlassian.com/fisheye/using-smart-commits-960155400.html

.. code-block:: sh
$ git commit -m "MYPROJECT-13 #comment zrobione #time 20m #done"
.. code-block:: text
:caption: Jira
Expand Down Expand Up @@ -173,37 +177,53 @@ GIT
#
# @author Matt Harasymczuk <matt@astrotech.io>
# @since 2012-10-23
# @updated 2020-11-15
# @updated 2022-07-17
#
# This simple hook gets Jira issue ID from the branch you are currently
# committing to. If you used Jira development panel "Create Branch",
# your branch name should be: "feature/MYPROJECT-69-some-issue-summary"
# and in such case it would get "MYPROJECT-69". Then hook prepends issue
# ID to your current commit message linking commit and Jira issue together.
# You'll never forget about adding issue id to the commit message anymore!
#
# To install hook just paste following script (with this comment) in:
# ``.git/hooks/prepare-commit-msg``
#
# This simple hook gets Jira issue ID from the branch you are currently committing to.
# If you used Jira development panel "Create Branch", your branch name should be:
# "feature/MYPROJECT-69-some-issue-summary" and in such case it would get "MYPROJECT-69".
# Then hook prepends issue ID to your current commit message linking commit and Jira issue together.
# You'll never forget about adding issue id to the commit message anymore! :}
# On *nix machines (macOS, Linux, etc) add executable rights:
# ``chmod +x .git/hooks/prepare-commit-msg``
#
# To install hook just put following script (with comment) in ".git/hooks/prepare-commit-msg"
# On *nix machines (macOS, Linux, etc) add executable rights: ``chmod +x .git/hooks/prepare-commit-msg``
# That's it. You can commit to test if it works. Remember before committing to check out branch
# with proper name, such as: "feature/MYPROJECT-69-some-issue-summary".
# That's it. You can commit to test if it works.
# Remember before committing to check out branch with proper name, such as:
# ``feature/MYPROJECT-69-my-issue-summary``
COMMIT_MSG_FILE=$1
COMMIT_SOURCE=$2
COMMIT_HASH=$3
PATTERN='[A-Z]{2,10}-[0-9]{1,6}'
issuekey=$(git symbolic-ref HEAD |egrep --only-matching '[A-Z]{2,10}-[0-9]{1,6}')
message=$(cat $1)
currentBranch=$(git branch --show-current)
issueKey=$(echo $currentBranch |egrep --only-matching $PATTERN)
commitMsgFile=$1
commitMsgOld=$(cat $commitMsgFile)
commitMsgNew="$issueKey $commitMsgOld"
if [ -z "$issuekey" ]; then
if [ -z "$issueKey" ]; then
echo "You are currently on a branch without JIRA issue ID in its name."
echo "Changes were not committed."
echo ""
echo "If you want to commit anyway, just remove executable rights for this hook:"
echo "chmod -x .git/hooks/prepare-commit-msg"
echo ""
echo "But remember to re-enable it later on, by executing:"
echo "chmod +x .git/hooks/prepare-commit-msg"
exit 1
else
echo "$issuekey $message" > $COMMIT_MSG_FILE
echo "Current Branch: $currentBranch"
echo "Jira Issue Key: $issueKey"
echo "Commit Msg Old: $commitMsgOld"
echo "Commit Msg New: $commitMsgNew"
echo ""
echo $commitMsgNew > $commitMsgFile
exit 0
fi
.. figure:: ../_img/devops-gitflow.png
Expand Down

0 comments on commit 9cd1f38

Please sign in to comment.