commit

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Sentry Commit Messages

Sentry 提交信息规范

Follow these conventions when creating commits for Sentry projects.
在为Sentry项目创建提交时,请遵循以下规范。

When to Use This Skill

何时使用此技能

Use this skill when:
  • Committing code changes
  • Writing commit messages
  • Formatting git history
  • Following Sentry commit conventions
  • Referencing Sentry issues in commits
在以下场景使用此技能:
  • 提交代码变更
  • 编写提交信息
  • 格式化Git历史记录
  • 遵循Sentry提交规范
  • 在提交信息中引用Sentry问题

Prerequisites

前置条件

Before committing, ensure you're working on a feature branch, not the main branch.
bash
undefined
提交前,请确保你在功能分支上工作,而非主分支。
bash
undefined

Check current branch

查看当前分支

git branch --show-current

If you're on `main` or `master`, create a new branch first:

```bash
git branch --show-current

如果当前在`main`或`master`分支,请先创建新分支:

```bash

Create and switch to a new branch

创建并切换到新分支

git checkout -b <type>/<short-description>

Branch naming should follow the pattern: `<type>/<short-description>` where type matches the commit type (e.g., `feat/add-user-auth`, `fix/null-pointer-error`, `ref/extract-validation`).
git checkout -b <type>/<short-description>

分支命名应遵循`<type>/<short-description>`的格式,其中type需与提交类型匹配(例如:`feat/add-user-auth`、`fix/null-pointer-error`、`ref/extract-validation`)。

Format

格式

<type>(<scope>): <subject>

<body>

<footer>
The header is required. Scope is optional. All lines must stay under 100 characters.
<type>(<scope>): <subject>

<body>

<footer>
标题为必填项。范围为可选项。所有行长度不得超过100字符。

Commit Types

提交类型

TypePurpose
feat
New feature
fix
Bug fix
ref
Refactoring (no behavior change)
perf
Performance improvement
docs
Documentation only
test
Test additions or corrections
build
Build system or dependencies
ci
CI configuration
chore
Maintenance tasks
style
Code formatting (no logic change)
meta
Repository metadata
license
License changes
类型用途
feat
新增功能
fix
修复Bug
ref
代码重构(无行为变更)
perf
性能优化
docs
仅更新文档
test
添加或修正测试用例
build
构建系统或依赖变更
ci
CI配置变更
chore
维护任务
style
代码格式化(无逻辑变更)
meta
仓库元数据变更
license
许可证变更

Subject Line Rules

标题行规则

  • Use imperative, present tense: "Add feature" not "Added feature"
  • Capitalize the first letter
  • No period at the end
  • Maximum 70 characters
  • 使用祈使语气、现在时态:例如用“Add feature”而非“Added feature”
  • 首字母大写
  • 结尾不加句号
  • 最长不超过70字符

Body Guidelines

正文指南

  • Explain what and why, not how
  • Use imperative mood and present tense
  • Include motivation for the change
  • Contrast with previous behavior when relevant
  • 解释做了什么为什么这么做,无需说明实现方式
  • 使用祈使语气和现在时态
  • 包含变更的动机
  • 必要时对比之前的行为

Footer: Issue References

页脚:问题引用

Reference issues in the footer using these patterns:
Fixes GH-1234
Fixes #1234
Fixes SENTRY-1234
Refs LINEAR-ABC-123
  • Fixes
    closes the issue when merged
  • Refs
    links without closing
在页脚中使用以下格式引用问题:
Fixes GH-1234
Fixes #1234
Fixes SENTRY-1234
Refs LINEAR-ABC-123
  • Fixes
    表示合并后将关闭该问题
  • Refs
    仅关联问题,不会自动关闭

AI-Generated Changes

AI生成的变更

When changes were primarily generated by a coding agent (like Claude Code), include the Co-Authored-By attribution in the commit footer:
Co-Authored-By: Claude <noreply@anthropic.com>
This is the only indicator of AI involvement that should appear in commits. Do not add phrases like "Generated by AI", "Written with Claude", or similar markers in the subject, body, or anywhere else in the commit message.
当变更主要由编码Agent(如Claude Code)生成时,请在提交页脚中添加Co-Authored-By署名:
Co-Authored-By: Claude <noreply@anthropic.com>
这是提交信息中唯一可体现AI参与的标识。请勿在标题、正文或提交信息的其他位置添加“Generated by AI”、“Written with Claude”等类似表述。

Examples

示例

Simple fix

简单修复

fix(api): Handle null response in user endpoint

The user API could return null for deleted accounts, causing a crash
in the dashboard. Add null check before accessing user properties.

Fixes SENTRY-5678
Co-Authored-By: Claude <noreply@anthropic.com>
fix(api): Handle null response in user endpoint

The user API could return null for deleted accounts, causing a crash
in the dashboard. Add null check before accessing user properties.

Fixes SENTRY-5678
Co-Authored-By: Claude <noreply@anthropic.com>

Feature with scope

带范围的功能

feat(alerts): Add Slack thread replies for alert updates

When an alert is updated or resolved, post a reply to the original
Slack thread instead of creating a new message. This keeps related
notifications grouped together.

Refs GH-1234
feat(alerts): Add Slack thread replies for alert updates

When an alert is updated or resolved, post a reply to the original
Slack thread instead of creating a new message. This keeps related
notifications grouped together.

Refs GH-1234

Refactor

代码重构

ref: Extract common validation logic to shared module

Move duplicate validation code from three endpoints into a shared
validator class. No behavior change.
ref: Extract common validation logic to shared module

Move duplicate validation code from three endpoints into a shared
validator class. No behavior change.

Breaking change

破坏性变更

feat(api)!: Remove deprecated v1 endpoints

Remove all v1 API endpoints that were deprecated in version 23.1.
Clients should migrate to v2 endpoints.

BREAKING CHANGE: v1 endpoints no longer available
Fixes SENTRY-9999
feat(api)!: Remove deprecated v1 endpoints

Remove all v1 API endpoints that were deprecated in version 23.1.
Clients should migrate to v2 endpoints.

BREAKING CHANGE: v1 endpoints no longer available
Fixes SENTRY-9999

Revert Format

回滚格式

revert: feat(api): Add new endpoint

This reverts commit abc123def456.

Reason: Caused performance regression in production.
revert: feat(api): Add new endpoint

This reverts commit abc123def456.

Reason: Caused performance regression in production.

Principles

原则

  • Each commit should be a single, stable change
  • Commits should be independently reviewable
  • The repository should be in a working state after each commit
  • 每个提交应对应单一、稳定的变更
  • 提交应可独立评审
  • 每个提交完成后,仓库应处于可正常工作的状态

References

参考资料