【问题标题】:pull requests between two tags in git在 git 中的两个标签之间拉取请求
【发布时间】:2021-02-26 22:03:44
【问题描述】:

有没有办法在特定分支上的两个标签之间获取拉取请求。

现在,我正在使用 git log 来执行此操作。但是,似乎这会带来在第一个标签(PreviousVersion)之前创建的拉取请求。

git log --grep 'Merged PR' --oneline $CurrentVersion...$PreviousVersion --pretty=format:\"%s\"|cut -d':' -f 1|cut -d' ' -f3

你能帮忙吗?

【问题讨论】:

    标签: git github azure-devops devops azure-git-deployment


    【解决方案1】:

    $CurrentVersion...$PreviousVersion 并不意味着“在这两个提交之间”。它的意思是“任何提交只能通过 $CurrentVersion 或 ONLY $PreviousVersion”所以你可能会在 $PreviousVersion 之前得到一些提交。

    r1...r2 称为 r1 和 r2 的对称差,是 定义为 r1 r2 --not $(git merge-base --all r1 r2)。这是一组提交 可以从 r1(左侧)或 r2(右侧)之一到达,但不能 来自两者。

    改为使用$PreviousVersion..$CurrentVersion(两个点)。这也不完全是“在这两个提交之间”,因为 Git 历史不是线性的。它的意思是“提交可以通过 $CurrentVersion 访问,而不能通过 $PreviousVersion 访问”,这通常是您想要的。

    使用这个little example repository...

    A
    |
    B  [current]
    |
    C
    |
    |  1 [previous]
    |  |
    |  2
    | /
    D
    |
    E
    
    • 当前可以看到 B、C、D、E。
    • previous 可以看到 1、2、D、E。

    current...previous 将显示 B、C(仅当前可访问)和 1、2(仅可访问前一个)。

    previous..current 将只显示 B 和 C。

    current..previous 将仅显示 1 和 2。

    有关示例,请参阅 Revision Selection in Pro Git

    【讨论】:

    • 有没有办法对上一个和当前做常见的 PR(D,E),并将它们从当前删除。这样,我们就可以得到 B,C。
    • @Ras previous..current 只会给你 B、C。也许我不明白?
    • 它给了我 A 到 E。
    • @Ras 那么你的历史就不一样了。请与git log --oneline --all --graph --decorate 联系。这是a little script to make the example repository
    • 谢谢@Schwern。我觉得有什么不对劲。与我们的 IT 团队核实,我会在收到他们的回复后立即发布。
    猜你喜欢
    • 2017-08-04
    • 1970-01-01
    • 1970-01-01
    • 2020-03-04
    • 2014-04-30
    • 2011-12-31
    • 2021-04-12
    • 2017-07-14
    • 2014-08-27
    相关资源
    最近更新 更多