![[Git] Commit Message Conventions](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FbshANS%2FbtsKBcgKk8j%2Fe5lOM6kl00fo7fcWcxbtj1%2Fimg.png)
참조링크 - https://gist.github.com/stephenparish/9941e89d80e2bc58a153
한국어 정리링크 - https://www.conventionalcommits.org/ko/v1.0.0/
커밋 포맷 자동화 적용방법 링크 - https://medium.com/tunaiku-tech/automate-javascript-project-versioning-with-commitizen-and-standard-version-6a967afae7
starndard-version 공식문서 - https://github.com/conventional-changelog/standard-version?tab=readme-ov-file
이 글은 AngularJS에서 사용되는 커밋 컨벤션이다.
목표
- 코드 변경 이력을 기반으로 자동으로 CHANGELOG.md파일생성하기
- 실제 기능과 관련되지 않은 커밋들은 git bisect를 사용하여 무시할 수 있다.
- git 히스토리를 탐색할 때 좋은 퀄리티의 정보를 제공하자
CHANGELOG.md 생성하기
CHANGELOG.md
는 진행하는 프로젝트에서 버전별 변경 사항을 기록한 문서로서 릴리스시마다 사용자나 팀원이 쉽게 변경 내역을 이용할 수 있도록 신규기능추가, 버그 수정과 같은 중요한 변경 사항들을 정리합니다.
이 글에서는 CHANGELOG.md를 자동으로 생성하는 방법과 이를 돕기위한 스크립트 사용 방법을 설명합니다. 스크립트는 커밋로그를 기반으로 기본적인 뼈대를 자동으로 생성하며 릴리스 전에 수동으로 수정하여 최종 릴리스 노트를 작성할 수 있습니다.
git log <last tag> HEAD --pretty=format:%s
이 명령어는 마지막 릴리스 이후의 모든 커밋 메시지의 첫줄을 출력합니다.
이를 통해 모든 변경 사항의 기본적인 리스트업을 불러올 수 있습니다.
git log <last release> HEAD --grep feature
이 명령어는 마지막 릴리스 이후 추가된 신규 기능을 추출하는 명령입니다.
--grep feature옵션을 사용해 커밋메시지에 feature가 포함된 커밋을 필터링하여 리스트업 할 수 있습니다.
중요하지않은 커밋 식별하기
프로젝트를 개발하면서 커밋을 하는과정속에서 오타수정, 문서수정, 주석제거와 같이 실제 기능에 영향을 끼치지 않는 커밋들이 있게됩니다. 이러한 커밋들은 Git bisect를 사용함으로써 의미없는 커밋들을 무시할 수 있습니다.
git bisect skip $(git rev-list --grep irrelevant <good place> HEAD)
이 명령어를 사용하면 중요하지 않은 커밋을 건너뛸 수 있습니다.
--grep irrelevant 옵션을 사용하면 "irrelevant" 키워드가 포함된 커밋메시지들을 무시합니다.
git history를 통해 더 많은 정보를 제공하기
커밋메시지가 명확하지 않으면 나중에 히스토리를 탐색할 때 불편을 겪게 됩니다.
코드의 어느부분에서 변경이 이루어졌는지 명확히 하지 않으면 커밋을 확인할 때 일일이 파일을 확인해야하는 불편함을 마주하게 됩니다. 이를 예방하기위해 커밋 메시지에 변경된 코드의 위치를 포함시키는 것이 좋습니다.
아래의 예시를 살펴보겠습니다
- Fix small typo in docs widget (tutorial instructions)
- 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
- Fix sitemap include (to work on case sensitive linux)
위 메시지들은 컨벤션이 없기때문에 가독성이 떨어진다는 것을 알 수 있습니다.
이 전의 예시처럼 docs-abcdabc, fix-abcabc의 형태로 메시지를 작성해주면 좋을 것입니다.
정리하자면
- 커밋 메시지 컨벤션을 정해서 메시지의 가독성을 높여야한다.
- 코드의 변경된 내용을 명시함으로써 커밋메시지를 명확히한다.
- Fix, Ref, Feat등등..
커밋메시지 작성 포맷
<type>(<scope>): <subject>
<BLANK LINE>
<body>
<BLANK LINE>
<footer>
커밋 메시지는 위와 같은 형태로 작성되거나 팀만의 별도의 커밋메시지 작성 포맷을 만들고 지켜야합니다.
되도록이면 커밋메시지를 100자 내로하여 메시지의 가독성을 높여야합니다.
포맷의 의미 분석해보기
Subject line
type
: 커밋의 유형을 기재.
- feat: 기능 추가
- fix: 버그 수정
- docs: 문서 수정
- style: 코드 형식 수정(세미콜론 누락 등)
- refactor: 리팩터링
- test: 테스트 추가
- chore: 유지보수 관련 작업
scope
: 코드의 어느부분에서 변경이 이루어졌는지 명시합니다.
- $location
- $complie
- $ngClick
subject
: 변경사항에 대한 간결한 설명을 기재
- 명령형 현재 시제를 사용
- 첫 글자를 대문자로 쓰지 않는다.
- 마침표를 사용하지 않는다.
Message body
changed나 changes가 아닌 change와 같이 명령형 현재 시제를 사용.
변경하게 된 이유와 이전 동작과의 차이점을 작성합니다.
참고링크
• Writing Git Commit Messages
• A Note About Git Commit Messages
Message footer
- 호환성 깨짐(breaking changes)처럼 중요한 변경 사항을 꼬리말에 명시합니다. 이런 변경은 기존 기능을 사용하는 코드에 영향을 미칠 수 있기때문에 마이그레이션 가이드와 같은 설명이 필요합니다.
- 이슈 트래킹 번호를 명시해 해당 커밋이 어떤 이슈와 연결되어 있는지 참조합니다. 이는 팀에서 이슈관리와 커밋 추적에 매우 유용합니다.
호환성 깨짐 명시 예제
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 generally useful for directives so there should be no code using it.
이슈 트래킹 명시 예제
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.
'Git' 카테고리의 다른 글
[Git] gitignore와 관리해야할 파일 (1) | 2024.11.08 |
---|---|
[Git] push된 커밋을 되돌리고 Commit단위를 쪼개고 메시지 다시 작성하기 (1) | 2024.10.24 |
포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!