Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
J
jsdelivr-uploader
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
jsdelivr-uploader
Commits
5b1da499
Commit
5b1da499
authored
Sep 08, 2021
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix checkout
parent
5b7c8ea7
Pipeline
#5446
passed with stages
in 8 minutes and 38 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
5 deletions
+14
-5
src/app.service.ts
src/app.service.ts
+14
-5
No files found.
src/app.service.ts
View file @
5b1da499
...
...
@@ -161,12 +161,20 @@ export class AppService extends ConsoleLogger {
async
checkoutCorrectBranch
(
forceNew
?:
boolean
,
fetch
?:
boolean
,
newBranchOffset
=
1
,
):
Promise
<
{
branchId
:
number
;
size
:
number
}
>
{
const
res
=
await
this
.
getLatestBranchId
(
forceNew
);
const
res
=
await
this
.
getLatestBranchId
(
forceNew
,
newBranchOffset
);
const
branchName
=
res
.
branchId
.
toString
(
36
);
if
(
!
res
.
size
)
{
this
.
log
(
`Checking out to a new branch
${
branchName
}
`
);
await
this
.
git
.
checkout
([
'
--orphan
'
,
branchName
]);
try
{
await
this
.
git
.
checkout
([
'
--orphan
'
,
branchName
]);
}
catch
(
e
)
{
this
.
error
(
`Failed checking out to new branch
${
branchName
}
, would retry with another branch:
${
e
.
toString
()}
`
,
);
return
this
.
checkoutCorrectBranch
(
true
,
fetch
,
newBranchOffset
+
1
)
}
try
{
await
this
.
git
.
raw
([
'
rm
'
,
'
-rf
'
,
'
.
'
]);
}
catch
(
e
)
{}
...
...
@@ -194,6 +202,7 @@ export class AppService extends ConsoleLogger {
async
getLatestBranchId
(
forceNew
?:
boolean
,
newBranchOffset
=
1
,
):
Promise
<
{
branchId
:
number
;
size
:
number
}
>
{
const
[
latestFile
]
=
await
this
.
dbRepo
.
find
({
select
:
[
'
branchId
'
],
...
...
@@ -201,11 +210,11 @@ export class AppService extends ConsoleLogger {
take
:
1
,
});
if
(
!
latestFile
)
{
return
{
branchId
:
1
,
size
:
0
};
return
{
branchId
:
newBranchOffset
,
size
:
0
};
}
const
branchId
=
parseInt
(
latestFile
.
branchIdValue
.
toString
());
if
(
forceNew
)
{
return
{
branchId
:
branchId
+
1
,
size
:
0
};
return
{
branchId
:
branchId
+
newBranchOffset
,
size
:
0
};
}
const
{
totalSizeRaw
}
=
await
this
.
dbRepo
.
createQueryBuilder
(
'
file
'
)
...
...
@@ -215,7 +224,7 @@ export class AppService extends ConsoleLogger {
const
size
=
parseInt
(
totalSizeRaw
);
if
(
size
>=
this
.
maxBranchSize
)
{
this
.
log
(
`Will switch to branch
${
branchId
.
toString
(
36
)}
`
);
return
{
branchId
:
branchId
+
1
,
size
:
0
};
return
{
branchId
:
branchId
+
newBranchOffset
,
size
:
0
};
}
else
{
this
.
log
(
`Will remain on branch
${
branchId
.
toString
(
36
)}
`
);
return
{
branchId
,
size
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment