🏡 index : ~doyle/rgit.git

author Jordan Doyle <jordan@doyle.la> 2023-12-31 2:34:33.0 +00:00:00
committer Jordan Doyle <jordan@doyle.la> 2023-12-31 2:34:37.0 +00:00:00
commit
a5ba9bb12d3be1fa6c476ddade98878773ae61f0 [patch]
tree
da7388e4367601cd1555309e1c11a1165249bde6
parent
39bdc18d9982b21db2ca64e6173d495d37e793ed
download
a5ba9bb12d3be1fa6c476ddade98878773ae61f0.tar.gz

Fix cross-branch readme cache



Diff

 src/git.rs | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/git.rs b/src/git.rs
index bbb1263..b4842ac 100644
--- a/src/git.rs
+++ b/src/git.rs
@@ -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,
}

@@ -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();