Skip to content

Fire source control hooks when creating/opening/editing/deleting projects #1313

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

Merged
merged 5 commits into from
Feb 22, 2024

Conversation

isc-bsaviano
Copy link
Contributor

This PR fixes #1312

I think this is the best I can do with "other" actions to approximate what happens when a file is opened via the Atelier GET /doc/ API. @gjsjohnmurray I'd really appreciate your review on this since since you're a server-side source control expert.

Copy link
Contributor

@gjsjohnmurray gjsjohnmurray left a comment

Choose a reason for hiding this comment

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

Looks good as code, with only one minor comment made. I haven't tested it but I think the person who raised the issue is better placed to do that.

@isc-bsaviano
Copy link
Contributor Author

Thanks for the review @gjsjohnmurray! I've added your suggestion as well as a few more changes.

gjsjohnmurray
gjsjohnmurray previously approved these changes Feb 14, 2024
Copy link
Contributor

@gjsjohnmurray gjsjohnmurray left a comment

Choose a reason for hiding this comment

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

LGTM but not tested

@trevorfstrong
Copy link

Hi @isc-bsaviano we have always wanted the exposure of the current project opened for the current document to be passed to VSC studio Source Control hooks. Sounds like this might do the trick.
How can we update the plugin to trial this with our studio hooks?

@isc-bsaviano
Copy link
Contributor Author

@trevorfstrong I just re-read your request and I think it may be unrelated to this PR. This PR fires OtherStudioActions for .PRJ files. Is that what you're asking for, or do you mean something else?

@trevorfstrong
Copy link

Specifically, what we do is ensure someone that is checking out a document on the server, e.g. CLS, INT has it associated with the studio (VSC) project currently opened. Then when they check in the file, our Source Control system utilizes that project to control workflow patterns. It may be a separate issue that you can't handle but this is the code in the hooks.
Set projName=$Select($system.Version.GetMajor()>"2008":$Get(^||%Studio.Project),$IsObject($Get(%Project)):%Project.Name,1:"")
Any variation to get at the value passed in the content would be appreciated. e.g. a pointer to the passed json content object as an optional extra assuming it could pass the current project.

@isc-bsaviano
Copy link
Contributor Author

@trevorfstrong Something like that is going to be very difficult to implement in VS Code. VS Code doesn't really "open" projects, it just treats them as a SQL table that defines a group of documents. Since users can have multiple projects "open" at once (via the multi-root workspace feature) and REST connections can go through a number of CSP jobs, there isn't a good way to persist that information on the server.

@trevorfstrong
Copy link

ok, but if you passed the project in this screenshot when you "access" a document that is linked to the project, we can persist it on the back end as the last project "touched" by vsc.
image

@isc-bsaviano
Copy link
Contributor Author

I understand. It would be possible to pass the project with the REST requests somehow and "open" it for the duration that the request is processed so any source control hooks see it. That would require a bunch of IRIS-side changes though. I would need to discuss that internally before drawing up a spec or committing to doing that work.

@trevorfstrong
Copy link

Thanks for your attention on this subject Brett.

@isc-bsaviano
Copy link
Contributor Author

Thanks for bringing this to my attention! I will add this to my notes for when we have a larger discussion about projects support in VS Code.

@isc-bsaviano isc-bsaviano merged commit 69c684e into intersystems-community:master Feb 22, 2024
@isc-bsaviano isc-bsaviano deleted the fix-1312 branch February 22, 2024 12:30
@trevorfstrong
Copy link

Hi Brett.
Looks like the firing of project actions in the latest code is always triggered before items for source control actions, so i believe i can work with that. No need for any further mods

@trevorfstrong
Copy link

Hi again.
When we have multiple projects associated with the workspace and we select a file that is in a specific project, you fire the src ctrl actions for all projects in the workspace then that selected file, but the projects are simply looped thru in the order they are presented in the workspace when fired, so is there any way the project src ctrl action that the current file selected is in be fired last? e.g. before the currently selected file?

@trevorfstrong
Copy link

image

@isc-bsaviano
Copy link
Contributor Author

@trevorfstrong I think that what we have now is the best I can do. Makign this work closer to Studio would require a major server change to support "opening"/"closing" projects on every request, or spamming the OpenedDocument Studio action which could adversely affect other people's hooks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fire source control hooks when creating/opening/editing/deleting projects
4 participants