Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
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
90 changes: 90 additions & 0 deletions .claude/commands/find-first-release.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Find First Release

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

**Also Available as Gemini Gem:** For team members without Claude Code access, use the [Gemini Gem version](https://gemini.google.com/gem/1M7bkH8P-Inz6yRf1MRRuZEDK-_XPd0EL?usp=sharing).

## 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ 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]
## [1.1.2] - 2025-12-16

### πŸ› Critical Bug Fixes
Expand Down
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ 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
- Also available as [Gemini Gem](https://gemini.google.com/gem/1M7bkH8P-Inz6yRf1MRRuZEDK-_XPd0EL?usp=sharing) for broader team access
- Located in `.claude/commands/` for easy sharing across repositories

### Development Guidelines
Expand Down Expand Up @@ -172,6 +174,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. **Claude Code**: Copy `.claude/commands/find-first-release.md` to your repo, then use `/find-first-release 21` (or PR URL, or commit SHA)
2. **Gemini**: Use the [Gemini Gem](https://gemini.google.com/gem/1M7bkH8P-Inz6yRf1MRRuZEDK-_XPd0EL?usp=sharing) for team members without Claude Code access
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 +344,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
Loading