我可以用逻辑运算符 OR 搜索 github 标签吗?

我试着像这样过滤我在 Github 上的所有问题:

label:bug OR label:enhancement

但是很明显这不起作用,我找到了这一页 Https://help.github.com/articles/searching-issues/ 我以为一定要写在那里,但是我不知道怎么写。

一个人真的不能过滤两个标签的问题吗?我的意思是,这将是一个非常基本的任务,不是吗?

如果有人能给我点提示,我会很高兴听到的。

38313 次浏览

截至2021年更新

现在您可以使用 OR 操作进行搜索。请查看@VonC 给出的答案


Github 不支持这样搜索标签。对问题的搜索被认为是“ AND”而不是“ OR”。

下面是一个用于尝试这种方法的存储库。

演示 github 在搜索中支持“ AND”的示例

我的期望

所有的问题,是增强,功能或两者都应该出现. 。

  1. 增强和特征

  2. 增强

  3. 特写

实际结果

只有两个都出现了。

  1. 增强和特征

因此它不支持 OR 操作符。

更新

Another tedious hack around this could be remove the unwanted labels using a -(minus) symbol before the label. Look at the following example

label:enhancement -label:bug -label:foo -label:bar

这将列出所有没有 foo、 bar 和 bug 作为标签的项目。这将工作,但可以成为单调乏味的标签太多。

只包含增强的过滤问题

例如,我过滤包含两个标签的问题,如- Https://api.github.com/search/issues?q=language:python+label:%22good%20first%20issue%22+label:%22help%20wanted%22+state:open&sort=created 这个问题已经过时了,但我希望它能帮助那些可能被同一个问题困住的人。

截至2021年8月,也见这里: 我可以用逻辑运算符 OR 搜索 github 标签吗?和: https://github.blog/changelog/2021-08-02-search-issues-by-label-using-logical-or/


理想情况下,GitHub 搜索将支持嵌套和分组的括号,以及逻辑 ANDORNOT操作符。我希望他们能支持这样的事情:

is:open AND is:pr AND (review-requested:ElectricRCAircraftGuy OR
assignee:ElectricRCAircraftGuy) AND NOT(review-requested:"team:ORGNAME/team-1") AND
archived:false AND (author:my-teammate-1 OR author:my-teammate-2 OR
author:my-teammate-3)

相反,他们的搜索是非常有限的,也相当复杂,因为它有非常不同的行为取决于你键入你的搜索 哪里。由于不支持上面的搜索样式,让我们考虑一下这种更有限的搜索尝试:


我的研究:

is:open is:pr review-requested:ElectricRCAircraftGuy archived:false
author:my-teammate-1 author:my-teammate-2 author:my-teammate-3

The behavior I WANT is this:

is:open AND is:pr AND review-requested:ElectricRCAircraftGuy AND archived:false AND
(author:my-teammate-1 OR author:my-teammate-2 OR author:my-teammate-3)

But depending on 哪里 you do this search, you will get 两种截然不同的行为. If I go to https://github.com/ --> 点播请求 (at top) and type the search into this search bar highlighted in yellow here:

enter image description here

... 然后我得到了这个搜索行为:

is:open AND is:pr AND review-requested:ElectricRCAircraftGuy AND archived:false AND author:my-teammate-3

注意,所有 author字段 除了最后一个都被删除了。一次只能搜索给定字段中的一个!这太局限了!就好像我做过这样的搜索:

is:open is:pr review-requested:ElectricRCAircraftGuy archived:false
author:my-teammate-3

但是,如果我使用全局搜索栏(下面突出显示) ,它几乎可以在 https://github.com/的任何地方使用,然后复制并粘贴 My search到这个搜索栏中:

enter image description here

然后我得到了这种搜索行为这正是我想要的:

is:open AND is:pr AND review-requested:ElectricRCAircraftGuy AND archived:false AND
(author:my-teammate-1 OR author:my-teammate-2 OR author:my-teammate-3)

这意味着在全局搜索栏中,每个搜索词都在引擎盖下与 AND连接,除非有给定字段的倍数,然后每个字段都在引擎盖下与 OR连接,如上所示。但是,在本地拉请求搜索栏中,每个搜索项都与 AND在引擎盖下连接,如果存在给定字段的倍数,则删除所有的倍数,并保留 除了最后一个。这就是我所说的“复杂”的搜索行为,因为结果是1)混乱的,2)不同的,取决于你使用的搜索栏,3)限制: 即使你知道关于 GitHub 搜索的一切,仍然不可能获得你想要的搜索结果。如果没有广泛的研究和尝试,很难理解正在发生的事情,而这正是我必须要做的。:(

那么,如果您希望看到由我的队友1或我的队友2或我的队友3提出的所有“审查请求”的列表,您有哪些选择呢?你可以做一个全局搜索并加入书签,像这样:

is:open is:pr review-requested:ElectricRCAircraftGuy archived:false
author:my-teammate-1 author:my-teammate-2 author:my-teammate-3

或者你可以这样做,并标记3个独立的拉请求搜索,像这样:

  1. 开放的,未归档的公关要求我的审查和由 my-teammate-1
    is:open is:pr review-requested:ElectricRCAircraftGuy archived:false
    author:my-teammate-1
    
  2. 开放的,未归档的公关要求我的审查和由 my-teammate-2
    is:open is:pr review-requested:ElectricRCAircraftGuy archived:false
    author:my-teammate-2
    
  3. 开放的,未归档的公关要求我的审查和由 my-teammate-3
    is:open is:pr review-requested:ElectricRCAircraftGuy archived:false
    author:my-teammate-3
    

拉请求搜索的显示结果以一种更好的格式显示,所以即使对3个拉请求搜索进行标记比对同一事物进行单个全局搜索进行标记更痛苦,但这可能是你更喜欢的做法。

如果你想做一些更复杂的事情,比如得到这个行为:

is:open AND is:pr AND (review-requested:ElectricRCAircraftGuy OR
assignee:ElectricRCAircraftGuy) AND NOT(review-requested:"team:ORGNAME/team-1") AND
archived:false AND (author:my-teammate-1 OR author:my-teammate-2 OR
author:my-teammate-3)

抱歉,目前不可能。您必须创建多个子搜索,利用适合您的搜索栏行为,并在必要时使用 -标志排除结果。但是,您可以请求 GitHub 实现这种更高级的搜索行为,方法是先打开问题 here (not affiliated with GitHub--just a place to track issues),然后打开问题 给他们传递一个信息,并向它们提供指向您的问题和这个 Stack Overflow 答案的链接。

GitHub 搜索快速参考小抄:

提醒: 看这里可以快速刷新/总结在使用 GitHub 全局搜索栏和 GitHub Pull Request 搜索栏时应该期待什么。

默认的 GITHUB 拉请求(PR)搜索:

  1. 所有 我创造的公共关系:
    1. https://github.com --> click "Pull requests" at the 非常好.
    2. 直接链接: https://github.com/pulls
  2. 所有 分配给我的公开报告:
    1. Https://github.com —— > “拉请求”—— > “分配”。
    2. Direct link: https://github.com/pulls/assigned
  3. 所有 在评论中提到我的公共关系(通过@my-username) :
    1. https://github.com --> "Pull requests" --> "Mentioned".
    2. 直接链接: https://github.com/pulls/mentioned
  4. 所有 要求我审查的公开公共关系:
    1. Https://github.com —— > “拉请求”—— > “审查请求”。
    2. 直接链接: https://github.com/pulls/review-requested

自定义 GITHUB 拉请求(PR)搜索:

  1. 作者:

    1. 使用 拉请求搜索栏:

      1. Https://github.com —— > 在 非常好点击“拉请求”。

      2. 直接链接: < a href = “ https://github.com/pull”rel = “ norefrer”> https://github.com/pulls

      3. 现在使用位于顶部中间/顶部右侧的搜索栏。

      4. 注意,这个搜索栏一次只限于一个作者:

         is:open is:pr archived:false author:username-1
        is:open is:pr archived:false author:username-2
        is:open is:pr archived:false author:username-3
        is:open is:pr archived:false author:username-4
        
      5. 下面是上面四个搜索中第一个的一个样例 URL: < a href = “ https://github.com/pull? q = is% 3Aopen + is% 3Apr + archive% 3Afalse + author% 3Ausername-1”rel = “ noreference rer”> https://github.com/pulls?q=is%3aopen+is%3apr+archived%3afalse+author%3ausername-1

    2. [ BEST ] 使用 GitHub 全局搜索栏(GitHub 页面左上角的主搜索栏):

      • 这个搜索栏允许同时使用多个作者,但是显示的内容与上面的“拉”请求搜索略有不同(看起来没有那么好) :

          is:open is:pr archived:false author:username-1 author:username-2 author:username-3 author:username-4
        
      • 下面是在 GitHub 全局搜索栏中执行此搜索后的 URL: < a href = “ https://GitHub.com/search? q = is% 3Aopen + is% 3Apr + archive% 3Afalse + author% 3Ausername-1 + author% 3Ausername-2 + author% 3Ausername-3 + author% 3Ausername-4”rel = “ noReferrer”> https://GitHub.com/search?q=is%3aopen+is%3apr+archived%3afalse+author%3ausername-1+author%3ausername-2+author%3ausername-3+author%3ausername-4

  2. REVIEWS REQUESTED OF ME BY OTHERS:

    1. 使用 Pull request search bar:

      • 注意,这个搜索栏一次只限于一个作者:

          is:open is:pr archived:false review-requested:my-username author:username-1
        is:open is:pr archived:false review-requested:my-username author:username-2
        is:open is:pr archived:false review-requested:my-username author:username-3
        is:open is:pr archived:false review-requested:my-username author:username-4
        
      • 下面是上面第一个搜索的一个示例 URL: < a href = “ https://github.com/pull? q = is% 3Aopen + is% 3Apr + archive% 3Afalse + review-request% 3Amy-username + author% 3Ausername-1”rel = “ noReferrer”> https://github.com/pulls?q=is%3aopen+is%3apr+archived%3afalse+review-requested%3amy-username+author%3ausername-1

    2. [ BEST ] 使用 GitHub 全局搜索栏(GitHub 页面左上角的主搜索栏):

      • 这个搜索栏允许同时使用多个作者,但是显示的内容与上面的“拉”请求搜索略有不同(看起来没有那么好) :

          is:open is:pr archived:false review-requested:my-username author:username-1 author:username-2 author:username-3 author:username-4
        
      • 由上述全局搜索产生的 URL: < a href = “ https://github.com/search? q = is% 3Aopen + is% 3Apr + archive% 3Afalse + review-request% 3Amy-username + author% 3Ausername-1 + author% 3Ausername-2 + author% 3Ausername-3 + author% 3Ausername-4”rel = “ noReferrer”> https://github.com/search?q=is%3aopen+is%3apr+archived%3afalse+review-requested%3amy-username+author%3ausername-1+author%3ausername-2+author%3ausername-3+author%3ausername-4

参见:

  1. 我在这里的答案是如何通过“分支”、“从分支”和作者 包括来搜索 PR,使用自定义的 Chrome 搜索引擎,你可以在搜索栏中快速触发: How can I filter all GitHub pull requests for a specific target branch.

参考文献:

  1. https://webapps.stackexchange.com/questions/57933/how-to-search-with-logic-operators-on-github/111246#111246
  2. 在这里也可以看到我的简短回答: https://webapps.stackexchange.com/questions/57933/how-to-search-with-logic-operators-on-github/142071#142071
  3. 开始在 GitHub 上搜索
    1. 关于在 GitHub 上搜索
    2. 搜索问题和请求
    3. 使用搜索过滤问题和请求
    4. 理解搜索语法
    5. Troubleshooting search queries - here they mention AND, OR, and NOT operators, but they don't seem to actually have these implemented, so this page must be out-of-date :(.
  4. Https://github.com/isaacs/github/issues/660

从2021年8月开始,是的。

但是,它有 尚未传播到 GitHub Enterprise (2021年10月)
它也出现在 GHE 3.3(2021年12月)

参见:

使用逻辑 OR 按标签搜索问题

现在可以使用逻辑 OR 通过标签搜索问题。

只需使用逗号分隔标签。
For example:

label:"good first issue",bug

将列出与标签 good first issuebug的所有问题。

除了其他人所说的: 从3.3版本开始,在 GitHub Enterprise (GHE)中就可以使用 OR 搜索。请参阅 https://docs.github.com/enterprise-server@3.3/admin/release-notes#issues-and-pull-requests-changes的发布说明。

我在 git 提交中使用了它

from urllib.parse import quote


os.system('curl '+ '-H "Accept: application/vnd.github.cloak-preview"' + ' -s https://api.github.com/search/commits?q='+ \
quote('(KEYWORD1 OR KEYWORD2 OR KEYWORD3) repo:[PUT YOUR TARGET SEARCH REPOSITORY LINK HERE]')  ')