blog

Git コミットメッセージの書式

変更履歴には、新機能、バグ修正、後方互換性のない変更の 3 つのセクションを使用します。 リリース時に、これら3つのセクションの内容をスクリプトで生成し、関連するコミットにリンクすることができます。 ...

Oct 3, 2020 · 6 min. read
シェア

目的

  1. CHANGELOG を自動生成できます;
  2. git bisect が生成するコミットメッセージは無視してもかまいません。
  3. 提出履歴をより分かりやすく表示するようにしました;

変更履歴の作成

変更履歴には、新機能バグ修正後方互換性のない変更の3つのセクションを使用してください。

バージョンをリリースする際には、これらの3つのセクションの内容を、関連するコミットへのリンクを含むスクリプトで生成することができます。

もちろん、スクリプトが生成したスケルトンを元に、実際のリリースでCHANGELOGの内容を手動で編集することも可能です。

リリース以降に投稿されたすべてのトピックのリストをご覧ください:

git log <last tag> HEAD --pretty=format:%s

現在のバージョンの新機能をご覧ください:

git log <last release> HEAD --grep feature

重要でない提出物の特定

一緒にいるときは無視してかまいません:

git bisect skip $(git rev-list --grep irrelevant <good place> HEAD)

投稿履歴をより分かりやすく表示

これにより、「コンテキスト」情報が追加されます。

以下のコミットメッセージの例を見てください:

  • Fix small typo in docs widget
  • Fix test for scenario.Application - should remove old iframe
  • docs - various doc fixes
  • docs - stripping extra new lines
  • Replaced double line break with single when text is fetched from Google
  • Added support for properties in documentation

上記のメッセージはすべて変更の範囲を指定しようとするものですが、どのような規約にも従っていません。

次のメッセージを見てください:

  • fix comment stripping
  • fixing broken links
  • Bit of refactoring
  • Check whether links do exist and throw exception

これらのメッセージが何を示しているか理解できますか?変更の範囲を示すものではありません。

もちろん、どのファイルが変更されたかを調べることでこのメッセージを見つけることは可能ですが、非常に非効率的です。git の履歴を見ると、どちらもメッセージで変更範囲を指定しようとしていますが、規約を見逃しているだけです。

コミットメッセージの書式

コミットメッセージは、一行で 100 文字を超えてはいけません!これにより、github やさまざまな git ツールでメッセージを読みやすくなります。

送信メッセージは、ヘッダー本文フッターで構成され、空行で区切られています。

メッセージのヘッダ

コミットメッセージの最初の行はヘッダと呼ばれ、タイプ、スコープ(オプション)、変更の簡潔な説明が含まれます。

タイプフィールドを使用して、この変更の主なタイプを記述します。

  • 見事
  • feat
  • fix
  • docs
  • style
  • refactor
  • test

より適切な範囲がない場合は、*を使用できます。

<subject>

この投稿の簡潔な説明

  • 現在形を使ったコマンド:"change" は "changed" でも "changes" でもありません。
  • 最初の文字を大文字にしないでください。
  • 最後に意味はありません。

メッセージ本文

  • 末尾にドットをつけない.

git-commit-a-note-about-git-commit-messages

メッセージのフッター

重要な変更

すべての後方互換性のない変更は、フッターに別の領域として記述されなければなりません。投稿メッセージの残りの部分は、変更の説明、整列、移行の注意事項です。

BREAKING CHANGE: isolate scope bindings definition has changed and
 the inject option for the directive controller injection was removed.
 To migrate the code follow the example below:
 Before: 
 scope: {
 myAttr: 'attribute',
 myBind: 'bind',
 myExpression: 'expression',
 myEval: 'evaluate',
 myAccessor: 'accessor'
 }
 After:
 scope: {
 myAttr: '@',
 myBind: '@',
 myExpression: '&',
 // myEval - usually not useful, but in cases where the expression is assignable, you can use '='
 myAccessor: '=' // in directive's template change myAccessor() to myAccessor
 }
 The removed `inject` wasn't generaly useful for directives so there should be no code using it.

参照に関する問題

バグクラスをクローズしたコミットには、クローズしたバグ番号を別に記載し、"Closes" で始まるようにします。

Closes #234

複数のバグがある場合

Closes #123, #245, #992

feat($browser): onUrlChange event (popstate/hashchange/polling)
Added new event to $browser:
- forward popstate event if available
- forward hashchange event if popstate not available
- do polling when neither popstate nor hashchange available
Breaks $browser.onHashChange, which was removed (use onUrlChange instead)
fix($compile): couple of unit tests for IE9
Older IEs serialize html uppercased, but IE9 does not...
Would be better to expect case insensitive, unfortunately jasmine does
not allow to user regexps for throw expectations.
Closes #392
Breaks foo.bar api, foo.baz should be used instead
feat(directive): ng:disabled, ng:checked, ng:multiple, ng:readonly, ng:selected
New directives for proper binding these attributes in older browsers (IE).
Added coresponding description, live examples and e2e tests.
Closes #351
style($location): add couple of missing semi colons
docs(guide): updated fixed docs from Google Docs
Couple of typos fixed:
- indentation
- batchLogbatchLog -> batchLog
- start periodic checking
- missing brace
feat($compile): simplify isolate scope bindings
Changed the isolate scope binding options to:
 - @attr - attribute binding (including interpolation)
 - =model - by-directional model binding
 - &expr - expression execution binding
This change simplifies the terminology as well as
number of choices available to the developer. It
also supports local name aliasing from the parent.
BREAKING CHANGE: isolate scope bindings definition has changed and
the inject option for the directive controller injection was removed.
To migrate the code follow the example below:
Before:
scope: {
 myAttr: 'attribute',
 myBind: 'bind',
 myExpression: 'expression',
 myEval: 'evaluate',
 myAccessor: 'accessor'
}
After:
scope: {
 myAttr: '@',
 myBind: '@',
 myExpression: '&',
 // myEval - usually not useful, but in cases where the expression is assignable, you can use '='
 myAccessor: '=' // in directive's template change myAccessor() to myAccessor
}
The removed `inject` wasn't generaly useful for directives so there should be no code using it.
Read next

リートコード5.最長の回文部分文字列 注釈

ブーリアン2次元配列を作成し、横軸は部分文字列の終了インデックス、縦軸は開始インデックスであり、配列内の各ポイントは、この部分文字列の値が等しいかどうかをマークし、等しいは真です。 javaの文字列要素は0から始まり、部分文字列は、ath文字を含むath文字からインターセプトされます。ath文字...

Oct 3, 2020 · 2 min read