-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Base SHA for Dangerfile checks #20032
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reviewed in CoP meeting ✅
Dangerfile
Outdated
@@ -3,8 +3,8 @@ | |||
require 'ostruct' | |||
|
|||
module VSPDanger | |||
HEAD_SHA = `git rev-parse --abbrev-ref HEAD`.chomp.freeze | |||
BASE_SHA = 'origin/master' | |||
HEAD_SHA = ENV.fetch('GITHUB_HEAD_REF') ? "origin/#{ENV.fetch('GITHUB_HEAD_REF')}" : `git rev-parse --abbrev-ref HEAD`.chomp.freeze |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have to check ENV.fetch('GITHUB_HEAD_REF') for empty/nil?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LindseySaari I did that because if those vars ARE nil, it'll evaluate to "origin/"
, but I'd rather it default to 'git rev-parse --abbrev-ref HEAD'.chomp.freeze
/origin/master
in the case it is being ran outside of the GitHUB CI context (I believe it can be ran locally, per our convo yesterday).
Summary
origin/master
, so in the cases where a feature branch was the base branch, one would get unexpected results. For example if someone created a PR into a feature branch that changed 100 LOC, but the base branch already had 500+ changes, it would display a LOC error, despite it being in the acceptable range. This PR detects the BASE_SHA from the PR CI ENV.danger
options--head=${{ github.sha }} --base=${{ github.event.pull_request.base.sha }}
because they aren't actually being used (from what I can tell). It seems they were intending to solve the problem this PR is fixing, but never worked properly.Testing done