-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ISSUE 461] Fix issue when getting the fork name for the cases where the fork has a different name #462
Conversation
e2e tests are failing, I will investigate why... |
763d3f4
to
d56870c
Compare
@@ -125,15 +125,18 @@ export class GitAPIService { | |||
): Promise<string> { | |||
try { | |||
// check whether there is a fork with the same name as repo name | |||
const repoName = await this.checkIfRepositoryExists(targetOwner, repo); | |||
this.logger.info(`Checking if ${targetOwner}/${repo} is forked to ${sourceOwner}/${repo}`); | |||
const repoName = await this.checkIfRepositoryExists(sourceOwner, repo); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jstastny-cz @Ginxo TBH I'm not sure if using checkIfRepositoryExists
with sourceOwner
instead of targetOwner
is the correct way to go, after this change I'm getting many failures in the e2e tests locally and seems that in GH they are running forever and never finish.
To run them locally I used:
$ npm ci
$ ACT_LOG=true npm run test:e2e
Actually taking a look in the existing single-pr.test.ts e2e test, there is test PR from owner2/target:branchA to owner1/target-different-name:branchB
which should be testing the case where the fork has a different name from the original repository and the test is passing. Am I missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's it, this functionality is already covered and it shouldn't be re-adapted unless we discover specific corner case for it I'm not able to find (can't get trace logs).
I'm afraid we are missing something on the BC configuration rather than BC bug, but it is just a feeling I would like to confirm/discard. Could you please provide logs URL? Many thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it really seem correct to you @Ginxo ? We want to check here in the method if there's a fork with the same name as repo name ... but why would we check that the repo in target exists as the first thing and if so then return?
In code we invoke getForkName(currentTarget.group, originalSource.group!, currentTarget.name)
in checkout-service.ts:L163, where the currentTarget variable in same file L140 is commented as
// map the starting project target branch to the corresponding branch defined in the mapping for the current node // target branch is guaranteed to exist since base always exist
That really sounds like identity check. And the single-pr.test.ts - I am gonna check, but in this case I have mutliple PRs across 3 repositories, maybe it tests a different thing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It certainly does not do what the comment just above it says // check whether there is a fork with the same name as repo name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider this reproducer :
test("getForkNameForDifferentName", async () => {
const moctokit = new Moctokit();
moctokit.rest.repos
.get({ owner: "sourceOwner", repo: "repo" })
.reply({ status: 200, data: {} });
moctokit.rest.repos
.get({ owner: "targetOwner", repo: "repo" })
.reply({ status: 200, data: { name: "repo", owner: { login: "targetOwner" } } });
moctokit.rest.repos.listForks({ owner: "targetOwner", repo: "repo" }).reply({
status: 200,
data: [{ name: "repo-fork", owner: { login: "sourceOwner" } }],
});
await expect(git.getForkName("targetOwner", "sourceOwner", "repo")).resolves.toBe(
"repo-fork"
);
})
getForkName returns "repo".
@shubhbapna if you're available to discuss. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would maybe suggest removing the optimization of expecting that repositories with matching names between various groups/authors are possible forks altogether and rather rely on the resolution.
@jstastny-cz You are correct, it should be |
…the fork has a different name
@shubhbapna is it possible that you help us here related to the e2e tests please? As part of this PR there is a commit fixing the And now I'm trying to fix the |
So based on @shubhbapna comment, we followed the right path using All the e2e tests passed no and I would like to ask @shubhbapna @jstastny-cz and @Ginxo to review the PR. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind adding the unit test I pasted above? Or I can send a PR to your fork.
I'll try to understand the changes in tests tomorrow and add proper review.
@jstastny-cz there was already a test for the getForkName(), so I expanded it to also include what you suggested, please take a look. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just few minor suggestions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think one test mocked values are not corresponding.
@@ -158,13 +158,22 @@ test("PR from owner1/target:branchA to owner2/target:branchB while using mapping | |||
mockApi: [ | |||
moctokit.rest.repos | |||
.get({ | |||
owner: "owner1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok this seems like it was a hack to get around the issue that we're fixing (to get into the other path of the getForkName method). Seems valid not to fail resolution of the repos.
I would add though a successful resolution of owner1/project4 - that's the one actually receiving a PR. Or do I miss sth?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we already have a successful resolution of owner2/project4 in the block after this one.
In this cross-pr.test.ts, Owner1 has project1, project2, project3 and project4 while Owner 2 has only project3 and project4, that's why I mocked project1 and 2 to fail state and project 3 and 4 to ok state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was talking about owner1/project4 , it should not affect how the test runs now, but it might "strengthen" the test context ... anyway, just a minor note really.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jstastny-cz I would go without is for now, as AFAIK we are not doing it for the other tests like full-downstream.test.ts, otherwise I think we would need to apply this everywhere to be consistent (even not affecting the test result)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jstastny-cz if you are ok with the PR state, please approve it
Co-authored-by: Enrique Mingorance Cano <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thank you.
Fixes #461