Skip to content

chore(husky): add pre-push githook for branch naming convention#87

Merged
froggy1014 merged 2 commits intomainfrom
chore/branch-convention-pre-push
Jan 9, 2025
Merged

chore(husky): add pre-push githook for branch naming convention#87
froggy1014 merged 2 commits intomainfrom
chore/branch-convention-pre-push

Conversation

@froggy1014
Copy link
Copy Markdown
Contributor

@froggy1014 froggy1014 commented Jan 9, 2025

Changes

아래 이슈에 기반해서 pre-push 깃훅을 추가해봤습니다.

# Get the current branch name
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
BRANCH_REGEX='^(feat|fix|hotfix|chore|refactor|release|test|docs|ci|build)\/[a-z0-9-]+$'

# Check if the branch name matches the defined regex
if ! [[ $BRANCH_NAME =~ $BRANCH_REGEX ]]; then
   echo "Error: Invalid branch name format."
   echo 
   echo "Please rename your branch using:"
   echo "git branch -m <CATEGORY>/<SUBJECT> or git branch -m <CATEGORY>/<ISSUENUMBER>-<SUBJECT>"
   echo 
   echo "CATEGORY: feat, fix, hotfix, chore, refactor, release, test, docs, ci, build"
   echo
   exit 1
fi

exit 0

Visuals

image

Checklist

  • Have you written the functional specifications?
  • Have you written the test code?

Additional Discussion Points

Summary by CodeRabbit

  • Chores
    • Git 브랜치 이름 규칙을 검증하는 pre-push 후크 스크립트를 추가했습니다.
    • 브랜치 이름이 지정된 형식(feature, fix, hotfix 등)을 따르지 않으면 푸시가 차단됩니다.

@froggy1014 froggy1014 added the documentation Improvements or additions to documentation label Jan 9, 2025
@froggy1014 froggy1014 self-assigned this Jan 9, 2025
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jan 9, 2025

⚠️ No Changeset found

Latest commit: 68e34c6

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets
Name Type
@sipe-team/input Patch
@sipe-team/badge Patch
@sipe-team/card Patch
@sipe-team/divider Patch
@sipe-team/radio-group Patch
@sipe-team/side Patch
@sipe-team/skeleton Patch
@sipe-team/switch Patch
@sipe-team/tooltip Patch
@sipe-team/typography Patch

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jan 9, 2025

변경 사항 분석

Walkthrough

이 변경 사항은 .husky/pre-push 파일에 새로운 Git 브랜치 이름 규칙 유효성 검사 스크립트를 도입합니다. 스크립트는 현재 브랜치 이름을 가져와 사전 정의된 정규 표현식과 비교합니다. feature, fix, hotfix 등 특정 카테고리와 설명적인 주제를 허용하며, 규칙에 맞지 않는 경우 오류 메시지를 출력하고 푸시를 차단합니다.

Changes

파일 변경 요약
.husky/pre-push Git 브랜치 이름 규칙 유효성 검사 스크립트 추가

Possibly related PRs

Suggested reviewers

  • noahluftyang
  • bae-sh
  • heeji289
  • synuns
  • hy57in
  • kimdaeyeobbb
  • developerjhp

Poem

🐰 브랜치 이름의 토끼 춤 🌿
규칙을 따라 깡총깡총
코드의 숲을 질주하네
깔끔하고 명확한 이름으로
Git의 여정을 노래하네!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 68e34c6 and cdc3262.

📒 Files selected for processing (1)
  • .husky/pre-push (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .husky/pre-push

Finishing Touches

  • 📝 Generate Docstrings

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@froggy1014 froggy1014 linked an issue Jan 9, 2025 that may be closed by this pull request
@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (3)
.husky/pre-push (3)

1-2: 분리된 HEAD 상태 처리 필요

현재 구현은 일반적인 브랜치에서는 잘 작동하지만, 분리된 HEAD 상태를 처리하지 않습니다.

다음과 같이 수정하는 것을 추천드립니다:

-BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
+BRANCH_NAME=$(git symbolic-ref -q --short HEAD || echo "HEAD")
+if [ "$BRANCH_NAME" = "HEAD" ]; then
+    echo "현재 분리된 HEAD 상태입니다. 브랜치에서 작업해주세요."
+    exit 1
+fi

7-14: 에러 메시지 개선 필요

현재 에러 메시지는 기본적인 정보만 제공합니다. 구체적인 예시를 추가하면 사용자가 더 쉽게 이해할 수 있을 것 같습니다.

다음과 같이 수정하는 것을 추천드립니다:

-   echo "Error: Invalid branch name format."
+   echo "오류: 올바르지 않은 브랜치 이름 형식입니다."
    echo 
    echo "Please rename your branch using:"
    echo "git branch -m <CATEGORY>/<SUBJECT> or git branch -m <CATEGORY>/<ISSUENUMBER>-<SUBJECT>"
    echo 
    echo "CATEGORY: feat, fix, hotfix, chore, refactor, release, test, docs, ci, build"
+   echo
+   echo "예시:"
+   echo "- feat/user-login"
+   echo "- fix/87-memory-leak"
+   echo "- chore/update-dependencies"
    echo

17-17: 성공 메시지 추가 권장

현재는 성공 시 아무런 메시지 없이 종료됩니다. 사용자에게 브랜치 이름이 유효하다는 피드백을 제공하면 좋을 것 같습니다.

다음과 같이 수정하는 것을 추천드립니다:

+echo "✅ 브랜치 이름이 규칙에 맞습니다: $BRANCH_NAME"
 exit 0
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 768bb2e and 68e34c6.

📒 Files selected for processing (1)
  • .husky/pre-push (1 hunks)

Comment thread .husky/pre-push Outdated
Copy link
Copy Markdown
Member

@synuns synuns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이제 브랜치 컨벤션까지!!
완성도가 점점 높아지는 기분이 듭니다~~

Comment thread .husky/pre-push Outdated
Copy link
Copy Markdown
Member

@synuns synuns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good!!

Copy link
Copy Markdown
Contributor

@SEMIN-97 SEMIN-97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

�매우 좋습니다👍

@froggy1014 froggy1014 merged commit 71fcc50 into main Jan 9, 2025
@froggy1014 froggy1014 deleted the chore/branch-convention-pre-push branch January 9, 2025 13:38
@coderabbitai coderabbitai Bot mentioned this pull request Jan 11, 2025
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Branch Convention

3 participants