File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -479,6 +479,12 @@ export class RepositoriesStore extends TypedBaseStore<
479479 repository : Repository ,
480480 date : number = Date . now ( )
481481 ) : Promise < void > {
482+ // Synthetic sidebar-only worktree rows are transient repositories that
483+ // are not persisted in the repositories store.
484+ if ( repository . id < 0 ) {
485+ return
486+ }
487+
482488 await this . db . repositories . update ( repository . id , {
483489 lastStashCheckDate : date ,
484490 } )
@@ -496,6 +502,12 @@ export class RepositoriesStore extends TypedBaseStore<
496502 public async getLastStashCheckDate (
497503 repository : Repository
498504 ) : Promise < number | null > {
505+ // Synthetic sidebar-only worktree rows are transient repositories that
506+ // are not persisted in the repositories store.
507+ if ( repository . id < 0 ) {
508+ return null
509+ }
510+
499511 let lastCheckDate = this . lastStashCheckCache . get ( repository . id ) || null
500512 if ( lastCheckDate !== null ) {
501513 return lastCheckDate
Original file line number Diff line number Diff line change @@ -3,7 +3,11 @@ import assert from 'node:assert'
33import { RepositoriesStore } from '../../src/lib/stores/repositories-store'
44import { TestRepositoriesDatabase } from '../helpers/databases'
55import { IAPIFullRepository , getDotComAPIEndpoint } from '../../src/lib/api'
6- import { assertIsRepositoryWithGitHubRepository } from '../../src/models/repository'
6+ import {
7+ assertIsRepositoryWithGitHubRepository ,
8+ Repository ,
9+ } from '../../src/models/repository'
10+ import { gitHubRepoFixture } from '../helpers/github-repo-builder'
711
812describe ( 'RepositoriesStore' , ( ) => {
913 let repoDb = new TestRepositoriesDatabase ( )
@@ -97,4 +101,22 @@ describe('RepositoriesStore', () => {
97101 )
98102 } )
99103 } )
104+
105+ describe ( 'stash check tracking' , ( ) => {
106+ it ( 'ignores transient synthetic repositories' , async ( ) => {
107+ const syntheticRepo = new Repository (
108+ '/tmp/repo-feature-a' ,
109+ - 1 ,
110+ gitHubRepoFixture ( { owner : 'example' , name : 'repo' } ) ,
111+ false
112+ )
113+
114+ assert . equal (
115+ await repositoriesStore . getLastStashCheckDate ( syntheticRepo ) ,
116+ null
117+ )
118+
119+ await repositoriesStore . updateLastStashCheckDate ( syntheticRepo )
120+ } )
121+ } )
100122} )
You can’t perform that action at this time.
0 commit comments