Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions lib/gitlab/client/repositories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,26 @@ def contributors(project, options = {})
get("/projects/#{url_encode project}/repository/contributors", query: options)
end
alias repo_contributors contributors

# Generate changelog data
#
# @example
# Gitlab.generate_changelog(42, 'v1.0.0')
# Gitlab.generate_changelog(42, 'v1.0.0', branch: 'main')
#
# @param [Integer, String] project The ID or name of a project
# @param [String] version The version to generate the changelog for
# @param [Hash] options A customizable set of options
# @option options [String] :from The start of the range of commits (SHA)
# @option options [String] :to The end of the range of commits (as a SHA) to use for the changelog
# @option options [String] :date The date and time of the release, defaults to the current time
# @option options [String] :branch The branch to commit the changelog changes to
# @option options [String] :trailer The Git trailer to use for including commits
# @option options [String] :file The file to commit the changes to
# @option options [String] :message The commit message to produce when committing the changes
# @return [bool]
def generate_changelog(project, version, options = {})
post("/projects/#{url_encode project}/repository/changelog", body: options.merge(version: version))
end
end
end
1 change: 1 addition & 0 deletions spec/fixtures/changelog.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
200
17 changes: 17 additions & 0 deletions spec/gitlab/client/repositories_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,21 @@
expect(@contributors.first.commits).to eq(117)
end
end

describe '.generate_changelog' do
before do
stub_post('/projects/3/repository/changelog', 'changelog')
.with(body: { version: 'v1.0.0', branch: 'main' })
@changelog = Gitlab.generate_changelog(3, 'v1.0.0', branch: 'main')
end

it 'gets the correct resource' do
expect(a_post('/projects/3/repository/changelog')
.with(body: { version: 'v1.0.0', branch: 'main' })).to have_been_made
end

it 'returns successful result' do
expect(@changelog).to be_truthy
end
end
end