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 compatibility issue with Octokit >= 8 #1479

Merged

Conversation

manicmaniac
Copy link
Member

@manicmaniac manicmaniac commented Feb 1, 2024

Overview

Close #1475

Currently Danger cannot post an inline comment when it is installed with Octokit >= 8.
It is because that Octokit has changed the method signature of create_pull_request_comment() (octokit/octokit.rb@918af86).

This PR fixes this issue by changing arguments depends on Octokit version.

Test

I added 2 specs to confirm that Danger changes its behavior depends on Octokit version.

And I also confirmed that this PR fixes the issue in other repository.
manicmaniac/danger-issue-1475#6

Bug / Known issues

The branch name of this PR is wrong. The change of method signature was introduced in Octokit v8, not v7.

@manicmaniac manicmaniac self-assigned this Feb 1, 2024
expect(@g.client).to receive(:delete_comment).with("artsy/eigen", inline_issue_id_2).and_return({})
expect(@g.client).to receive(:delete_comment).with("artsy/eigen", main_issue_id).and_return({})

v = Danger::Violation.new("Sure thing", true, "Rakefile", 34)
Copy link
Member Author

Choose a reason for hiding this comment

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

@manicmaniac manicmaniac marked this pull request as ready for review February 1, 2024 19:04
@manicmaniac manicmaniac requested review from orta and removed request for orta February 1, 2024 19:04
@manicmaniac manicmaniac marked this pull request as draft February 1, 2024 19:14
@manicmaniac manicmaniac changed the title Fix compatibility issue with Octokit >= 7 Fix compatibility issue with Octokit >= 8 Feb 1, 2024
client.create_pull_request_comment(ci_source.repo_slug, ci_source.pull_request_id,
body, head_ref, m.file, position)
body, head_ref, m.file, (Octokit::MAJOR >= 8 ? m.line : position))
Copy link
Member Author

Choose a reason for hiding this comment

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

Octokit::MAJOR exists since Octokit v4.0.0 and it is the minimum version that Danger supports.

spec.add_runtime_dependency "octokit", ">= 4.0"

@manicmaniac manicmaniac requested a review from orta February 1, 2024 19:35
@manicmaniac manicmaniac marked this pull request as ready for review February 1, 2024 19:35
@manicmaniac
Copy link
Member Author

@orta Could you give me a quick review on this one?
Or let me know if I could merge pull requests without being reviewed.

Copy link
Member

@orta orta left a comment

Choose a reason for hiding this comment

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

Yep, seems reasonable - feel free to self-merge things you think aren't controversial, and make deploys when you're happy (I'm OOO for 3 weeks!)

@manicmaniac manicmaniac merged commit 02ceb1f into danger:master Feb 4, 2024
12 checks passed
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.

Compatibility with Octokit v8
2 participants