Skip to content

whenever we refresh the history view, update the list of local-only commits - #3712

Merged
iAmWillShepherd merged 3 commits into
masterfrom
refresh-local-commits
Jan 9, 2018
Merged

iAmWillShepherd merged 3 commits into
masterfrom
refresh-local-commits

Conversation

@shiftkey

@shiftkey shiftkey commented Jan 1, 2018

Copy link
Copy Markdown
Member

Fixes #3698

The internal state of Desktop uses a list of SHAs to represent the commits on the current branch which are local-only. These are computed in GitStore:

    let localCommits: ReadonlyArray<Commit> | undefined
    if (branch.upstream) {
      const revRange = `${branch.upstream}..${branch.name}`
      localCommits = await this.performFailableOperation(() =>
        getCommits(this.repository, revRange, CommitBatchSize)
      )
    } else {
      localCommits = await this.performFailableOperation(() =>
        getCommits(this.repository, 'HEAD', CommitBatchSize, [
          '--not',
          '--remotes',
        ])
      )
    }

These then flow through props as a list to be computed inside CommitList:

    const isLocal = this.props.localCommitSHAs.indexOf(commit.sha) > -1

    return (
      <CommitListItem
        key={commit.sha}
        gitHubRepository={this.props.repository.gitHubRepository}
        isLocal={isLocal}
        commit={commit}
        user={avatarUser}
        emoji={this.props.emoji}
        onRevertCommit={this.props.onRevertCommit}
        onViewCommitOnGitHub={this.props.onViewCommitOnGitHub}
      />
    )

We already have a function that gets called whenever the History tab needs to be refreshed, so let's just add this additional work into there.

@shiftkey shiftkey added the ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Jan 1, 2018
@iAmWillShepherd iAmWillShepherd self-assigned this Jan 8, 2018

@iAmWillShepherd iAmWillShepherd 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.

I only had some minor code suggestions, none of which I'm married to.

Comment thread app/src/lib/stores/app-store.ts Outdated
const gitStore = this.getGitStore(repository)
const state = this.getRepositoryState(repository)

if (state.branchesState.tip.kind === TipState.Valid) {

This comment was marked as spam.

Comment thread app/src/lib/stores/app-store.ts Outdated

if (state.branchesState.tip.kind === TipState.Valid) {
const currentBranch = state.branchesState.tip.branch
await gitStore.loadLocalCommits(currentBranch)

This comment was marked as spam.

@shiftkey

shiftkey commented Jan 9, 2018

Copy link
Copy Markdown
Member Author

🍎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-review Pull Requests that are ready to be reviewed by the maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants