iuricode padroes-de-commits

repository·main·Indexed 27 days ago

https://github.com/iuricode/padroes-de-commits

Standards for semantic commits based on the Conventional Commits specification. Includes a commit-msg.sh shell script hook for automated validation, a guide for using emojis to categorize changes, and a reference of commit types such as feat, fix, docs, and refactor.

Tokens
1.9K
Snippets
3
Records
7
Agent score
44%

What's inside padroes-de-commits

  1. Commit message best practices and structure

    main

    To maintain a high-quality commit history, follow these recommendations:

    Structure

    • Subject Line: Keep the first line to a maximum of 4 words if possible. Use a consistent type.
    • Body: Use the commit body to provide precise descriptions of what is contained in the commit, the impact of the changes, and the reasons for the changes.
    • Footer: Use the footer for information about reviewers or task IDs (e.g., Reviewed-by: Name Refs #123).

    Content

    • Emojis: Use an emoji at the beginning of the message to visually represent the commit type.
    • Links: Use authentic links; avoid link shorteners or affiliate links.
    • Descriptions: Provide a succinct description of the change.
  2. Install the commit-msg.sh hook for Conventional Commits validation

    main

    Follow these steps to install the commit-msg.sh script as a Git hook to enforce Conventional Commits in your repository.

    1. Verify Git installation: Ensure Git is installed by running git --version.
    2. Locate the script: Ensure commit-msg.sh is available in your project directory.
    3. Prepare hooks directory: Create the .git/hooks directory if it doesn't exist:
      mkdir -p .git/hooks
    4. Install the hook: Copy the script to the hooks directory and rename it to commit-msg (removing the .sh extension):
      cp caminho/para/commit-msg.sh .git/hooks/commit-msg
    5. Grant execution permissions: Make the script executable:
      chmod +x .git/hooks/commit-msg
    6. Test the hook: Attempt a commit following the conventional pattern:
      git add .
      git commit -m "feat: adicionar funcionalidade xyz"

    If the message follows the pattern, the commit will succeed. Otherwise, the hook will block it.

    mkdir -p .git/hooks
    cp caminho/para/commit-msg.sh .git/hooks/commit-msg
    chmod +x .git/hooks/commit-msg
  3. Commit message examples with emojis

    main

    The project provides a pattern for using emojis in commit messages to improve readability in GitHub. The pattern follows the format: :emoji: type: description.

    Examples of mapping Git commands to GitHub results:

    • :tada: Commit inicial $\rightarrow$ 🎉 Commit inicial
    • :books: docs: Atualização do README $\rightarrow$ 📚 docs: Atualização do README
    • :bug: fix: Loop infinito na linha 50 $\rightarrow$ 🐛 fix: Loop infinito na linha 50
    • :sparkles: feat: Página de login $\rightarrow$ ✨ feat: Página de login
    • :bricks: ci: Modificação no Dockerfile $\rightarrow$ 🧱 ci: Modificação no Dockerfile
    • :recycle: refactor: Passando para arrow functions $\rightarrow$ ♻️ refactor: Passando para arrow functions
    • :zap: perf: Melhoria no tempo de resposta $\rightarrow$ ⚡ perf: Melhoria no tempo de resposta
    • :boom: fix: Revertendo mudanças ineficientes $\rightarrow$ 💥 fix: Revertendo mudanças ineficientes
    • :lipstick: feat: Estilização CSS do formulário $\rightarrow$ 💄 feat: Estilização CSS do formulário
    • :test_tube: test: Criando novo teste $\rightarrow$ 🧪 test: Criando novo teste
    • :bulb: docs: Comentários sobre a função LoremIpsum( ) $\rightarrow$ 💡 docs: Comentários sobre a função LoremIpsum( )
    • :card_file_box: raw: RAW Data do ano aaaa $\rightarrow$ 🗃️ raw: RAW Data do ano aaaa
    • :broom: cleanup: Eliminando blocos de código comentados... $\rightarrow$ 🧹 cleanup: Eliminando blocos de código comentados...
    • :wastebasket: remove: Removendo arquivos não utilizados... $\rightarrow$ 🗑️ remove: Removendo arquivos não utilizados...
    git commit -m ":sparkles: feat: Página de login"
  4. Conventional Commit types and descriptions

    main

    Use these semantic types to indicate the intention of your commit. These types align with the Conventional Commits specification:

    • feat: A new feature (correlates to MINOR versioning).
    • fix: A bug fix (correlates to PATCH versioning).
    • docs: Documentation changes only (e.g., README).
    • test: Changes to tests (adding, modifying, or deleting).
    • build: Changes to build files and dependencies.
    • perf: Code changes related to performance.
    • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc).
    • refactor: A code change that neither fixes a bug nor adds a feature.
    • chore: Updating build tasks, config files, or packages (e.g., adding to .gitignore).
    • ci: Changes to CI configuration files and scripts.
    • raw: Changes related to configuration files, data, features, or parameters.
    • cleanup: Removing commented code or unnecessary snippets to improve readability.
    • remove: Deleting obsolete files, directories, or features.
  5. Reference of commit emojis and keywords

    main

    Use the following mapping of emojis and keywords to standardize commit messages:

    TypeEmojiKeyword
    Accessibility:wheelchair:
    Adding a test:white_check_mark:test
    Update submodule version⬆️ :arrow_up:
    Revert submodule version⬇️ :arrow_down:
    Adding a dependency:heavy_plus_sign:build
    Code review changes👌 :ok_hand:style
    Animations and transitions💫 :dizzy:
    Bugfix🐛 :bug:fix
    Comments💡 :bulb:docs
    Initial commit🎉 :tada:init
    Configuration🔧 :wrench:chore
    Deploy🚀 :rocket:
    Documentation📚 :books:docs
    In progress🚧 :construction:
    UI Styling💄 :lipstick:feat
    Infrastructure🧱 :bricks:ci
    Task list (ideas)🔜 :soon:
    Move/Rename🚚 :truck:chore
    New feature:sparkles:feat
    Package.json (JS)📦 :package:build
    Performance:zap:perf
    Refactor♻️ :recycle:refactor
    Code Cleanup🧹 :broom:cleanup
    Removing a file🗑️ :wastebasket:remove
    Removing a dependency:heavy_minus_sign:build
    Responsiveness📱 :iphone:
    Reverting changes💥 :boom:fix
    Security🔒️ :lock:
    SEO🔍️ :mag:
    Version Tag🔖 :bookmark:
    Approval Test✔️ :heavy_check_mark:test
    Tests🧪 :test_tube:test
    Text📝 :pencil:
    Typing🏷️ :label:
    Error Handling🥅 :goal_net:
    Data🗃️ :card_file_box:raw
  6. Common Git commands reference

    main

    A reference of essential Git commands for repository management, including cloning, initializing, staging, committing, branching, and remote synchronization.

    git clone url-do-repositorio-no-github
    git init
    git add .
    git commit -m "mensagem do commit"
    git branch -M main
    git remote add origin https://github.com/usuario/nome-do-repositorio.git
    git push -u origin main
    git fetch
    git pull origin main
    git push --force-with-lease
    git revert id_do_commit_que_vai_ser_revertido
    git reset --hard id_do_commit_anterior_ao_que_vai_ser_apagado
    git commit --amend -m "mensagem_reescrita"
    git cherry-pick HASH_DO_COMMIT
    git switch <branch>
  7. Git terminology glossary

    main

    Definitions of common Git and GitHub concepts:

    • fork: A copy of a repository to your own GitHub account, allowing independent changes.
    • issues: A tool for managing tasks, feature requests, and bug reports.
    • pull request: A mechanism to submit proposed changes to an original repository for review.
    • gist: A tool for sharing code snippets without creating a full repository.