-
Notifications
You must be signed in to change notification settings - Fork 447
Initial extension integration with Tfvc support #69
Conversation
Abstract GitContext into IRepositoryContext (to support TfvcContext) Guard Git-specific functionality Add TfvcContext Add RepositoryContextFactory Add TFVC-specific call to get the current Build status Add CoreApiClient (and service) to get TeamProject and ProjectCollection information Add RepositoryInfoClient which utilizes CoreApiClient (to validate Tfvc urls) Add new integration test environment variable, MSVSTS_TEAM_REMOTE_TFVC_REPOSITORY_URL TODOs: Team project currently hard-coded Exceptions need to be handled (e.g., missing tools, missing workspace, no team project, etc.).
} | ||
} | ||
if (matchingBuild) { | ||
return { buildId: matchingBuild.id, imageUrl: undefined }; |
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.
Is it important to set the imageUrl here? Just checking. Maybe a comment as to why we are leaving it empty?
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 don't actually ever use it (even before this change). It's the URL to an SVG that renders the badge (the image on the build page). I can add a comment.
return undefined; //not what we expected (which is a tfvc team services repo) | ||
} | ||
} else { | ||
//TODO: on-prem TFS...?! |
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 this mean we don't handle OnPrem servers right now?
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.
Correct. This is the first PR for the basic integration (and I used a Team Services repository for that). On-Prem will be forthcoming.
repository: { | ||
id: "00000000-0000-0000-0000-000000000000", | ||
name: "NoNameTfvcRepository", | ||
url: "http://xplatalm.visualstudio.com/repository-url-does-not-exist", |
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.
Can the repository.url be the server url as well?
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.
Absolutely.
//RepositoryInfo uses repository.remoteUrl to set up accountUrl | ||
private getTfvcRepoInfoBlob(serverUrl: string, collectionId: string, collectionName: string, collectionUrl: string, | ||
projectId: string, projectName: string, projectDesc: string, projectUrl: string): any { | ||
//TODO: Not sure if remoteUrl should always be the same as serverUrl...? |
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.
Seems fine to me. We shouldn't be using the remote URL for TFVC stuff any way.
if (err.errorCode === "404") { //check this!! | ||
return false; | ||
} else { | ||
throw err; //check this!! |
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.
So, I assume here this is an unexpected err, so you are throwing. 404 is the only expected error. That seems appropriate, but I would have to check the IntelliJ code to verify. Does the caller above expect this to throw? You may need to add a comment like the others that throw.
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.
First, I should have added a TODO to 'check this!!' which flags it for me to come back and run through this code in an e2e scenario. I'll do that (I typically ensure I have no TODOs left when I complete a User Story). For reference, here's the code I was referencing.
//call will also return the teamProject name for us. | ||
try { | ||
const tfvc: Tfvc = new Tfvc(); | ||
const repo: Repository = tfvc.Open(this._tfvcFolder); |
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.
Perhaps this is the place to cache the repository object. If we are keeping this context until the next "Reinitialize" then it would be simple to keep the TFVC repository object here as well. Just means that we have to pass this context around to anything that needs the repository.
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.
Yeah, we should consider. I think we should create a few more commands and re-visit. Once we have a few more commands, I hope it'll be clearer where we should be doing it. Plus, we need to consider passing the credentials to the Tfvc commands.
this._tfvcRemoteUrl = tfvcWorkspace.server; // "https://xplatalm.visualstudio.com/defaultcollection/"; //This comes from workfold | ||
this._isTeamServicesUrl = RepoUtils.IsTeamFoundationServicesRepo(this._tfvcRemoteUrl); // true; | ||
this._isTeamFoundationServer = RepoUtils.IsTeamFoundationServerRepo(this._tfvcRemoteUrl); //TODO: Not sure I want to do this here; // false; | ||
this._teamProjectName = "L2.VSCodeExtension"; |
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.
Hard coded string - I know why :) but you may want to add a comment to fix this.
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.
Done
public static IsTeamFoundationServerRepo(url: string): boolean { | ||
if (RepoUtils.IsTeamFoundationGitRepo(url) && !RepoUtils.IsTeamFoundationServicesRepo(url)) { | ||
if (!RepoUtils.IsTeamFoundationServicesRepo(url)) { |
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.
This doesn't seem correct anymore. Can we really say that an URL is an OnPrem url just because it isn't a VSTS URL? Perhaps we should rename the method to "IsPossiblyTeamFoundationServerRepo". But I may be missing something. I know you check the URL by calling the server, so this may not matter.
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.
At this iteration, I assume that the url that I'm checking has already been verified as a valid url. That said, I haven't gotten to the "possibly" scenario yet (which I believe is multiple collections). Right now, the code will do a Team Services repository and, presumably, a "possibly" scenario is for on-prem. Once I get to doing on-prem scenarios, I expect this to become clearer.
this._gitClient.OpenFileHistory(this._gitContext); | ||
if (this._gitClient) { | ||
this._gitClient.OpenFileHistory(this._repoContext); | ||
} |
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.
Seems like there should be an "else" on these commands that tells the user that we detected that this was not a git repository or something like that.
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 took a note for this. It may make sense to indicate the type of repo a particular command applies to.
|| !this._serverContext | ||
|| !this._serverContext.RepoInfo.IsTeamFoundation) { | ||
this.setErrorStatus(Strings.NoGitRepoInformation); | ||
this.setErrorStatus(Strings.NoRepoInformation); | ||
return false; |
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.
Maybe check for the "expected repo type" here and have it passed in from the command. Just a thought.
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 took a note for this. It may make sense to indicate the type of repo a particular command applies to.
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.
Some minor comments, but overall the changes look good!
Abstract GitContext into IRepositoryContext (to support TfvcContext)
Guard Git-specific functionality
Add TfvcContext
Add RepositoryContextFactory
Add TFVC-specific call to get the current Build status
Add CoreApiClient (and service) to get TeamProject and ProjectCollection information
Add RepositoryInfoClient which utilizes CoreApiClient (to validate Tfvc urls)
Add new integration test environment variable, MSVSTS_TEAM_REMOTE_TFVC_REPOSITORY_URL
TODOs:
Team project currently hard-coded
Exceptions need to be handled (e.g., missing tools, missing workspace, no team project, etc.).