alibaba / git-repo-go

git-repo is a command-line tool for centralized workflow, can work with Gerrit, AGit-Flow compatible servers. It is written in Golang, and it can be installed easily without further dependency. It provides an easy-to-use solution for multiple repositories which is introduced by Android repo first, and it can also work with a single repository.

Home Page:https://git-repo.info/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request: Add github api create merge request

cnmade opened this issue · comments

Ref: https://docs.github.com/en/rest/reference/pulls#create-a-pull-request

after local code change, we type git pr

this action will look for if the origin URL was github

If github ,then make API call to create new pull request

we can using .netrc to let git auto know the token to access the github api

Amazing way.

For example:

  1. know the origin URL , for me , like https://github.com/cnmade/bsmi-kb.git
  2. detect if the URL start with https://github.com and end with .git
  3. if match the rules, we know how to get the full repo : substr(0, 19), then substr(-4,4)
  4. we now get cnmade/bsmi-kb
  5. POST https://api.github.com/repos/{owner}/{repo}/pulls, for this repo, we know: https://api.github.com/repos/cnmade/bsmi-kb/pulls
curl \
  -X POST \
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/repos/cnmade/bsmi-kb/pulls \
  -d '{"head":"for/master","base":"master"}'
  1. job finished.

When I contributed "proc-receive" and "report-status-v2" to Git, Peff (Jeff King from GitHub) told me github has a tailored version of git-receive-pack, so it's not possible for github to support "proc-receive" quickly.

If you want to create pull request using github API, it's better to use github CLI tool. When creating pull request this way, you have to create a real topic branch, and cannot do like agit-flow or gerrit, which are built-in in this tool.

@jiangxin all works can be implement at client side .no more need to hack into git core.

I made some rush code to implement it.

see: https://github.com/cnmade/git-cpr/blob/for/dev/main.go

It works for me