Community.VisualStudio.Toolkit icon indicating copy to clipboard operation
Community.VisualStudio.Toolkit copied to clipboard

Question: Is there any service that i can get somehow for accessing SourceControl?

Open CorsairRO opened this issue 4 years ago • 4 comments

Hello,

First of all thank you very much for the nice lib that you are developing here. It is really a great tooling tool.

However i have a question. Is there any way for the VS to get somehow a service or is it easy for me to plug in such thing for accessing the SourceControl.

I am using the tool in some extensions where i generate some code files. The project is on Azure DevOps using TFS Source Control At regeneration, if the files are there, i dont want to have to seect all, then checkout all, then run my tool, then checkin 200 files back when in reality it changed only 1.

Something similar to EnvDTE.DTE.SourceControl ?

Thank you very much for the answer and for the tool that you develop/maintain keep up the good work have a nice day

CorsairRO avatar Jan 12 '22 15:01 CorsairRO

I think you can do it this way. If it works for you, let's add it to the toolkit. I don't have a TFS instance to code against, so can't test this myself

var textMgr = await VS.GetServiceAsync<SVsTextManager, IVsTextManager>();

// Check if file needs to be checked out
textMgr.GetBufferSccStatus2(filename, out int nonEditable, out int statusFlags);

//If so, check out the file
textMgr.AttemptToCheckOutBufferFromScc2(filename, out int checkoutSucceeded, out int statusFlags);

madskristensen avatar Jan 12 '22 19:01 madskristensen

Thank you for your reply.

I will try to see if it works, as i am definitively using TFS since more than 15 Yrs now and i cannot use something else even if i tried lots of other source control solutions. Unfortunately only TFS gives me the Exclusive Checkout which is what i am interested in

I will let you know if this works, thank you again.

Adding it to the toolkit: I dont know where and how to add it. If you let me know a bit of where it should be put, i can help with it. Otherwise if it is simpler, you just add it

I will let you know how it is working really soon. Thank you again for the reply and for the tool.

CorsairRO avatar Jan 13 '22 17:01 CorsairRO

You don't have to add it, just post the code that works for you here, and I can add it

madskristensen avatar Jan 13 '22 17:01 madskristensen

Have not looked at all the details above, but wanted to add a note about possibly including a helper to also check if files were already checked out (and by who) if possible.

shaggygi avatar Feb 16 '22 03:02 shaggygi