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

[FEAT]: Add support for generating release notes content for a release #1573

Open
1 task done
davegudge opened this issue May 19, 2023 · 0 comments
Open
1 task done
Labels
hacktoberfest Issues for participation in Hacktoberfest Status: Up for grabs Issues that are ready to be worked on by anyone Type: Feature New feature or request

Comments

@davegudge
Copy link

davegudge commented May 19, 2023

Describe the need

Add support for generating release notes content for a release:

https://docs.github.com/en/rest/releases/releases?apiVersion=2022-11-28#generate-release-notes-content-for-a-release


Below is the logic required (+ test) to support 'generating release notes content for a release':

module Octokit
  class Client
    module Releases

      ...

      # Generate release notes content for a release
      #
      # @param repo [Integer, String, Repository, Hash] A GitHub repository
      # @param tag_name [String] Git tag from which to create release. This can be an existing tag or a new one.
      # @option options [String] :target_commitish Specifies the commitish value that determines where the Git tag is created from.
      # @option options [String] :previous_tag_name The name of the previous tag to use as the starting point for the release notes.
      # @option options [String] :configuration_file_path Specifies a path to a file in the repository containing configuration settings used for generating the release notes. If unspecified, the configuration file located in the repository at '.github/release.yml' or '.github/release.yaml' will be used.
      # @return [Sawyer::Resource] The Generated Release Notes Content
      # @see https://developer.github.com/v3/repos/releases/#generate-release-notes-content-for-a-release
      def create_release_notes(repo, tag_name, options = {})
        opts = options.merge(tag_name: tag_name)
        post "#{Repository.path repo}/releases/generate-notes", opts
      end

      ...

    end
  end
end
describe Octokit::Client::Releases do

  ...

  describe '.create_release_notes', :vcr do
    it 'creates the release notes' do
      release = @client.create_release_notes \
        @test_repo, 'test-create-release-notes-tag', previous_tag_name: 'test-create-release-notes-previous-tag'
      expect(release.body).to include('Changes in Release')
      assert_requested :post, github_url("/repos/#{@test_repo}/releases/generate-notes")
    end
  end

  ...

end

I am not familiar with VCR and so far, I've been unable to generate the spec/cassettes/Octokit_Client_Releases/_create_release_notes/creates_release_notes.json entry required.

The test outlined above fails with:

  1) Octokit::Client::Releases.create_release_notes creates the release notes
     Failure/Error: raise error

     Octokit::Unauthorized:
       GET https://api.github.com/repos/api-padawan/api-sandbox?auto_init=true: 401 - Bad credentials // See: https://docs.github.com/rest
     # ./lib/octokit/response/raise_error.rb:14:in `on_complete'
     # ./lib/octokit/middleware/follow_redirects.rb:73:in `perform_with_redirection'
     # ./lib/octokit/middleware/follow_redirects.rb:61:in `call'
     # ./lib/octokit/connection.rb:156:in `request'
     # ./lib/octokit/connection.rb:19:in `get'
     # ./lib/octokit/client/repositories.rb:27:in `repository'
     # ./lib/octokit/client/repositories.rb:15:in `repository?'
     # ./spec/spec_helper.rb:113:in `block (2 levels) in <top (required)>'
     # ./lib/octokit/middleware/follow_redirects.rb:73:in `perform_with_redirection'
     # ./lib/octokit/middleware/follow_redirects.rb:61:in `call'
     # ./lib/octokit/connection.rb:156:in `request'
     # ./lib/octokit/connection.rb:28:in `post'
     # ./lib/octokit/client/releases.rb:46:in `create_release_notes'
     # ./spec/octokit/client/releases_spec.rb:29:in `block (3 levels) in <top (required)>'

I have attempted to set the OCTOKIT_TEST_GITHUB_ORGANIZATION= OCTOKIT_TEST_GITHUB_LOGIN= OCTOKIT_TEST_GITHUB_TOKEN, but other tests then fail due to the limited permissions have I have provided via the access token.

It may be easier for somebody who is already 'setup' to modify the test suite on this repository to implement the solution above.

SDK Version

No response

API Version

No response

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@davegudge davegudge added Status: Triage This is being looked at and prioritized Type: Feature New feature or request labels May 19, 2023
@kfcampbell kfcampbell added Priority: Normal Status: Up for grabs Issues that are ready to be worked on by anyone and removed Status: Triage This is being looked at and prioritized labels May 19, 2023
@nickfloyd nickfloyd added the hacktoberfest Issues for participation in Hacktoberfest label Sep 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest Issues for participation in Hacktoberfest Status: Up for grabs Issues that are ready to be worked on by anyone Type: Feature New feature or request
Projects
Status: 🔥 Backlog
Development

No branches or pull requests

3 participants