Skip to content
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

Bug 2021205: fix git url change validation #10769

Conversation

abhinandan13jan
Copy link
Contributor

@abhinandan13jan abhinandan13jan commented Jan 4, 2022

Addresses

https://issues.redhat.com/browse/OCPBUGSM-36949
https://bugzilla.redhat.com/show_bug.cgi

Issue

Reads gitType instead of detectedGitType

Screenshots

url-change-validation

Tests

no change

Browser conformance

Chrome / Firefox

@abhinandan13jan abhinandan13jan changed the title fix git url change validation Bug 2021205: fix git url change validation Jan 4, 2022
@openshift-ci openshift-ci bot added bugzilla/severity-low Referenced Bugzilla bug's severity is low for the branch this PR is targeting. bugzilla/invalid-bug Indicates that a referenced Bugzilla bug is invalid for the branch this PR is targeting. labels Jan 4, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 4, 2022

@abhinandan13jan: This pull request references Bugzilla bug 2021205, which is invalid:

  • expected the bug to target the "4.10.0" release, but it targets "---" instead

Comment /bugzilla refresh to re-evaluate validity if changes to the Bugzilla bug are made, or edit the title of this pull request to link to a different bug.

In response to this:

Bug 2021205: fix git url change validation

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci openshift-ci bot added the component/dev-console Related to dev-console label Jan 4, 2022
@abhinandan13jan
Copy link
Contributor Author

/kind bug

@openshift-ci openshift-ci bot added the kind/bug Categorizes issue or PR as related to a bug. label Jan 4, 2022
@abhinandan13jan
Copy link
Contributor Author

/bugzilla refresh

@openshift-ci openshift-ci bot added bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. and removed bugzilla/invalid-bug Indicates that a referenced Bugzilla bug is invalid for the branch this PR is targeting. labels Jan 4, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 4, 2022

@abhinandan13jan: This pull request references Bugzilla bug 2021205, which is valid. The bug has been moved to the POST state. The bug has been updated to refer to the pull request using the external bug tracker.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.10.0) matches configured target release for branch (4.10.0)
  • bug is in the state NEW, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

Requesting review from QA contact:
/cc @sanketpathak

In response to this:

/bugzilla refresh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@karthikjeeyar
Copy link
Contributor

When the user fixes the incorrect url, the Git type should not be shown. We need to reset the showGitType variable when a valid git type is detected

image

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 4, 2022

@abhinandan13jan: This pull request references Bugzilla bug 2021205, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.10.0) matches configured target release for branch (4.10.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

Requesting review from QA contact:
/cc @sanketpathak

In response to this:

Bug 2021205: fix git url change validation

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@abhinandan13jan
Copy link
Contributor Author

When the user fixes the incorrect url, the Git type should not be shown. We need to reset the showGitType variable when a valid git type is detected

image

Fixed
git-url-valid

@karthikjeeyar
Copy link
Contributor

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jan 5, 2022
@abhinandan13jan
Copy link
Contributor Author

/test e2e-gcp-console

@christoph-jerolimov
Copy link
Member

/assign

Copy link
Member

@christoph-jerolimov christoph-jerolimov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the old version, the user must select the Git provider if the URL detection doesn't work.

This single case is fixed in the new version, but it breaks the option to select a provider .. and maybe switch it after that. Checkout this recoding:

Peek 2022-01-05 22-24

/hold

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 5, 2022
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Jan 6, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 6, 2022

@abhinandan13jan: This pull request references Bugzilla bug 2021205, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.10.0) matches configured target release for branch (4.10.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

Requesting review from QA contact:
/cc @sanketpathak

In response to this:

Bug 2021205: fix git url change validation

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Comment on lines 241 to 247
}

if (
detectedGitType === GitTypes.github ||
detectedGitType === GitTypes.gitlab ||
detectedGitType === GitTypes.bitbucket
) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this also if we compare it to "not unsure" (aka sure) instead of list all (currently) known Git provider?

You can optional add the && showGitTypes so that setFieldValue is not called if it's already false.

Suggested change
}
if (
detectedGitType === GitTypes.github ||
detectedGitType === GitTypes.gitlab ||
detectedGitType === GitTypes.bitbucket
) {
} else if (detectedGitType !== GitTypes.unsure && values.git.showGitType) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i am now using a cleaner approach to the problem. Updated

Comment on lines 250 to 260
gitType as any,
detectedGitType as any,
Copy link
Member

@christoph-jerolimov christoph-jerolimov Jan 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure, but is this change really needed? Doesn't it make sense to use the selected type if we show this dropdown option?

Sorry, but I'm now even more sure that this is not what we want here. If the user selects a git provider for a custom domain we should his/her selection instead of the latest detection.

For example when the user enters https://git.mycomapny.com and selects GitLab and changes the repo name again we should still use GitLab to detect the import strategies.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

@abhinandan13jan
Copy link
Contributor Author

In the old version, the user must select the Git provider if the URL detection doesn't work.

This single case is fixed in the new version, but it breaks the option to select a provider .. and maybe switch it after that. Checkout this recoding:

Peek 2022-01-05 22-24

/hold

I updated
git-url-change

@christoph-jerolimov
Copy link
Member

christoph-jerolimov commented Jan 6, 2022

Works better. I unhold this if someone else will take a look. I added two questions and will take a deeper look later.

/unhold

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 6, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 6, 2022

@abhinandan13jan: This pull request references Bugzilla bug 2021205, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.10.0) matches configured target release for branch (4.10.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

Requesting review from QA contact:
/cc @sanketpathak

In response to this:

Bug 2021205: fix git url change validation

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@abhinandan13jan
Copy link
Contributor Author

/test e2e-gcp-console

@karthikjeeyar
Copy link
Contributor

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jan 7, 2022
@christoph-jerolimov
Copy link
Member

/retest

Copy link
Member

@christoph-jerolimov christoph-jerolimov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @abhinandan13jan, cc @karthikjeeyar,

the reason my review takes so long was that I'm not happy that handleGitUrlChange was now called twice when switching from an invalid to a valid git URL.

duplicate-github-calls

This happen because const handleGitUrlChange = React.useCallback(... updates the git type in line 252. The useEffect in line 421 then calls the same handleGitUrlChange again with a debounce.

I think we could fix it by cleaning the touched info when we automatically override the git.type in line 251. See suggestion below.

Did you see any reasons, not to do this? IMHO this works only because the useEffect has a (for me not really understandable) condition for different "touched" fields. Btw: I'm not a fan of this solution and that the InputField onChange, this callback, and the effect works so closely together, but that is something we should maybe cleanup in the future.

Comment on lines 251 to 254
if (gitType !== values.git.type) {
setFieldValue('git.type', gitType);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (gitType !== values.git.type) {
setFieldValue('git.type', gitType);
}
if (gitType !== values.git.type) {
setFieldTouched('git.type', false, false);
setFieldValue('git.type', gitType, true);
}

With this change:

fixed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback, I updated accordingly :)

@christoph-jerolimov
Copy link
Member

christoph-jerolimov commented Jan 8, 2022

@abhinandan13jan @karthikjeeyar I replace Karthiks lgtm with my approval so that you can update this on Monday without my additional review. But I will do it if needed.

I hope that's fine for you both. If you both agree that we can not apply my recommendation, Karthik can just re-add his lgtm. 😄

/lgtm cancel
/approve

@openshift-ci openshift-ci bot added approved Indicates a PR has been approved by an approver from all required OWNERS files. and removed lgtm Indicates that a PR is ready to be merged. labels Jan 8, 2022
@karthikjeeyar
Copy link
Contributor

@abhinandan13jan I agree with Christoph's concern, we should try avoid multiple calls for git detection. Please update the PR.

Thanks @jerolimov for the review and highlighting the issue with multiple network calls, which I overlooked. However I feel as reviewers we should not give lgtm / approve unless we are satisfied with the changes.

@karthikjeeyar
Copy link
Contributor

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jan 10, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 10, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: abhinandan13jan, jerolimov, karthikjeeyar

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-bot
Copy link
Contributor

/retest-required

Please review the full test history for this PR and help us cut down flakes.

2 similar comments
@openshift-bot
Copy link
Contributor

/retest-required

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest-required

Please review the full test history for this PR and help us cut down flakes.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 10, 2022

@abhinandan13jan: all tests passed!

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@openshift-merge-robot openshift-merge-robot merged commit 5e07d72 into openshift:master Jan 10, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 10, 2022

@abhinandan13jan: All pull requests linked via external trackers have merged:

Bugzilla bug 2021205 has been moved to the MODIFIED state.

In response to this:

Bug 2021205: fix git url change validation

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. bugzilla/severity-low Referenced Bugzilla bug's severity is low for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. component/dev-console Related to dev-console kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants