Skip to content

Add Git post-checkout hook documentation for automatic Jira status updates#4

Merged
alexec merged 2 commits intomainfrom
copilot/update-readme-with-script-explanation
Oct 21, 2025
Merged

Add Git post-checkout hook documentation for automatic Jira status updates#4
alexec merged 2 commits intomainfrom
copilot/update-readme-with-script-explanation

Conversation

Copy link
Contributor

Copilot AI commented Oct 21, 2025

This PR adds comprehensive documentation for a Git post-checkout hook that automatically updates Jira issue status when developers switch branches.

What's Added

A new Git Hook Integration section in the README that documents a bash script for automatically syncing Git branch changes with Jira. When a developer checks out a branch with a Jira issue key in the name (e.g., feature/PROJ-123-add-feature), the hook automatically updates that issue's status to "In Progress".

Key Features Documented

  • Automatic detection: Extracts Jira issue keys from branch names using the pattern [_A-Z0-9]+-[0-9]+
  • Self-installing: Downloads the jira CLI automatically if not present in ~/bin/jira
  • Platform-aware: Detects the correct binary for the user's OS and architecture
  • Zero-friction workflow: Developers just check out branches normally, and Jira stays in sync

Documentation Includes

  1. Clear explanation of what the hook does and why it's useful
  2. Step-by-step setup instructions
  3. The complete bash script ready to copy-paste
  4. Examples of supported branch naming conventions
  5. Notes about customizing for different Jira instances

This enhancement helps teams maintain better synchronization between their Git workflow and Jira project tracking without requiring manual updates.

Original prompt

Add this to the README, explain what it is

#!/bin/bash
set -euo pipefail

old_branch=$(git name-rev --name-only "$1")
new_branch=$(git branch --show-current)

if [ "$old_branch" = "$new_branch" ]; then
exit 0
fi

grep the branch name for a jira ticket pattern (e.g. ABC-123)

jira_issue_key=$(echo $new_branch | grep -oE '[_A-Z0-9]+-[0-9]+')

if [ ! -n "$jira_issue_key" ]; then
exit
fi

if [ ! -e ~/bin/jira ]; then
platform=$(uname -s | tr '[:upper:]' '[:lower:]')
arch=$(uname -m | sed 's/x86_64/amd64/' | sed 's/aarch64/arm64/')
curl -fsL -o ~/bin/jira https://github.com/kitproj/jira-cli/releases/download/v0.0.6/jira_v0.0.6_${platform}_${arch}
mkdir -p ~/bin
chmod +x ~/bin/jira
fi

~/bin/jira -h jira.intuit.com update-issue-status $jira_issue_key "In Progress"


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
Copilot AI changed the title [WIP] Add explanation for branch status update script in README Add Git post-checkout hook documentation for automatic Jira status updates Oct 21, 2025
Copilot AI requested a review from alexec October 21, 2025 21:03
@alexec alexec marked this pull request as ready for review October 21, 2025 21:20
@alexec alexec merged commit 2046246 into main Oct 21, 2025
2 checks passed
@alexec alexec deleted the copilot/update-readme-with-script-explanation branch October 21, 2025 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants