Skip to content
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

Fix danger local with non master base branch #1058

Merged
merged 1 commit into from
Jul 24, 2020

Conversation

ahobson
Copy link
Contributor

@ahobson ahobson commented Jul 23, 2020

This fixes #1057

Comment on lines 10 to 13
/** What should we compare against? */
base?: string
/** Should we run against current staged changes? */
staging?: boolean
Copy link
Member

@f-meloni f-meloni Jul 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this add this parameter also to the other commands, and then to their help too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would, but I think that's a feature so that the base comparison branch will work for all commands. This is needed as I mention in #1057 since danger-runner winds up being invoked.

I did suggest another idea in #1057 but there was a comment that the shared argument solution was preferable.

I'm happy to rework to make it more appropriate

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other commands are pr and ci runner etc.
In those context I think base and staging would not make sense, because you would be running it against a PR, and not a local branch.
The pr command has a specific command too, https://github.com/danger/danger-js/blob/master/source/commands/danger-pr.ts#L93 and in that case it works, then why does this need to be on the SharedCLI instead? (just asking to try to get more context)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm really not familiar with the code base, but I think that's because those options are only needed before invoking danger runner but the base branch is needed after invoking danger runner.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the value taken at line 17 and 19, really similarly to what happens in https://github.com/danger/danger-js/blob/master/source/commands/danger-pr.ts#L93 ? (Again is just me trying to understand better)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps my analysis in #1057 is wrong, but I believe what is happening is that danger-local winds up invoking danger-runner and passes the base branch argument, but because it's not a shared option, that override is lost.

Note that in danger-pr the options are removed and so isJSON is never passed to danger-runner. The base branch option needs to be interpreted by danger-runner somehow and the shared arguments is the most obvious way to do that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not positive about this, but it does seem like the cliArgs are used inside the runner only if the command is not using a platform. If that's the case, then it's only danger-local.ts that needs to send the base branch.

But danger-runner.ts is invoked by danger-pr, danger-ci, and danger-local (and others), so I think that means we need to merge the cliArgs when generating the json. I've updated the PR

@ahobson ahobson force-pushed the fix-danger-local-main-branch-1057 branch from 28e06a2 to 5ee6491 Compare July 24, 2020 14:27
@danger-public
Copy link

Warnings
⚠️

Please add a changelog entry for your changes. You can find it in CHANGELOG.md

Please add your change and name to the master section.

Generated by 🚫 dangerJS against 5ee6491

Copy link
Member

@f-meloni f-meloni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, let's wait to see what @orta thinks

@orta
Copy link
Member

orta commented Jul 24, 2020

Yeah, I think this is the original intent 👍

@orta
Copy link
Member

orta commented Jul 24, 2020

Yeah, I think it should be pretty harmless to pass through arbitrary CLI data regardless. Thanks for taking it up @ahobson

@orta orta merged commit 7f6d2b3 into danger:master Jul 24, 2020
@ahobson ahobson deleted the fix-danger-local-main-branch-1057 branch July 24, 2020 19:37
@orta
Copy link
Member

orta commented Jul 24, 2020

Shipped as 10.3.0 because apparantly I can't remember which is patch or minor it seems 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] renaming master branch causes danger local to fail even when base branch is provided
4 participants