레이블이 tera인 게시물을 표시합니다. 모든 게시물 표시
레이블이 tera인 게시물을 표시합니다. 모든 게시물 표시

git-cliff and git commit template

# git-cliff 로 커스텀한 changelog 를 생성할 수 있다.
https://github.com/orhun/git-cliff
# 설치
brew install git-cliff

# 이제 git-cliff 또는 git cliff 명령을 사용할 수 있다.
# 설정파일(cliff.toml) 생성
git cliff --init

# cliff.toml 에서 사용하는 template 엔진 tera 사용방법
# https://www.conventionalcommits.org 포맷을 사용하지 않으면 다음 2개의 설정을 비활성화 해야 커밋 메시지 파싱을 할 수 있다.
vi cliff.toml
[git]
conventional_commits = false
filter_unconventional = false

# changelog 생성
# stdout 출력
git cliff

# CHANGELOG.md 파일로 출력
git cliff -o CHANGELOG.md

# 버전명시(v 로시작하는 것은 자동 cliff.toml에서 trim 처리)
# 버전명시 하지 않으면 [unreleased] 로 표시된다.
git cliff -o CHANGELOG.md -t v1.0.0

# 현재 태그에 대한 변경사항만 생성(새 태그 버전에서의 변경 사항만 파악할때 유용)
git cliff -o CHANGELOG.md --current

#####

# commit 메시지 템플릿 적용 및 체크
# 참고 ~/.git/hooks 에 각종 hook sample 파일이 있다.
# hook 파일들도 푸시해서 관리하기 위해서 별도 hookPath 를 설정
git config core.hooksPath .githooks

# commit_message_template.txt 내용으로 커밋 메시지 생성
# 템플릿 파일 설정
git config commit.template .githooks/commit_message_template.txt

# git commit 실행시 처리 순서
1. pre-commit 에서 커밋 파일 체크
설정 파일 참고 https://github.com/ysoftman/test_code/blob/master/.githooks/pre-commit

2. prepare-commit-msg 에서 커밋 메시지 처리할 내용
3. (vim 으로) 커밋 메시지 작성

4. commit-msg 에서 메시지 규칙 체크