Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: support finding pr branch via git config branch keys
Fixes pwntester#799 When the gh cli tool checks out a branch created from a fork of the origin it places remote tracking info directly in git config at a key derived from branch.{branch_name} prefix. Octo did not consider this when checking if the repository is checked out to the branch pending merge into the origin. Update the `in_pr_branch` function to also check if the current PR has a git configuration which provides details of the upstream fork branch. See the following `man git-config` entries for more details: ``` branch.<name>.remote When on branch <name>, it tells git fetch and git push which remote to fetch from/push to. The remote to push to may be overridden with remote.pushDefault (for all branches). The remote to push to, for the current branch, may be further overridden by branch.<name>.pushRemote. If no remote is configured, or if you are not on any branch and there is more than one remote defined in the repository, it defaults to origin for fetching and remote.pushDefault for pushing. Additionally, . (a period) is the current local repository (a dot-repository), see branch.<name>.merge's final note below. branch.<name>.pushRemote When on branch <name>, it overrides branch.<name>.remote for pushing. It also overrides remote.pushDefault for pushing from branch <name>. When you pull from one place (e.g. your upstream) and push to another place (e.g. your own publishing repository), you would want to set remote.pushDefault to specify the remote to push to for all branches, and use this option to override it for a specific branch. branch.<name>.merge Defines, together with branch.<name>.remote, the upstream branch for the given branch. It tells git fetch/git pull/git rebase which branch to merge and can also affect git push (see push.default). When in branch <name>, it tells git fetch the default refspec to be marked for merging in FETCH_HEAD. The value is handled like the remote part of a refspec, and must match a ref which is fetched from the remote given by "branch.<name>.remote". The merge information is used by git pull (which at first calls git fetch) to lookup the default branch for merging. Without this option, git pull defaults to merge the first refspec fetched. Specify multiple values to get an octopus merge. If you wish to setup git pull so that it merges into <name> from another branch in the local repository, you can point branch.<name>.merge to the desired branch, and use the relative path setting . (a period) for branch.<name>.remote. ``` Signed-off-by: ldelossa <[email protected]>
- Loading branch information