[GH-ISSUE #377] Ensure hooks work for git aliased commands #139

Closed
opened 2026-03-02 04:12:11 +03:00 by kerem · 0 comments
Owner

Originally created by @svarlamov on GitHub (Jan 18, 2026).
Original GitHub issue: https://github.com/git-ai-project/git-ai/issues/377

Depends on #376 first

Users commonly alias commands like git commit to shorter versions like git co. Since aliased commands to not actually call git again, but are instead resolved internally by git itself, we have to check to see if the command we see matches an existing hook we care about.

Aliases can also add new commands to a single git call. For example,

$ git config --global alias.unstage 'reset HEAD --'

# This makes the following two commands equivalent:
$ git unstage fileA
$ git reset HEAD -- fileA

This might also require additional logic in the hooks parsing to understand such chained commands. I am not sure what the best approach is to support this off the top of my head, but excited to discuss in this issue. I think an initial PR can leave this support out, and we could leave this part of the issue open.

We must also add tests with git config (might require updates to TestRepo to support this. Do not add them as global aliases so that it doesn't pollute developers' git installs and parallel tests to do not interfere with each other)

Git alias docs: https://git-scm.com/book/en/v2/Git-Basics-Git-Aliases

Originally created by @svarlamov on GitHub (Jan 18, 2026). Original GitHub issue: https://github.com/git-ai-project/git-ai/issues/377 Depends on #376 first Users commonly alias commands like `git commit` to shorter versions like `git co`. Since aliased commands to not actually call git again, but are instead resolved internally by `git` itself, we have to check to see if the command we see matches an existing hook we care about. Aliases can also add new commands to a single git call. For example, ``` $ git config --global alias.unstage 'reset HEAD --' # This makes the following two commands equivalent: $ git unstage fileA $ git reset HEAD -- fileA ``` This might also require additional logic in the hooks parsing to understand such chained commands. I am not sure what the best approach is to support this off the top of my head, but excited to discuss in this issue. I think an initial PR can leave this support out, and we could leave this part of the issue open. We must also add tests with git config (might require updates to TestRepo to support this. Do not add them as global aliases so that it doesn't pollute developers' git installs and parallel tests to do not interfere with each other) Git alias docs: https://git-scm.com/book/en/v2/Git-Basics-Git-Aliases
kerem 2026-03-02 04:12:11 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/git-ai#139
No description provided.