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

VSC Compare function, not working with Favorites from Zowe Explorer #2522

Conversation

SanthoshiBoyina
Copy link
Contributor

@SanthoshiBoyina SanthoshiBoyina commented Oct 18, 2023

Proposed changes

The feature of Visual Studio Code to compare 2 files, if the file on the mainframe has changed in the meantime, doesn't work if you open a Member under Favorites. It overrides the file automatically. In this bug fix, we are able to trigger Compare function when ETAGs are mismatched.

Release Notes

Milestone:

Changelog:

Types of changes

What types of changes does your code introduce to Zowe Explorer?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Updates to Documentation or Tests (if none of the other choices apply)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This checklist will be used as reference for both the contributor and the reviewer

  • I have read the CONTRIBUTOR GUIDANCE wiki
  • PR title follows Conventional Commits Guidelines
  • PR Description is included
  • gif or screenshot is included if visual changes are made
  • yarn workspace vscode-extension-for-zowe vscode:prepublish has been executed
  • All checks have passed (DCO, Jenkins and Code Coverage)
  • I have added unit test and it is passing
  • I have added integration test and it is passing
  • There is coverage for the code that I have added
  • I have tested it manually and there are no regressions found
  • I have added necessary documentation (if appropriate)
  • Any PR dependencies have been merged and published (if appropriate)

Further comments

@codecov
Copy link

codecov bot commented Oct 18, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!.

@rudyflores
Copy link
Contributor

Is this for 2.12.0? @JillieBeanSim @SanthoshiBoyina

@SanthoshiBoyina SanthoshiBoyina changed the title updated with bug fix VSC Compare function, not working with Favorites from Zowe Explorer Oct 18, 2023
@JillieBeanSim
Copy link
Contributor

Is this for 2.12.0? @JillieBeanSim @SanthoshiBoyina

I am not opposed to it being included if the tests are fixed and the coverage is good in time, not seeing the coverage report yet with failing tests

Copy link
Contributor

@JillieBeanSim JillieBeanSim left a comment

Choose a reason for hiding this comment

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

I am seeing the diff editor open then when trying to save that I get the pop up to compare, I would assume one or the other happen but not both and the second right behind the first encounter.

Copy link
Member

@traeok traeok left a comment

Choose a reason for hiding this comment

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

Thanks for working on this bug fix @SanthoshiBoyina!

I'm running into the same situation as @JillieBeanSim - the side-by-side diff appears, but the dialog with Compare/Overwrite does not. However, this occurs for non-favorited nodes as well. I think this is because calls to willForceUpload (in src/shared/utils.ts) were removed with a previous PR, and this function was responsible for showing the dialog:

Gui.infoMessage(localize("saveFile.info.confirmUpload", "Would you like to overwrite the remote file?"), {
        items: [localize("saveFile.overwriteConfirmation.yes", "Yes"), localize("saveFile.overwriteConfirmation.no", "No")],
    })

(lines 284-286 in the mentioned file)

I'm wondering if we still want to use this willForceUpload function somewhere? As a quick solution, if we add a similar dialog to the compareFileContent function in src/shared/utils.ts, or if we show a dialog before calling compareFileContent, it should fix the issue.

@JillieBeanSim
Copy link
Contributor

I don't think we should be forceUploading anything unless the decision came from user.

@traeok
Copy link
Member

traeok commented Oct 23, 2023

I don't think we should be forceUploading anything unless the decision came from user.

@JillieBeanSim I agree. My comment was mostly to bring awareness that the "conflict prompt" (showed before the diff) is no longer there. We used to call this willForceUpload function (mentioned above) that contained a similar dialog, but this call was removed at some point in the past and now we do not show a dialog at all when a conflict occurs. This is a regression introduced with a previous release, since we used to show a dialog, but it is not a result of the work on this PR. This could always be added to the repo as a separate issue for a future PR to solve.

Update: this dialog is the dialog I was referring to, sorry for the confusion. It was removed sometime between 2.8 and 2.9.

@JillieBeanSim
Copy link
Contributor

ok, if we had a regression maybe the popup can be added/moved to the shared.utils.compareFileContent() method. this will cut down on introducing duplicate code to bring it back in other cases and fix the duplication here in this PR

@SanthoshiBoyina
Copy link
Contributor Author

I am seeing the diff editor open then when trying to save that I get the pop up to compare, I would assume one or the other happen but not both and the second right behind the first encounter.

VS Code has a built-in mechanism to show a notification when you try to save a dirty file that has been changed outside of VS Code or by another program
save-conflict
In order not to make this built-in vs code notification pop up, In the setting we need to configure files.saveConflictResolution to overwriteFileOnDisk option from the default askUser option.

@traeok
Copy link
Member

traeok commented Oct 27, 2023

I am seeing the diff editor open then when trying to save that I get the pop up to compare, I would assume one or the other happen but not both and the second right behind the first encounter.

VS Code has a built-in mechanism to show a notification when you try to save a dirty file that has been changed outside of VS Code or by another program save-conflict In order not to make this built-in vs code notification pop up, In the setting we need to configure files.saveConflictResolution to overwriteFileOnDisk option from the default askUser option.

@SanthoshiBoyina

I'm not sure if we should override this option during that process, as it might interfere with other local files that the user is editing within VS Code. Unfortunately, we are unable to use VS Code's built-in conflict management directly with a remote system such as an LPAR.

Currently, data sets and USS file contents are written to temp. files, so VS Code has no way of checking whether the document has a different e-tag than the mainframe. It calculates an e-tag for the temp. file on disk, but it's different from the one that the mainframe generates, so we have to handle the remote save separately from the temp. file. Until we switch to something like a FileSystemProvider (#2207), we can only check to see if conflict resolution is needed after saving the temp file. If there is a conflict, we un-save the temp. file and then present a similar dialog to VS Code's.

@rudyflores
Copy link
Contributor

rudyflores commented Oct 31, 2023

Seems like the issue here with the compare editor not showing is because the node being passed into compareFileContent is a directory, can see that the error that shows in the debug console when trying to click on Compare mentions that a directory was entered too, this happens right when node.getUSSDocumentFilePath() is called in line 377 of utils.ts

image

@rudyflores rudyflores modified the milestones: v2.12.0, v2.13.0 Nov 1, 2023
@JillieBeanSim JillieBeanSim modified the milestones: v2.13.0, v2.12.1 Nov 2, 2023
@SanthoshiBoyina SanthoshiBoyina self-assigned this Nov 3, 2023
Signed-off-by: Santhoshi Boyina <[email protected]>
Signed-off-by: Santhoshi Boyina <[email protected]>
Signed-off-by: Santhoshi Boyina <[email protected]>
@SanthoshiBoyina SanthoshiBoyina force-pushed the etag-mismatch-not-triggering-compare branch from 3451334 to aba4048 Compare November 3, 2023 15:40
Copy link

sonarcloud bot commented Nov 3, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
8.8% 8.8% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

@SanthoshiBoyina SanthoshiBoyina changed the base branch from main to merging/main-2.12.0 November 3, 2023 17:17
@JillieBeanSim JillieBeanSim deleted the branch zowe:merging/main-2.12.0 November 6, 2023 16:48
@JillieBeanSim JillieBeanSim removed this from the v2.12.1 milestone Nov 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Closed
Development

Successfully merging this pull request may close these issues.

5 participants