From a679d73684d8efdd1867b24d21e686f3f2bb09e9 Mon Sep 17 00:00:00 2001 From: Ryan McNeil Date: Thu, 26 Dec 2024 10:59:18 -0700 Subject: [PATCH 1/5] puts refs --- Dangerfile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Dangerfile b/Dangerfile index a8c8a497044..0eab2766179 100644 --- a/Dangerfile +++ b/Dangerfile @@ -8,6 +8,11 @@ module VSPDanger class Runner def self.run + puts 'ENV:' + puts ENV.fetch('GITHUB_BASE_REF') + puts ENV.fetch('GITHUB_HEAD_REF') + puts ENV.fetch('GITHUB_REF') + prepare_git [ From d842012a0b1f3a02862d6ba928219192e89a53f8 Mon Sep 17 00:00:00 2001 From: Ryan McNeil Date: Thu, 26 Dec 2024 11:08:58 -0700 Subject: [PATCH 2/5] update HEAD/BASE SHA --- Dangerfile | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/Dangerfile b/Dangerfile index 0eab2766179..59e620a8f2d 100644 --- a/Dangerfile +++ b/Dangerfile @@ -3,16 +3,11 @@ require 'ostruct' module VSPDanger - HEAD_SHA = `git rev-parse --abbrev-ref HEAD`.chomp.freeze - BASE_SHA = 'origin/master' + HEAD_SHA = ENV['GITHUB_HEAD_REF'] || `git rev-parse --abbrev-ref HEAD`.chomp.freeze + BASE_SHA = ENV['GITHUB_BASE_REF'] || 'origin/master' class Runner def self.run - puts 'ENV:' - puts ENV.fetch('GITHUB_BASE_REF') - puts ENV.fetch('GITHUB_HEAD_REF') - puts ENV.fetch('GITHUB_REF') - prepare_git [ From 2d055fc4410ec3896dd626e355d187d8b7fd58df Mon Sep 17 00:00:00 2001 From: Ryan McNeil Date: Mon, 30 Dec 2024 15:34:32 -0700 Subject: [PATCH 3/5] add 'origin/' to branches --- Dangerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dangerfile b/Dangerfile index 59e620a8f2d..896cb9122ce 100644 --- a/Dangerfile +++ b/Dangerfile @@ -3,8 +3,8 @@ require 'ostruct' module VSPDanger - HEAD_SHA = ENV['GITHUB_HEAD_REF'] || `git rev-parse --abbrev-ref HEAD`.chomp.freeze - BASE_SHA = ENV['GITHUB_BASE_REF'] || 'origin/master' + HEAD_SHA = ENV.fetch('GITHUB_HEAD_REF') ? "origin/#{ENV.fetch('GITHUB_HEAD_REF')}" : `git rev-parse --abbrev-ref HEAD`.chomp.freeze + BASE_SHA = ENV.fetch('GITHUB_BASE_REF') ? "origin/#{ENV.fetch('GITHUB_BASE_REF')}" : 'origin/master' class Runner def self.run From 6d66dedb24f2baabe3475d70b16f9ae1730c2b2f Mon Sep 17 00:00:00 2001 From: Ryan McNeil Date: Mon, 30 Dec 2024 16:13:46 -0700 Subject: [PATCH 4/5] remove unnecessary refs to head/base --- .github/workflows/danger.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/danger.yml b/.github/workflows/danger.yml index 2a72505a5bd..e72d048b7fb 100644 --- a/.github/workflows/danger.yml +++ b/.github/workflows/danger.yml @@ -24,7 +24,7 @@ jobs: bundler-cache: true - name: Run Danger - run: bundle exec danger --head=${{ github.sha }} --base=${{ github.event.pull_request.base.sha }} --verbose + run: bundle exec danger --verbose - name: Add Danger Label uses: actions-ecosystem/action-remove-labels@v1 From 2bb20a80fc0118d26ba5f06cbdfb1c987e89d481 Mon Sep 17 00:00:00 2001 From: Ryan McNeil Date: Tue, 31 Dec 2024 10:49:50 -0700 Subject: [PATCH 5/5] fix case of empty string --- Dangerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dangerfile b/Dangerfile index 896cb9122ce..11a4fc1047e 100644 --- a/Dangerfile +++ b/Dangerfile @@ -3,8 +3,8 @@ require 'ostruct' module VSPDanger - HEAD_SHA = ENV.fetch('GITHUB_HEAD_REF') ? "origin/#{ENV.fetch('GITHUB_HEAD_REF')}" : `git rev-parse --abbrev-ref HEAD`.chomp.freeze - BASE_SHA = ENV.fetch('GITHUB_BASE_REF') ? "origin/#{ENV.fetch('GITHUB_BASE_REF')}" : 'origin/master' + HEAD_SHA = ENV.fetch('GITHUB_HEAD_REF', '').empty? ? `git rev-parse --abbrev-ref HEAD`.chomp.freeze : "origin/#{ENV.fetch('GITHUB_HEAD_REF')}" + BASE_SHA = ENV.fetch('GITHUB_BASE_REF', '').empty? ? 'origin/master' : "origin/#{ENV.fetch('GITHUB_BASE_REF')}" class Runner def self.run