Skip to content

Fix commits missing in History tab - #12553

Merged
sergiou87 merged 4 commits into
developmentfrom
fix-commits-missing
Jul 19, 2021
Merged

sergiou87 merged 4 commits into
developmentfrom
fix-commits-missing

Conversation

@sergiou87

Copy link
Copy Markdown
Member

Closes #12506
Closes #3704

Description

I think #12506 (comment) gives good context about the reason behind this bug. Luckily, git has a --skip parameter, so with the changes in this PR, when we need to load a new page of commits, we'll run git log from HEAD and skip the X first commits.

In order to test this, you can create a repository with two branches alternating commits between two branches and finally merging them, using this script:

mkdir test-repo
cd test-repo
git init

git checkout -b main
echo "initial file" > 0
git add 0
git commit -m "initial commit"

git checkout -b sub

for F in {1..300}; do
  echo "hello $F" > $F

  # if F is even, then commit from main
  if [ $((F%2)) -eq 0 ]; then
    git checkout main
    git add $F
    git commit -m "commit $F"
  else
    # if F is odd, then commit from sub
    git checkout sub
    git add $F
    git commit -m "commit $F"
  fi
done

git checkout main
git merge sub

Screenshots

Without the fix, after the second page is loaded, you only see commits from one of the branches (either odd or even numbers in the test repo):

Screen.Recording.2021-07-02.at.12.14.11.mov

With the fix, you always see both odd and even numbers:

Screen.Recording.2021-07-02.at.12.15.16.mov

Release notes

Notes: [Fixed] History tab shows all commits as the user scrolls down

Comment on lines -204 to -234
/** Load the next batch of history, starting from the last loaded commit. */
public async loadNextHistoryBatch() {
if (this.requestsInFight.has(LoadingHistoryRequestKey)) {
return
}

if (!this.history.length) {
return
}

const lastSHA = this.history[this.history.length - 1]
const requestKey = `history/${lastSHA}`
if (this.requestsInFight.has(requestKey)) {
return
}

this.requestsInFight.add(requestKey)

const commits = await this.performFailableOperation(() =>
getCommits(this.repository, `${lastSHA}^`, CommitBatchSize)
)
if (!commits) {
return
}

this._history = this._history.concat(commits.map(c => c.sha))
this.storeCommits(commits)
this.requestsInFight.delete(requestKey)
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.

This wasn't used at all anymore 😅

@tidy-dev tidy-dev 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.

✨ Tested it out. Works great! Awesome debugging to figure that one out. The never ending joy of merge commits. 😸

gitMerge

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

Amazing job finding the culprit @sergiou87! ✨

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.

Commit missing in history view a commit disappears from change history of a branch

3 participants