Skip to content

Commit 7fce590

Browse files
authored
Merge pull request #576 from semantic-release/fix/project-id
2 parents 506a56b + 3350152 commit 7fce590

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

lib/get-repo-id.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import parseUrl from "parse-url";
22
import escapeStringRegexp from "escape-string-regexp";
33

4-
export default ({ envCi: { service } = {}, env: { CI_PROJECT_PATH } }, gitlabUrl, repositoryUrl) =>
5-
service === "gitlab" && CI_PROJECT_PATH
6-
? CI_PROJECT_PATH
4+
export default ({ envCi: { service } = {}, env: { CI_PROJECT_ID } }, gitlabUrl, repositoryUrl) =>
5+
service === "gitlab" && CI_PROJECT_ID
6+
? CI_PROJECT_ID
77
: parseUrl(repositoryUrl)
88
.pathname.replace(new RegExp(`^${escapeStringRegexp(parseUrl(gitlabUrl).pathname)}`), "")
99
.replace(/^\//, "")

test/get-repo-id.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,18 @@ test("Parse repo id with organization and subgroup", (t) => {
4141
test("Get repo id from GitLab CI", (t) => {
4242
t.is(
4343
getRepoId(
44-
{ envCi: { service: "gitlab" }, env: { CI_PROJECT_PATH: "other-owner/other-repo" } },
44+
{ envCi: { service: "gitlab" }, env: { CI_PROJECT_ID: "123" } },
4545
"https://gitlbab.com",
4646
"https://gitlab.com/owner/repo.git"
4747
),
48-
"other-owner/other-repo"
48+
"123"
4949
);
5050
});
5151

52-
test("Ignore CI_PROJECT_PATH if not on GitLab CI", (t) => {
52+
test("Ignore CI_PROJECT_ID if not on GitLab CI", (t) => {
5353
t.is(
5454
getRepoId(
55-
{ envCi: { service: "travis" }, env: { CI_PROJECT_PATH: "other-owner/other-repo" } },
55+
{ envCi: { service: "travis" }, env: { CI_PROJECT_ID: "123" } },
5656
"https://gitlbab.com",
5757
"https://gitlab.com/owner/repo.git"
5858
),

0 commit comments

Comments
 (0)