-
Notifications
You must be signed in to change notification settings - Fork 9.2k
Open
Labels
enhancementNew feature or requestNew feature or request
Description
I use AI to review merge requests. The assistants I use all support git natively. However, they don't know how to check all changes since the parent branch, because the "parent branch" is not a standard git concept.
So every time I just give the AI the parent branch name or the command to get it.
It would be nice if the git MCP offered this function.
Here is the command I use; I think it is a reasonable definition of a parent branch:
Find the first commit on the current branch that is on a branch other than the current branch or any remote with the same name.
Print the name of any such branch.
current_branch=$(git rev-parse --abbrev-ref HEAD) && \
for commit in $(git rev-list HEAD); do \
other_branch=$(git branch -a --contains $commit | \
/usr/bin/grep -Ev -m 1 "^[ *]*(remotes/.*/)?$current_branch$" | \
sed -r 's#^[ *]*(remotes/)?##' | \
xargs); \
[[ -n "$other_branch" ]] && echo "$other_branch" && break; \
doneMetadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request