Skip to content

Sort changed files before building the AI commit message prompt #14485

Description

@gk-bbai

Description

When generating an AI commit message, changed files are added to the prompt in a non-deterministic order. Regenerating on an unchanged working tree produces a different file order each time.

Steps to reproduce

  1. Configure Ollama as the AI provider.
  2. Have a multi-file change in the working tree.
  3. Click Generate message several times without changing anything.

Result

The diff content is the same between requests, but the per-file order differs each time.

Expected

A fixed file order for identical input.

Effects

  • Same changeset yields differently-ordered prompts, so messages vary between regenerations.
  • Reordering invalidates the local runtime's prompt cache on each regeneration.

Suggested fix

Sort the change set by file path before assembling the prompt.

Related

Env: GitButler 0.20.3 (macOS), Ollama provider.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions