Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DojoBackendAPI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Dojo_Project_Nguyen
Backend
DojoBackendAPI
Commits
d5c892f0
Commit
d5c892f0
authored
1 year ago
by
kelly.nguyen
Browse files
Options
Downloads
Patches
Plain Diff
add function for archive a repo
parent
518d48c0
Branches
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#33278
failed
1 year ago
Stage: code_quality
Stage: test
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
ExpressAPI/src/managers/GitlabManager.ts
+16
-5
16 additions, 5 deletions
ExpressAPI/src/managers/GitlabManager.ts
ExpressAPI/src/routes/AssignmentRoutes.ts
+102
-103
102 additions, 103 deletions
ExpressAPI/src/routes/AssignmentRoutes.ts
with
118 additions
and
108 deletions
ExpressAPI/src/managers/GitlabManager.ts
+
16
−
5
View file @
d5c892f0
...
...
@@ -8,7 +8,7 @@ import logger
import
{
AccessLevel
,
EditProjectOptions
,
ProjectVariableSchema
,
ProtectedBranchAccessLevel
,
ProtectedBranchSchema
}
from
'
@gitbeaker/core
'
;
import
DojoStatusCode
from
'
../shared/types/Dojo/DojoStatusCode.js
'
;
import
SharedGitlabManager
from
'
../shared/managers/SharedGitlabManager.js
'
;
import
*
as
fs
from
'
fs
'
;
class
GitlabManager
extends
SharedGitlabManager
{
constructor
()
{
...
...
@@ -268,11 +268,22 @@ class GitlabManager extends SharedGitlabManager {
}
}
async
exportRepository
(
repoId
:
number
,
extension
:
ArchiveType
):
Promise
<
Blob
>
{
async
exportRepository
(
repoId
:
number
)
:
Promise
<
Blob
>
{
try
{
return
await
this
.
api
.
Repositories
.
showArchive
(
repoId
,
{
fileType
:
extension
this
.
api
.
Repositories
.
showArchive
(
repoId
).
then
(
async
archive
=>
{
const
buffer
=
Buffer
.
from
(
await
archive
.
arrayBuffer
());
fs
.
writeFile
(
'
repository-archive.tar.gz
'
,
buffer
,
(
err
)
=>
{
if
(
err
)
{
console
.
error
(
'
Error saving archive:
'
,
err
);
}
else
{
console
.
log
(
'
Archive saved successfully!
'
);
}
});
}).
catch
(
error
=>
{
console
.
error
(
'
Error fetching archive:
'
,
error
);
});
return
await
this
.
api
.
Repositories
.
showArchive
(
repoId
);
}
catch
(
e
)
{
logger
.
error
(
JSON
.
stringify
(
e
));
return
Promise
.
reject
(
e
);
...
...
This diff is collapsed.
Click to expand it.
ExpressAPI/src/routes/AssignmentRoutes.ts
+
102
−
103
View file @
d5c892f0
...
...
@@ -302,9 +302,8 @@ class AssignmentRoutes implements RoutesManager {
}
private
async
exportAssignment
(
req
:
express
.
Request
,
res
:
express
.
Response
)
{
let
ext
:
Gitlab
.
ArchiveType
=
'
zip
'
;
await
GitlabManager
.
exportRepository
(
req
.
boundParams
.
assignment
!
.
gitlabId
,
ext
);
return
req
.
session
.
sendResponse
(
res
,
StatusCodes
.
OK
);
const
resDl
=
await
GitlabManager
.
exportRepository
(
req
.
boundParams
.
assignment
!
.
gitlabId
);
return
req
.
session
.
sendResponse
(
res
,
StatusCodes
.
OK
,
resDl
);
}
}
...
...
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