Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CUSTOM KEY VALIDATION #3570

Open
epsilon11101 opened this issue May 18, 2024 · 0 comments
Open

CUSTOM KEY VALIDATION #3570

epsilon11101 opened this issue May 18, 2024 · 0 comments

Comments

@epsilon11101
Copy link

I've created a custom key, but it doesn't validate if there are staged changes. It executes even if there are no staged files. Any help would be appreciated.

Here's my custom command configuration:

gui:
  nerdFontsVersion: "3"
customCommands:
  - key: "<c-c>"
    context: "files"
    description: "Commit with Gitmoji 👽"

    prompts:
      - type: "menu"
        title: "Choose a Gitmoji"
        key: "Gitmoji"
        suggestions:
          preset: "branches"

        options:
          - name: "✨ feat"
            value: ""
          - name: "🐛 fix"
            value: "🐛"
          - name: "📝 docs"
            value: "📝"
          - name: "💄 style"
            value: "💄"
          - name: "♻️ refactor"
            value: "♻️"
          - name: "⚡ perf"
            value: ""
          - name: "✅ test"
            value: ""
          - name: "🔨 build"
            value: "🔨"
          - name: "💚 ci"
            value: "💚"
          - name: "🔧 chore"
            value: "🔧"
          - name: "⏪ revert"
            value: ""
          - name: "🚧 wip"
            value: "🚧"
          - name: "🔀 merge"
            value: "🔀"
          - name: "⬆️ dependencies"
            value: "⬆️"
          - name: "⬇️ compatibility"
            value: "⬇️"
          - name: "👕 lint"
            value: "👕"
          - name: "🔒 security"
            value: "🔒"
          - name: "♿ accessibility"
            value: ""
          - name: "🌐 i18n"
            value: "🌐"
          - name: "🏷️ release"
            value: "🏷️"
          - name: "🎉 init"
            value: "🎉"
          - name: "➕ dep-add"
            value: ""
          - name: "➖ dep-remove"
            value: ""
          - name: "📈 analytics"
            value: "📈"
          - name: "📱 responsive"
            value: "📱"
          - name: "🎨 ux/ui"
            value: "🎨"
          - name: "🔍 seo"
            value: "🔍"
          - name: "💀 dead code"
            value: "💀"

      - type: "input"
        title: "Enter the commit title"
        key: "CommitSummary"
        initialValue: ""
      - type: "input"
        title: "Enter the commit description"
        key: "CommitDescription"
        initialValue: ""
    checkForConflicts: true
    command: |
      staged_files=$(git diff --cached --name-only)
      if [ -z "$staged_files" ]; then
        echo "No files staged for commit. Please stage your changes first."
        exit 1
      else
        git commit -m '{{.Form.Gitmoji}} {{.Form.CommitSummary}}' -m '{{.Form.CommitDescription}}'
      fi
    loadingText: "Committing..."
´´´
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant