Skip to content

Commit

Permalink
Merge pull request #576 from semantic-release/fix/project-id
Browse files Browse the repository at this point in the history
  • Loading branch information
fgreinacher committed Aug 3, 2023
2 parents 506a56b + 3350152 commit 7fce590
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions lib/get-repo-id.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import parseUrl from "parse-url";
import escapeStringRegexp from "escape-string-regexp";

export default ({ envCi: { service } = {}, env: { CI_PROJECT_PATH } }, gitlabUrl, repositoryUrl) =>
service === "gitlab" && CI_PROJECT_PATH
? CI_PROJECT_PATH
export default ({ envCi: { service } = {}, env: { CI_PROJECT_ID } }, gitlabUrl, repositoryUrl) =>
service === "gitlab" && CI_PROJECT_ID
? CI_PROJECT_ID
: parseUrl(repositoryUrl)
.pathname.replace(new RegExp(`^${escapeStringRegexp(parseUrl(gitlabUrl).pathname)}`), "")
.replace(/^\//, "")
Expand Down
8 changes: 4 additions & 4 deletions test/get-repo-id.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,18 @@ test("Parse repo id with organization and subgroup", (t) => {
test("Get repo id from GitLab CI", (t) => {
t.is(
getRepoId(
{ envCi: { service: "gitlab" }, env: { CI_PROJECT_PATH: "other-owner/other-repo" } },
{ envCi: { service: "gitlab" }, env: { CI_PROJECT_ID: "123" } },
"https://gitlbab.com",
"https://gitlab.com/owner/repo.git"
),
"other-owner/other-repo"
"123"
);
});

test("Ignore CI_PROJECT_PATH if not on GitLab CI", (t) => {
test("Ignore CI_PROJECT_ID if not on GitLab CI", (t) => {
t.is(
getRepoId(
{ envCi: { service: "travis" }, env: { CI_PROJECT_PATH: "other-owner/other-repo" } },
{ envCi: { service: "travis" }, env: { CI_PROJECT_ID: "123" } },
"https://gitlbab.com",
"https://gitlab.com/owner/repo.git"
),
Expand Down

0 comments on commit 7fce590

Please sign in to comment.