From 66ccfa35a10e50ab81b6277bbd2ccc6ee89ab5d9 Mon Sep 17 00:00:00 2001 From: davidgortega Date: Fri, 21 May 2021 10:02:11 +0200 Subject: [PATCH 1/5] cml-pr name branch --- src/drivers/github.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/drivers/github.js b/src/drivers/github.js index a0b1304cf..27ba4115c 100644 --- a/src/drivers/github.js +++ b/src/drivers/github.js @@ -18,6 +18,11 @@ const { GITHUB_EVENT_NAME } = process.env; +const branch_name = (branch) => { + const parts = branch.split('/'); + return parts[parts.length - 1] || branch; +}; + const owner_repo = (opts) => { let owner, repo; const { uri } = opts; @@ -276,8 +281,8 @@ class Github { } = pr; return { url, - source, - target + source: branch_name(source), + target: branch_name(target) }; }); } @@ -290,7 +295,7 @@ class Github { } get branch() { - return GITHUB_REF; + return branch_name(GITHUB_REF); } get user_email() { From 006370bdb994646cb941b3048b51fbf2ed157ac3 Mon Sep 17 00:00:00 2001 From: davidgortega Date: Fri, 21 May 2021 11:41:37 +0200 Subject: [PATCH 2/5] not null --- src/drivers/github.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/drivers/github.js b/src/drivers/github.js index 27ba4115c..15b47f237 100644 --- a/src/drivers/github.js +++ b/src/drivers/github.js @@ -19,6 +19,8 @@ const { } = process.env; const branch_name = (branch) => { + if (!branch) return; + const parts = branch.split('/'); return parts[parts.length - 1] || branch; }; From a5f551e7d00889f4afd60fdbb084282311dfbf5f Mon Sep 17 00:00:00 2001 From: davidgortega Date: Fri, 21 May 2021 12:00:48 +0200 Subject: [PATCH 3/5] replace --- src/drivers/github.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/drivers/github.js b/src/drivers/github.js index 15b47f237..007d7c4ee 100644 --- a/src/drivers/github.js +++ b/src/drivers/github.js @@ -21,8 +21,7 @@ const { const branch_name = (branch) => { if (!branch) return; - const parts = branch.split('/'); - return parts[parts.length - 1] || branch; + return branch.replace('/refs/heads/', ''); }; const owner_repo = (opts) => { From cdbf9cb4782ba04df0939ce3ab6a9406ae30dee0 Mon Sep 17 00:00:00 2001 From: davidgortega Date: Fri, 21 May 2021 12:03:51 +0200 Subject: [PATCH 4/5] refs/ --- src/drivers/github.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/drivers/github.js b/src/drivers/github.js index 007d7c4ee..1f545f73b 100644 --- a/src/drivers/github.js +++ b/src/drivers/github.js @@ -21,7 +21,7 @@ const { const branch_name = (branch) => { if (!branch) return; - return branch.replace('/refs/heads/', ''); + return branch.replace('refs/heads/', ''); }; const owner_repo = (opts) => { From 06db5448cde4c9c5f8be901a0ebd09d13794e79b Mon Sep 17 00:00:00 2001 From: DavidGOrtega Date: Mon, 24 May 2021 18:58:41 +0200 Subject: [PATCH 5/5] tags Co-authored-by: Casper da Costa-Luis --- src/drivers/github.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/drivers/github.js b/src/drivers/github.js index 1f545f73b..a77434400 100644 --- a/src/drivers/github.js +++ b/src/drivers/github.js @@ -21,7 +21,7 @@ const { const branch_name = (branch) => { if (!branch) return; - return branch.replace('refs/heads/', ''); + return branch.replace(/refs\/(head|tag)s\//, ''); }; const owner_repo = (opts) => {