Skip to content

Repository indicator optimizations, round two - #10588

Merged
niik merged 11 commits into
developmentfrom
repository-indicator-optimizations-take-two
Sep 18, 2020
Merged

niik merged 11 commits into
developmentfrom
repository-indicator-optimizations-take-two

Conversation

@niik

@niik niik commented Sep 16, 2020

Copy link
Copy Markdown
Member

Description

This is a follow-up to #10119 and a precursor to being able to disable background updates for repository indicators.

Prior to this PR the repository indicator updater would call AppStore.performFetch when fetching repositories. performFetch does a fair bit more work than just a fetch, such as a full repository refresh, branch protection updates, and branch fast forwards.

// manually refresh branch protections after the push, to ensure
// any new branch will immediately report as protected
await this.refreshBranchProtectionState(repository)
await this._refreshRepository(repository)
this.updatePushPullFetchProgress(repository, {
kind: 'generic',
title: refreshTitle,
description: 'Fast-forwarding branches',
value: fetchWeight + refreshWeight * 0.5,
})
await this.fastForwardBranches(repository)

Since all we need for the repository indicators is an ahead/behind status for the current branch (which we'll get from both status, and from running fetch) we can take a shortcut here. We're never run repository indicator refreshes on the currently selected repository and we'll run a full repository refresh when a repository is selected so we're not missing anything.

The second change here is about updating the repository indicator for a repository as soon as we get the results back from status instead of waiting for the fetch. That's just a nice little ux improvement.


private async withPushPullFetch(
repository: Repository,
account: IGitAccount | null,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I just stumbled upon the fact that this parameter was unused so I removed it which let me keep a newly introduced call to this method on one line. It's unrelated to this PR but it's small enough that I'm hoping we can just sneak it in.

account: IGitAccount | null
): Promise<void> {
return this.withPushPullFetch(repository, account, async () => {
return this.withPushPullFetch(repository, async () => {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Removes the unused account parameter. No logical difference

remotes?: IRemote[]
): Promise<void> {
await this.withPushPullFetch(repository, account, async () => {
await this.withPushPullFetch(repository, async () => {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Removes the unused account parameter. No logical difference

Comment on lines +952 to +959
} else {
this._aheadBehind = null
}
} else {
this._aheadBehind = null
}

this.emitUpdate()

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We haven't run into any problems with not resetting aheadBehind in fetch before since all fetches are followed by a status call which itself refreshes (and resets) the aheadBehind but now that we're running fetch stand-alone it makes sense for us to be more diligent here.

rafeca
rafeca previously approved these changes Sep 17, 2020

@rafeca rafeca left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

Comment thread app/src/lib/stores/app-store.ts Resolved
@niik
niik merged commit 1bb3f79 into development Sep 18, 2020
@niik
niik deleted the repository-indicator-optimizations-take-two branch September 18, 2020 09:27
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.

2 participants