Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
renovate
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GitHub Mirror
Renovate Bot
renovate
Commits
9e2c81f0
Unverified
Commit
9e2c81f0
authored
2 years ago
by
Sergei Zharinov
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
refactor(cache): Explicit types for different cache revisions (#17362)
parent
8f8f059d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/util/cache/repository/common.ts
+8
-4
8 additions, 4 deletions
lib/util/cache/repository/common.ts
lib/util/cache/repository/types.ts
+14
-1
14 additions, 1 deletion
lib/util/cache/repository/types.ts
with
22 additions
and
5 deletions
lib/util/cache/repository/common.ts
+
8
−
4
View file @
9e2c81f0
import
is
from
'
@sindresorhus/is
'
;
import
is
from
'
@sindresorhus/is
'
;
import
type
{
RepoCacheData
,
RepoCacheRecord
}
from
'
./types
'
;
import
type
{
RepoCacheRecordV10
,
RepoCacheRecordV11
,
RepoCacheRecordV12
,
}
from
'
./types
'
;
// Increment this whenever there could be incompatibilities between old and new cache structure
// Increment this whenever there could be incompatibilities between old and new cache structure
export
const
CACHE_REVISION
=
12
;
export
const
CACHE_REVISION
=
12
;
...
@@ -7,7 +11,7 @@ export const CACHE_REVISION = 12;
...
@@ -7,7 +11,7 @@ export const CACHE_REVISION = 12;
export
function
isValidRev10
(
export
function
isValidRev10
(
input
:
unknown
,
input
:
unknown
,
repo
?:
string
repo
?:
string
):
input
is
RepoCache
Data
&
{
repository
?:
string
;
revision
?:
number
}
{
):
input
is
RepoCache
RecordV10
{
return
(
return
(
is
.
plainObject
(
input
)
&&
is
.
plainObject
(
input
)
&&
is
.
safeInteger
(
input
.
revision
)
&&
is
.
safeInteger
(
input
.
revision
)
&&
...
@@ -20,7 +24,7 @@ export function isValidRev10(
...
@@ -20,7 +24,7 @@ export function isValidRev10(
export
function
isValidRev11
(
export
function
isValidRev11
(
input
:
unknown
,
input
:
unknown
,
repo
?:
string
repo
?:
string
):
input
is
{
repository
:
string
;
revision
:
number
;
data
:
RepoCacheData
}
{
):
input
is
RepoCacheRecordV11
{
return
(
return
(
is
.
plainObject
(
input
)
&&
is
.
plainObject
(
input
)
&&
is
.
safeInteger
(
input
.
revision
)
&&
is
.
safeInteger
(
input
.
revision
)
&&
...
@@ -34,7 +38,7 @@ export function isValidRev11(
...
@@ -34,7 +38,7 @@ export function isValidRev11(
export
function
isValidRev12
(
export
function
isValidRev12
(
input
:
unknown
,
input
:
unknown
,
repo
?:
string
repo
?:
string
):
input
is
RepoCacheRecord
{
):
input
is
RepoCacheRecord
V12
{
return
(
return
(
is
.
plainObject
(
input
)
&&
is
.
plainObject
(
input
)
&&
is
.
safeInteger
(
input
.
revision
)
&&
is
.
safeInteger
(
input
.
revision
)
&&
...
...
This diff is collapsed.
Click to expand it.
lib/util/cache/repository/types.ts
+
14
−
1
View file @
9e2c81f0
...
@@ -47,13 +47,26 @@ export interface RepoCacheData {
...
@@ -47,13 +47,26 @@ export interface RepoCacheData {
prComments
?:
Record
<
number
,
Record
<
string
,
string
>>
;
prComments
?:
Record
<
number
,
Record
<
string
,
string
>>
;
}
}
export
interface
RepoCacheRecord
{
export
interface
RepoCacheRecordV10
extends
RepoCacheData
{
repository
?:
string
;
revision
?:
number
;
}
export
interface
RepoCacheRecordV11
{
repository
:
string
;
revision
:
number
;
data
:
RepoCacheData
;
}
export
interface
RepoCacheRecordV12
{
repository
:
string
;
repository
:
string
;
revision
:
number
;
revision
:
number
;
payload
:
string
;
payload
:
string
;
hash
:
string
;
hash
:
string
;
}
}
export
type
RepoCacheRecord
=
RepoCacheRecordV12
;
export
interface
RepoCache
{
export
interface
RepoCache
{
load
():
Promise
<
void
>
;
load
():
Promise
<
void
>
;
save
():
Promise
<
void
>
;
save
():
Promise
<
void
>
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment