Skip to content

Commit

Permalink
Fix cross-branch readme cache
Browse files Browse the repository at this point in the history
  • Loading branch information
w4 committed Dec 31, 2023
1 parent 39bdc18 commit a5ba9bb
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ use tracing::instrument;

use crate::syntax_highlight::ComrakSyntectAdapter;

type ReadmeCacheKey = (PathBuf, Option<Arc<str>>);

pub struct Git {
commits: Cache<Oid, Arc<Commit>>,
readme_cache: Cache<PathBuf, Option<(ReadmeFormat, Arc<str>)>>,
readme_cache: Cache<ReadmeCacheKey, Option<(ReadmeFormat, Arc<str>)>>,
syntax_set: SyntaxSet,
}

Expand Down Expand Up @@ -220,7 +222,7 @@ impl OpenRepository {
let git = self.git.clone();

git.readme_cache
.try_get_with(self.cache_key.clone(), async move {
.try_get_with((self.cache_key.clone(), self.branch.clone()), async move {
tokio::task::spawn_blocking(move || {
let repo = self.repo.lock();

Expand Down

0 comments on commit a5ba9bb

Please sign in to comment.