From a8c5f367a93c901246d4d98051ad11631c1fa9f6 Mon Sep 17 00:00:00 2001 From: Martin Lowe <martin.lowe@eclipse-foundation.org> Date: Mon, 24 Oct 2022 15:50:28 -0400 Subject: [PATCH 1/2] Iss #84 - Update git hook to enable fork validation Resolves #84 --- src/main/rb/eca.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/rb/eca.rb b/src/main/rb/eca.rb index ec24f67e..b380f3ad 100644 --- a/src/main/rb/eca.rb +++ b/src/main/rb/eca.rb @@ -94,8 +94,8 @@ if (nil_or_empty(project_json_data) || project_json_data.class.name == 'Array') end ## Get the web URL, checking if project is a fork to get original project URL if (!nil_or_empty(project_json_data['forked_from_project'])) then - puts "Non-Eclipse project repository detected: ECA validation will be skipped.\n\nNote that any issues with sign off or committer access will be flagged upon merging into the main project repository." - exit 0 + puts "Fork detected, using forked from project's URL for better commit validation." + project_url = project_json_data['forked_from_project']['web_url'] else project_url = project_json_data['web_url'] end -- GitLab From 2874cc0c728ceab021dd3132653163dcb657bcba Mon Sep 17 00:00:00 2001 From: Martin Lowe <martin.lowe@eclipse-foundation.org> Date: Tue, 1 Nov 2022 13:50:27 -0400 Subject: [PATCH 2/2] Update eca.rb to not fail on forked projects --- src/main/rb/eca.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/rb/eca.rb b/src/main/rb/eca.rb index b380f3ad..b39e5c57 100644 --- a/src/main/rb/eca.rb +++ b/src/main/rb/eca.rb @@ -22,6 +22,9 @@ ALLOW_LIST_PROJECTS = ['/eclipse/oniro-core/meta-ts', '/eclipse/oniro-core/meta-zephyr' ] +## Track whether forked project for error reporting (failing vs non-failing) +is_forked_project = false + ## Process the commit into a hash object that will be posted to the ECA validation service def process_commit(sha) commit_parents_raw = `git show -s --format='%P' #{sha}` @@ -96,6 +99,7 @@ end if (!nil_or_empty(project_json_data['forked_from_project'])) then puts "Fork detected, using forked from project's URL for better commit validation." project_url = project_json_data['forked_from_project']['web_url'] + is_forked_project = true else project_url = project_json_data['web_url'] end @@ -209,6 +213,8 @@ else end end ## If error, exit as status 1 -if (response.code == 403) then +if (response.code == 403 && is_forked_project) then + puts "Errors detected, but commits will be allowed for forked repository. Commit errors reported in this push will block merge into origin repository until resolved." +elsif (response.code == 403) then exit 1 end -- GitLab