Skip to content

Commit

Permalink
fix: use project ID for API calls if available
Browse files Browse the repository at this point in the history
  • Loading branch information
fgreinacher committed Jan 12, 2025
1 parent bc32806 commit 6b96943
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/get-project-context.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import urlJoin from "url-join";

import getProjectPath from "./get-project-path.js";
import getProjectId from "./get-project-id.js";

export default (context, gitlabUrl, gitlabApiUrl, repositoryUrl) => {
const projectId = getProjectId(context);
const projectPath = getProjectPath(context, gitlabUrl, repositoryUrl);
const encodedProjectPath = encodeURIComponent(projectPath);
const projectApiUrl = urlJoin(gitlabApiUrl, `/projects/${encodedProjectPath}`);
const projectApiUrl = urlJoin(gitlabApiUrl, `/projects/${projectId ?? encodedProjectPath}`);
return {
projectPath,
encodedProjectPath,
Expand Down
4 changes: 4 additions & 0 deletions lib/get-project-id.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default ({ envCi: { service } = {}, env: { CI_PROJECT_ID } }) =>
service === "gitlab" && CI_PROJECT_ID
? CI_PROJECT_ID
: null;

0 comments on commit 6b96943

Please sign in to comment.