Skip to content

Conversation

@everpcpc
Copy link
Member

Summary

This PR implements caching of git repository information in the session database to reduce repeated git command executions.

What changed:

  • Added 4 cache fields to session types: currentBranch, ownerRepo, isFork, originOwnerRepo
  • Created database migration to add these fields to the sessions table
  • Implemented fetchAndCacheRepoInfo() function to fetch and cache repo info on first access
  • Updated 3 IPC handlers to use cached data:
    • sessions:get-git-commands
    • sessions:get-remote-pull-request
    • sessions:get-pr-remote-commits

Why:
Previously, every call to these handlers would execute git commands to get branch and remote information. This PR caches this data in the session database after the first query, significantly reducing git command overhead.

Testing:

  • Added new test file gitCacheHandlers.test.ts with 4 tests covering cache hit/miss scenarios
  • Updated existing tests in gitHandlers.test.ts to work with the caching mechanism
  • All 50 tests pass (46 existing + 4 new)

Tests

  • Unit Test
  • Logic Test
  • Benchmark Test
  • No Test - Explain why

Type of change

  • Bug Fix (non-breaking change which fixes an issue)
  • New Feature (non-breaking change which adds functionality)
  • Breaking Change (fix or feature that could cause existing functionality not to work as expected)
  • Documentation Update
  • Refactoring
  • Performance Improvement
  • Other (please describe):

Store current branch, owner/repo, fork status, and origin owner/repo
in the session database. This reduces repeated git command executions
by caching repo information after the first query.

Updated IPC handlers (get-git-commands, get-remote-pull-request,
get-pr-remote-commits) to use cached data when available and fall
back to fetching when cache misses occur.
@everpcpc everpcpc marked this pull request as ready for review January 19, 2026 13:50
@everpcpc everpcpc merged commit a9c42f8 into databendlabs:main Jan 19, 2026
3 checks passed
@everpcpc everpcpc deleted the toronto-wng627md branch January 19, 2026 13:50
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.

1 participant