RFR: 1431: The method TestPullRequest#diff sometimes returns wrong information
Magnus Ihse Bursie
ihse at openjdk.org
Mon Aug 22 13:00:19 UTC 2022
On Mon, 22 Aug 2022 12:47:05 GMT, Erik Joelsson <erikj at openjdk.org> wrote:
>> test/src/main/java/org/openjdk/skara/test/TestPullRequest.java line 257:
>>
>>> 255: var baseHash = sourceHash;
>>> 256: var targetBranch = new Branch(targetRef());
>>> 257: while (!"0".repeat(40).equals(baseHash.hex())) {
>>
>> So if the common commit is more than 40 commits away, return "no diff"? :-)
>>
>> This is only used in testing, right? If so, this you could get away with it, but I think a comment describing the limitations would be needed.
>
> I think you are misunderstanding the code. `"0".repeat(40)` just generates a string with 40 zeros, basically a null hash.
>
> Looping to find the common ancestor is one way of doing it, but I would recommend checking out `git merge-base`. There is a method for it already on `GitRepository`.
I see. Yes, I misunderstood the code as looping backwards for a maximum of 40. Don't know how I got to that conclusion. My brain is apparently still partially stuck in vacation mode. I don't think I'm used to methods being called on a string literal.
-------------
PR: https://git.openjdk.org/skara/pull/1360
More information about the skara-dev
mailing list