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
External 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 (HES-SO)
Projects
Backend
DojoBackendAPI
Commits
f072d417
Commit
f072d417
authored
1 year ago
by
michael.minelli
Browse files
Options
Downloads
Patches
Plain Diff
GitlabManager => Add getRepositoryLastCommit function
parent
c8590e80
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ExpressAPI/src/managers/GitlabManager.ts
+38
-16
38 additions, 16 deletions
ExpressAPI/src/managers/GitlabManager.ts
with
38 additions
and
16 deletions
ExpressAPI/src/managers/GitlabManager.ts
+
38
−
16
View file @
f072d417
import
axios
from
'
axios
'
;
import
Config
from
'
../config/Config
'
;
import
GitlabRepository
from
'
../shared/types/Gitlab/GitlabRepository
'
;
import
GitlabAccessLevel
from
'
../shared/types/Gitlab/GitlabAccessLevel
'
;
import
GitlabMember
from
'
../shared/types/Gitlab/GitlabMember
'
;
import
{
StatusCodes
}
from
'
http-status-codes
'
;
import
GitlabVisibility
from
'
../shared/types/Gitlab/GitlabVisibility
'
;
import
GitlabUser
from
'
../shared/types/Gitlab/GitlabUser
'
;
import
GitlabTreeFile
from
'
../shared/types/Gitlab/GitlabTreeFile
'
;
import
parseLinkHeader
from
'
parse-link-header
'
;
import
GitlabFile
from
'
../shared/types/Gitlab/GitlabFile
'
;
import
express
from
'
express
'
;
import
GitlabRoute
from
'
../shared/types/Gitlab/GitlabRoute
'
;
import
SharedConfig
from
'
../shared/config/SharedConfig
'
;
import
GitlabProfile
from
'
../shared/types/Gitlab/GitlabProfile
'
;
import
GitlabRelease
from
'
../shared/types/Gitlab/GitlabRelease
'
;
import
axios
from
'
axios
'
;
import
Config
from
'
../config/Config
'
;
import
GitlabRepository
from
'
../shared/types/Gitlab/GitlabRepository
'
;
import
GitlabAccessLevel
from
'
../shared/types/Gitlab/GitlabAccessLevel
'
;
import
GitlabMember
from
'
../shared/types/Gitlab/GitlabMember
'
;
import
{
StatusCodes
}
from
'
http-status-codes
'
;
import
GitlabVisibility
from
'
../shared/types/Gitlab/GitlabVisibility
'
;
import
GitlabUser
from
'
../shared/types/Gitlab/GitlabUser
'
;
import
GitlabTreeFile
from
'
../shared/types/Gitlab/GitlabTreeFile
'
;
import
parseLinkHeader
from
'
parse-link-header
'
;
import
GitlabFile
from
'
../shared/types/Gitlab/GitlabFile
'
;
import
express
from
'
express
'
;
import
GitlabRoute
from
'
../shared/types/Gitlab/GitlabRoute
'
;
import
SharedConfig
from
'
../shared/config/SharedConfig
'
;
import
GitlabProfile
from
'
../shared/types/Gitlab/GitlabProfile
'
;
import
GitlabRelease
from
'
../shared/types/Gitlab/GitlabRelease
'
;
import
{
CommitSchema
,
Gitlab
}
from
'
@gitbeaker/rest
'
;
import
logger
from
'
../shared/logging/WinstonLogger
'
;
class
GitlabManager
{
readonly
api
=
new
Gitlab
({
host
:
SharedConfig
.
gitlab
.
URL
,
token
:
Config
.
gitlab
.
account
.
token
});
private
getApiUrl
(
route
:
GitlabRoute
):
string
{
return
`
${
SharedConfig
.
gitlab
.
apiURL
}${
route
}
`
;
}
...
...
@@ -75,6 +82,21 @@ class GitlabManager {
return
response
.
data
;
}
async
getRepositoryLastCommit
(
repoId
:
number
,
branch
:
string
=
'
main
'
):
Promise
<
CommitSchema
|
undefined
>
{
try
{
const
commits
=
await
this
.
api
.
Commits
.
all
(
repoId
,
{
refName
:
branch
,
maxPages
:
1
,
perPage
:
1
});
return
commits
.
length
>
0
?
commits
[
0
]
:
undefined
;
}
catch
(
e
)
{
logger
.
error
(
e
);
return
undefined
;
}
}
async
createRepository
(
name
:
string
,
description
:
string
,
visibility
:
string
,
initializeWithReadme
:
boolean
,
namespace
:
number
,
sharedRunnersEnabled
:
boolean
,
wikiEnabled
:
boolean
,
import_url
:
string
):
Promise
<
GitlabRepository
>
{
const
response
=
await
axios
.
post
<
GitlabRepository
>
(
this
.
getApiUrl
(
GitlabRoute
.
REPOSITORY_CREATE
),
{
name
:
name
,
...
...
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