This repository was archived by the owner on Jun 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Refactor repository models (repository refactor part 1) #2008
Closed
Closed
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
80abca2
Remove IGitService dependency from RepositoryModel
jcansdale 1177e93
Move LocalRepositoryModel ctor into GitService 1/2
jcansdale c6c8b84
Move LocalRepositoryModel ctor into GitService 2/2
jcansdale edb8232
Fix tests after LocalRepositoryModel refactor
jcansdale 835e561
Move GenerateUrl to LinkCommandBase
jcansdale fe2dcf8
Convert LocalRepositoryModel to GitService tests
jcansdale 683ad50
Move LocalReposotoryModel.Refresh to GitService
jcansdale 59e5652
Remove LocalRepositoryModel.HeadSha property
jcansdale 01d2e46
Remove CreateLocalRepositoryModel overload
jcansdale 7bab478
Read the current branch when model is created
jcansdale e3f8114
Clean up LocalRepositoryModel
jcansdale 2f13d62
ClonePath -> CloneUri
jcansdale c61d0f2
Make GitService.Refresh the CurrentBranch
jcansdale 473fa48
Merge branch 'master' into fixes/2007-refactor-repository-models
jcansdale 47430fd
Add workaround for out of date CurrentBranch issue
jcansdale 713d9c4
Refactor to IGitService.CreateCurrentBranchModel
jcansdale 0f59f7e
Make GetPullRequestForCurrentBranch return (tuple)
jcansdale 42d09fa
Avoid firing StatusChanged if we're not on a repo
jcansdale a47af2b
Suppress "Do not directly await a Task" warning
jcansdale db41ef9
Get rid of LocalRepositoryModelFactory
jcansdale 06d17e0
Merge branch 'master' into fixes/2007-refactor-repository-models
jcansdale a4c8386
Rename IGitService.Refresh to RefreshCloneUrl
jcansdale 2ce3e84
Merge branch 'master' into fixes/2007-refactor-repository-models
grokys File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,10 +40,7 @@ public class TeamExplorerContext : ITeamExplorerContext | |
| string solutionPath; | ||
| string repositoryPath; | ||
| UriString cloneUrl; | ||
| string branchName; | ||
| string headSha; | ||
| string trackedSha; | ||
| Tuple<string, int> pullRequest; | ||
| (string owner, int number) pullRequest; | ||
|
|
||
| ILocalRepositoryModel repositoryModel; | ||
| JoinableTask refreshJoinableTask; | ||
|
|
@@ -113,10 +110,7 @@ async Task RefreshAsync() | |
| { | ||
| var newRepositoryPath = repo?.LocalPath; | ||
| var newCloneUrl = repo?.CloneUrl; | ||
| var newBranchName = repo?.CurrentBranch?.Name; | ||
| var newHeadSha = repo?.CurrentBranch?.Sha; | ||
| var newTrackedSha = repo?.CurrentBranch?.TrackedSha; | ||
| var newPullRequest = repo != null ? await pullRequestService.GetPullRequestForCurrentBranch(repo) : null; | ||
| var newPullRequest = repo != null ? await pullRequestService.GetPullRequestForCurrentBranch(repo) : default; | ||
|
|
||
| if (newRepositoryPath != repositoryPath) | ||
| { | ||
|
|
@@ -128,33 +122,20 @@ async Task RefreshAsync() | |
| log.Debug("ActiveRepository changed to {CloneUrl} @ {Path}", repo?.CloneUrl, newRepositoryPath); | ||
| ActiveRepository = repo; | ||
| } | ||
| else if (newBranchName != branchName) | ||
| { | ||
| log.Debug("Fire StatusChanged event when BranchName changes for ActiveRepository"); | ||
| StatusChanged?.Invoke(this, EventArgs.Empty); | ||
| } | ||
| else if (newHeadSha != headSha) | ||
| { | ||
| log.Debug("Fire StatusChanged event when HeadSha changes for ActiveRepository"); | ||
| StatusChanged?.Invoke(this, EventArgs.Empty); | ||
| } | ||
| else if (newTrackedSha != trackedSha) | ||
| else if (newPullRequest != pullRequest) | ||
| { | ||
| log.Debug("Fire StatusChanged event when TrackedSha changes for ActiveRepository"); | ||
| log.Debug("Fire StatusChanged event when PullRequest changes for ActiveRepository"); | ||
| StatusChanged?.Invoke(this, EventArgs.Empty); | ||
| } | ||
| else if (newPullRequest != pullRequest) | ||
| else if (newRepositoryPath != null) | ||
| { | ||
| log.Debug("Fire StatusChanged event when PullRequest changes for ActiveRepository"); | ||
| log.Debug("Fire StatusChanged event when on a repository and anything changes"); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reads a bit yoda-y ;)
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if that's a feature? 😉 I'll change it to: |
||
| StatusChanged?.Invoke(this, EventArgs.Empty); | ||
| } | ||
|
|
||
| repositoryPath = newRepositoryPath; | ||
| cloneUrl = newCloneUrl; | ||
| branchName = newBranchName; | ||
| headSha = newHeadSha; | ||
| solutionPath = newSolutionPath; | ||
| trackedSha = newTrackedSha; | ||
| pullRequest = newPullRequest; | ||
| } | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 StatusChanged is no longer firing when HEAD changes? Is this because it wasn't working before anyway? (i.e. it was firing before the actual change)
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.
Now either a repository change event will be fired when we set
ActiveRepositoryor aStatusChangedwill be fired if we think anything about the active repository might have changed (including when theHEADchanged).This is actually similar to what was happening before because
newPullRequest != pullRequestwas always returningtrue(the tuple comparison issue).I have changed it so that if we're not on a repository, no
StatusChangedevent will fire.