如何将新的拉取请求附加到 github 上的现有问题?

发布于 2024-10-08 23:09:07 字数 301 浏览 1 评论 0 原文

我不确定,但我有一个模糊的记忆,创建了一个带有“Issue 4”或标题中的内容的 github pull request,并且它自动附加到我提交的项目中的 Issue 4。我最近又尝试了一次,但没有成功——它只是创建了一个全新的问题。我在新的拉取请求页面上没有看到任何类似“附加到问题”的选项,也没有在问题页面上看到“为此问题打开新的拉取请求”。有什么方法可以做到这一点,以帮助项目所有者保持问题页面整洁并避免重复?

编辑:澄清一下,我知道创建拉取请求总是会产生问题。我想将拉取请求附加到现有问题。

I'm not sure, but I have a vague memory of creating a github pull request with "Issue 4" or something in the title, and it automatically attached itself to Issue 4 in the project that I was submitting it to. I tried it again recently and it didn't work -- it just created a brand new issue instead. I don't see any options like "Attach to issue" on the new pull request page, nor "Open a new pull request for this issue" on the issue page. Is there any way to do this, to help project owners keep their Issues page clean and avoid duplication?

Edit: To clarify, I know that creating a pull request always creates a new issue. I would like to instead attach the pull request to an existing issue.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(10

于我来说 2024-10-15 23:09:07

向现有上游问题添加拉取请求很容易假设您使用正常的 github 方式进行分叉

只需使用任何支持的关键字在提交消息中引用该问题:

  • close
  • closes
  • close
  • 修复
  • 修复
  • 修复
  • 解决
  • 解决
  • 已解决

例如:“此提交修复#116”

引用该问题的文本不需要出现在提交的主题行中。

将您的提交推送到 github 存储库,拉取请求将自动附加到问题中。

注意:虽然不是必需的,但强烈建议您将属于拉取请求一部分的任何内容提交到特定于该问题的单独分支,因为该分支上的未来提交将被附加到拉取请求(由 github 自动添加) )。因此,如果您没有创建单独的分支,将其保留在 master 上,然后继续开发,那么您对 ​​master 的所有不相关的提交都将被附加到您的拉取请求中。

Adding a pull request to an existing upstream issue is easy assuming you forked using the normal github means.

Simply reference the issue in your commit message using any of the supported keywords:

  • close
  • closes
  • closed
  • fix
  • fixes
  • fixed
  • resolve
  • resolves
  • resolved

For example: "this commit fixes #116"

The text referencing the issue does not need to appear in the subject line of your commit.

Push your commit to your github repo and the pull request will be automatically appended to the issue.

Note: While it is not required, it is strongly recommended that you commit anything that will be part of a pull request to a separate branch specific to that issue, because future commits on that branch will be appended to the pull request (automatically by github). So, if you didn't make a separate branch, left it on master, and then kept developing, then all your unrelated commits to master would get appended to your pull request.

池予 2024-10-15 23:09:07

hub 项目可以做到这一点。

在要从中发送拉取请求的存储库和分支中:

$ hub pull-request -i 4

这使用 GitHub API,并将当前分支的拉取请求附加到现有问题号 4。


编辑:@atomicules 的评论:为了扩展 @MichaelMior 的答案,一个完整的例子是:

$ hub pull-request -i 4 -b USERNAME_OF_UPSTREAM_OWNER:UPSTREAM_BRANCH -h YOUR_USERNAME:YOUR_BRANCH URL_TO_ISSUE

The hub project can do this.

In the repository and branch that you want to send a pull request from:

$ hub pull-request -i 4

This uses the GitHub API, and attaches a pull request for the current branch to the existing issue number 4.


EDIT: Comment by @atomicules: To expand on the answer by @MichaelMior a full example is:

$ hub pull-request -i 4 -b USERNAME_OF_UPSTREAM_OWNER:UPSTREAM_BRANCH -h YOUR_USERNAME:YOUR_BRANCH URL_TO_ISSUE
柠檬 2024-10-15 23:09:07

您可以使用 Pull Request API 从现有问题创建 Pull 请求:

$ curl --user "smparkes" \
       --request POST \
       --data '{"issue": 15, "head": "smparkes:synchrony", "base": "master"}' \
       https://api.github.com/repos/technoweenie/faraday/pulls

这会创建一个拉取请求:

  • faraday 项目中询问 technoweenie (https://api.github.com/repos/technoweenie /faraday/pulls)
  • smparkes' fork 中的 synchrony 分支中拉取(“head ": "smparkes:同步")
  • master 分支>technoweenie 的 fork ("base": "master")
  • 并将拉取请求附加到问题 15 ("issue": 15
  • 与拉取请求作者smparkes(--user“smparkes”),系统
  • 将提示您获取您的 GitHub 密码

You can create a Pull Request from an existing Issue with the Pull Request API:

$ curl --user "smparkes" \
       --request POST \
       --data '{"issue": 15, "head": "smparkes:synchrony", "base": "master"}' \
       https://api.github.com/repos/technoweenie/faraday/pulls

This creates a pull request:

  • ask technoweenie at project faraday (https://api.github.com/repos/technoweenie/faraday/pulls)
  • to pull from the synchrony branch in smparkes' fork ("head": "smparkes:synchrony")
  • to the master branch in technoweenie's fork ("base": "master")
  • and attach the pull request to issue 15 ("issue": 15)
  • with the pull request author smparkes (--user "smparkes")
  • you will be prompted for your GitHub password
我要还你自由 2024-10-15 23:09:07

另一个可能的工具是 Issue2Pr 网站,它将您的问题转化为拉取请求。

非常简单有效!

在此处输入图像描述

资源:

Another possible tool is the Issue2Pr website which turns your issues into Pull Requests.

It's very simple and effective!

enter image description here

Resources:

素年丶 2024-10-15 23:09:07

这个其他答案解释了如何使用cURL (curl) 通过 GitHub API。以下是如何使用 HTTPie (http) 来完成此操作,这会产生更简单的- 易于阅读且易于编辑的命令:

$ http --auth "<your-GitHub-username>" \
       POST \
       https://api.github.com/repos/<issue-repo-owner>/<issue-repo-name>/pulls \
       issue=<issue-number> head=<your-GitHub-username>:<your-fork-branch-name> base=<issue-repo-branch-name>

然后在出现提示时输入您的 GitHub 密码。

解释示例

您已使用用户名 smparkes 和密码 hunter2< 登录 GitHub /em>.您看到了 technoweenie 的存储库 faraday,想到了应该更改的内容,并在该存储库上为其提出了一个问题,问题#15。后来,你发现没有其他人做出你提议的改变,而你也有一些时间自己去做。您分叉faraday到您自己的帐户,然后写入您的更改并推送它们到名为 synchrony 的分支下的分支。您认为 technoweenie 应该将这些更改拉到 master 他的仓库的分支。对于这种情况,您可以编写以下命令,将之前的问题转换为拉取请求:

$ http --auth "smparkes" \
       POST \
       https://api.github.com/repos/technoweenie/faraday/pulls \
       issue=15 head=smparkes:synchrony base=master
http: password for [email protected]: hunter2

现在 问题#15 是一个 Pull 请求。

This other answer explains how to use cURL (curl) to create a Pull Request from an Issue through the GitHub API. Here’s how to do it using HTTPie (http), which produces an easier-to-read and easier-to-edit command:

$ http --auth "<your-GitHub-username>" \
       POST \
       https://api.github.com/repos/<issue-repo-owner>/<issue-repo-name>/pulls \
       issue=<issue-number> head=<your-GitHub-username>:<your-fork-branch-name> base=<issue-repo-branch-name>

Then type your GitHub password when prompted.

Explained example

You have logged into GitHub with username smparkes and password hunter2. You saw technoweenie’s repo faraday, thought of something that should be changed, and made an Issue on that repo for it, Issue #15. Later, you find that nobody else has made your proposed change, and you also have some time to do it yourself. You fork faraday to your own account, then write your changes and push them to your fork under a branch named synchrony. You think technoweenie should pull those changes to the master branch of his repo. This is the command you would write to convert your previous Issue into a Pull Request for this situation:

$ http --auth "smparkes" \
       POST \
       https://api.github.com/repos/technoweenie/faraday/pulls \
       issue=15 head=smparkes:synchrony base=master
http: password for [email protected]: hunter2

Now Issue #15 is a Pull Request.

酷遇一生 2024-10-15 23:09:07

而不是在客户端执行此操作(使用 hub,如 < a href="https://stackoverflow.com/users/3757/christian-oudard">克里斯蒂安·乌达尔 答案),您现在(2020 年 2 月)可以在服务器端 (github.com) 执行此操作,

请参阅“从侧边栏查看和链接问题和拉取请求 "

您现在可以通过各自页面的侧边栏链接问题和拉取请求。合并链接的拉取请求后,此处建立的连接将自动关闭问题。

文档

还有一个 搜索 API 具有该功能。

使用 linked:pr 搜索限定符查找存储库中具有关闭拉取请求引用的所有未解决问题。
同样,使用 -linked:issue 找到存储库中缺少支持问题的所有拉取请求。


Ismoh评论到讨论:

GitHub Action: Pull request 'development' object/data, aka linked issues"

和 Ismosh 的 用于查找拉取请求的链接问题的市场操作

    - name: Find linked issues
      id: find-linked-issues
      uses: Ismoh-Games/[email protected]
      with:
        token: ${{ secrets.GITHUB_TOKEN }}
        repository: ${{ github.repository }} # optional
        pull-request-number: ${{ github.event.pull_request.number }} # optional
        copy-issues-labels: true # optional

Instead of doing that on the client side (with hub, as in Christian Oudard answer), you now (February 2020) can do it on the server side (github.com)

See "View and link issues and pull requests from the sidebar "

You can now link issues and pull requests via the sidebar in their respective pages. Connections made here will automatically close issues once a linked pull request is merged.

Documentation: https://help.github.com/assets/images/help/pull_requests/link-issue-drop-down.png

And there is a search API with that feature.

Find all the open issues in a repository that have closing pull requests references with the linked:pr search qualifier.
Similarly, locate all the pull requests in a repository that are missing a supporting issue with -linked:issue.


Ismoh refers in the comments to the discussion:

"GitHub Action: Pull request 'development' object/data, aka linked issues"

And Ismosh's Marketplace action for finding the linked issues of a pull request.

    - name: Find linked issues
      id: find-linked-issues
      uses: Ismoh-Games/[email protected]
      with:
        token: ${{ secrets.GITHUB_TOKEN }}
        repository: ${{ github.repository }} # optional
        pull-request-number: ${{ github.event.pull_request.number }} # optional
        copy-issues-labels: true # optional
感受沵的脚步 2024-10-15 23:09:07

如果您在 github 上使用 2-factor-auth,您需要在请求中提供 authtoken 作为标头:

curl -u "<your_username>:<your_pw>" \
     --header 'X-GitHub-OTP: <your_authtoken>' \
     --request POST \
     --data '{"issue":"<issue_nr>", "head":"<your_username>:<your_forks_branchname>", "base":"<upstream_branch>"}' \
     https://api.github.com/repos/<upstream_user>/<upstream_repo>/pulls

in case you use 2-factor-auth with github you'll need to provide the authtoken as header in the request:

curl -u "<your_username>:<your_pw>" \
     --header 'X-GitHub-OTP: <your_authtoken>' \
     --request POST \
     --data '{"issue":"<issue_nr>", "head":"<your_username>:<your_forks_branchname>", "base":"<upstream_branch>"}' \
     https://api.github.com/repos/<upstream_user>/<upstream_repo>/pulls
自此以后,行同陌路 2024-10-15 23:09:07

您还可以使用 Gub 提交针对您的问题的拉取请求。

它还可以帮助您使用正确的分叉/拉请求样式。

编辑:2013 年 10 月 5 日

要让 Gub 提交问题 #123 的拉取请求,您需要运行以下命令:

$ gub start 123

这将创建一个新的分支 issues-123。一旦你完成了这个问题,执行:

$ gub finish

瞧!

注:我是Gub gem 的作者。

You may also use Gub to submit pull requests for your issue.

It also helps you use a proper fork/pull-request style.

Edit: 10/5/2013

To get Gub to submit pull-request for issue #123, you need to run the following:

$ gub start 123

This will create a new branch issue-123. Once you're done working on the issue, execute:

$ gub finish

Voila!

Note: I am the author of Gub gem.

も星光 2024-10-15 23:09:07

使用 git-hub 工具,您可以通过以下方式执行此操作:

$>; git hub 拉附加 123

这会将问题 #123 转换为拉取请求 #123,从而将有关该问题的所有讨论保留在一个位置。

Using the git-hub tool, you could do this with:

$> git hub pull attach 123

This would convert issue #123 into pull request #123, thus maintaining all discussion about the issue in a single location.

今天小雨转甜 2024-10-15 23:09:07

如果您启用了 2FA,则可以使用 HTTPie 传递令牌:

http POST \
    https://api.github.com/repos/<repo-owner>/<repo-name>/pulls \
    issue=2 head=issue_2 base=master
    "Authorization:token PUTAUTHTOKENHERE"

这将使用分支 issue_2 将问题 #2 转换为拉取请求。

If you have 2FA enabled, you can use pass the token with HTTPie:

http POST \
    https://api.github.com/repos/<repo-owner>/<repo-name>/pulls \
    issue=2 head=issue_2 base=master
    "Authorization:token PUTAUTHTOKENHERE"

This will use the branch issue_2 to convert issue #2 into a pull request.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文