Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 96 additions & 0 deletions .claude/commands/find-first-release.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# Find First Release

Find the first release (git tag) that contains a given issue, pull request, or commit.

## Usage

```
/find-first-release <issue|pr|commit>
```

## Parameters

- `issue`: Issue number (e.g., `21`, `#21`, or full URL)
- `pr`: Pull request number or URL
- `commit`: Commit SHA (short or long form)

## Examples

```
/find-first-release 21
/find-first-release #19
/find-first-release https://github.com/dotCMS/ai-workflows/issues/18
/find-first-release https://github.com/dotCMS/ai-workflows/pull/17
/find-first-release 9e1db62
/find-first-release 9e1db62a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e
```

## Implementation

Find the first release (git tag) that contains the specified issue, pull request, or commit: $ARGUMENTS.

**Logic:**

1. **Parse Input**: Determine if the input is an issue number, PR URL/number, or commit SHA
2. **Get Commit SHA**:
- **For Issues**: Use `gh issue view <number> --json closedAt,timelineItems` to find linked PRs, then get merge commit
- **For PRs**: Use `gh pr view <number> --json mergeCommit` to get the merge commit SHA
- **For Commits**: Use the SHA directly
3. **Find First Tag**: Use `git tag --contains <commit> | sort -V | head -1` to find the first release
4. **Handle Edge Cases**:
- Commit not found: "Commit SHA not found in repository"
- No tags found: "This commit is not part of any release yet (possibly in an unreleased branch)"
- Issue/PR not merged: "Issue/PR is not merged yet or has no associated commits"

**Output Format:**

```
πŸ” Finding first release for: <input>
πŸ“ Commit SHA: <sha>
🏷️ First Release: <tag> (released on <date>)

πŸ“Š Release Details:
- Tag: <tag>
- Date: <release-date>
- Commits: <number> commits since previous release
- View release: https://github.com/<owner>/<repo>/releases/tag/<tag>
```

**Error Handling:**

- If input cannot be parsed: "Invalid input format. Expected issue number, PR URL, or commit SHA"
- If commit is not in any release: "Commit <sha> is not included in any release yet"
- If API calls fail: Provide helpful error messages with suggestions

**Key Commands:**

```bash
# Get merge commit from PR
gh pr view <number> --json mergeCommit --jq '.mergeCommit.oid'

# Get linked PRs from issue
gh issue view <number> --json timelineItems --jq '.timelineItems[] | select(.source.pullRequest) | .source.pullRequest.number'

# Find first tag containing commit
git tag --contains <commit> | sort -V | head -1

# Get tag creation date
git log -1 --format=%ai <tag>

# Count commits between tags
git rev-list <previous-tag>..<tag> --count
```

**Repository Detection:**

- Auto-detect current repository using `gh repo view --json nameWithOwner`
- Support cross-repository queries if full URLs are provided
- Default to current repository for issue/PR numbers

**Smart Features:**

- βœ… Support multiple input formats (issue numbers, URLs, commit SHAs)
- βœ… Handle both short and long commit SHAs
- βœ… Provide rich context (release date, commit count, release URL)
- βœ… Clear error messages for edge cases
- βœ… Works without full git clone (uses `gh` API when possible)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these adding value or just artifacts of the ai generated find-first-release.md file?

11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ All notable changes to the Deployment Guard workflow will be documented in this
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### ✨ Added

- **New `/find-first-release` Command**: Find the first release (git tag) containing an issue, PR, or commit (#21)
- Supports multiple input formats: issue numbers, PR URLs, and commit SHAs
- Auto-detects input type and retrieves commit information via GitHub CLI
- Uses `git tag --contains` to find the first release containing the commit
- Provides rich output with release date, commit count, and release URL
- Handles edge cases: unreleased commits, unmerged PRs, and invalid input

Comment thread
mbiuki marked this conversation as resolved.
Outdated
## [1.1.2] - 2025-12-16

### πŸ› Critical Bug Fixes
Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ This repository serves as the **central hub for all Claude AI tooling and integr
Custom slash commands for enhanced productivity:

- **`/weekly-work`** - Generate team work summaries from merged PRs within date ranges
- **`/find-first-release`** - Find the first release (git tag) containing an issue, PR, or commit
- Located in `.claude/commands/` for easy sharing across repositories

### Development Guidelines
Expand Down Expand Up @@ -172,6 +173,12 @@ Copy commands from `.claude/commands/` to your repository's `.claude/commands/`
2. Use in Claude Code: `/weekly-work falcon 2025-01-20 2025-01-26`
3. Get a consolidated summary of merged PRs grouped by feature/topic

**Example: Find First Release**

1. Copy `.claude/commands/find-first-release.md` to your repo
2. Use in Claude Code: `/find-first-release 21` (or PR URL, or commit SHA)
3. Discover which release first included a specific change

### Sharing Cursor Rules

The `.cursor/rules/` directory contains modular development guidelines:
Expand Down Expand Up @@ -336,7 +343,8 @@ ai-workflows/
β”‚ └── tests.yml # Automated workflow testing
β”œβ”€β”€ .claude/
β”‚ β”œβ”€β”€ commands/ # Custom slash commands
β”‚ β”‚ └── weekly-work.md # Team work summary generator
β”‚ β”‚ β”œβ”€β”€ weekly-work.md # Team work summary generator
β”‚ β”‚ └── find-first-release.md # Find first release for issue/PR/commit
β”‚ └── settings.local.json # Claude Code settings
β”œβ”€β”€ .cursor/rules/ # Development best practices
β”‚ β”œβ”€β”€ terminal-commands.md # Safe command patterns
Expand Down