Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.2k
Refactor repository models (repository refactor part 1)#2008
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
80abca21177e93c6c8b84edb8232835e561fe2dcf8683ad5059e565201d2e467bab478e3f81142f13d62c61d0f2473fa4847430fd713d9c40f59f7e42d09faa47af2bdb41ef906d17e0a4c83862ce3e84File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| 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 ;)
| ||
| StatusChanged?.Invoke(this, EventArgs.Empty); | ||
| } | ||
| repositoryPath = newRepositoryPath; | ||
| cloneUrl = newCloneUrl; | ||
| branchName = newBranchName; | ||
| headSha = newHeadSha; | ||
| solutionPath = newSolutionPath; | ||
| trackedSha = newTrackedSha; | ||
| pullRequest = newPullRequest; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -32,7 +32,8 @@ public BranchModel(LibGit2Sharp.Branch branch, IRepositoryModel repo, IGitServic | ||
| Extensions.Guard.ArgumentNotNull(repo, nameof(repo)); | ||
| Name = DisplayName = branch.FriendlyName; | ||
| #pragma warning disable 0618 // TODO: Replace `Branch.Remote` with `Repository.Network.Remotes[branch.RemoteName]`. | ||
| Repository = branch.IsRemote ? new LocalRepositoryModel(branch.Remote.Url, gitService) : repo; | ||
| // NOTE: This method expects a localPath not a URL! | ||
| Repository = branch.IsRemote ? gitService.CreateLocalRepositoryModel(branch.Remote.Url) : repo; | ||
jcansdale marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| #pragma warning restore 0618 | ||
| IsTracking = branch.IsTracking; | ||
| Sha = branch.Tip?.Sha; | ||
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
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.