Sha256: d7b375bd3cf7ce6423d2165f46ca767acedc79fc388d105bbd54bdeec3cf72c1

Contents?: true

Size: 1.79 KB

Versions: 2

Compression:

Stored size: 1.79 KB

Contents

# frozen_string_literal: true

require 'stash_core_api/utils'

module StashCoreAPI
  # Interfaces with commits endpoints of Stash CoreAPI API
  module Commits
    include StashCoreAPI::Utils

    # @see https://developer.atlassian.com/static/rest/stash/3.9.2/stash-rest.html#idp2028464
    #
    # @param path [String] an optional path to filter commits by
    # @param since [String] the commit ID or ref (exclusively) to retrieve
    #   commits after
    # @param until [String] the commit ID (SHA1) or ref (inclusively) to
    #   retrieve commits before if until is unspecified, the tip of the
    #   repository's default branch is assumed
    # @param limit [Integer] the maximum number of commits to return
    #   Stash defaults to 25
    # @param withCounts [Boolean] optionally include the total number of
    #   commits and total number of unique authors
    def commits(path: nil, since: nil, until_: nil, limit: nil,
                with_counts: nil)
      endpoint = '/commits'
      if path || since || until_ || limit || with_counts
        endpoint = "#{endpoint}?"
        endpoint = "#{endpoint}path=#{sanitized_path(path)}&" if path
        endpoint = "#{endpoint}since=#{since}&" if since
        endpoint = "#{endpoint}until=#{until_}&" if until_
        endpoint = "#{endpoint}limit=#{limit}&" if limit
        endpoint = "#{endpoint}withCounts=#{with_counts}&" if with_counts
      end
      perform_get(endpoint)
    end

    # @see https://docs.atlassian.com/DAC/rest/stash/3.9.2/stash-rest.html#idp1729008
    #
    # @param limit [Integer] the maximum number of commits to return
    #   Stash defaults to 25
    def commit_changes(commit_id, limit: nil)
      endpoint = "/commits/#{commit_id}/changes"
      endpoint = "#{endpoint}?limit=#{limit}" if limit
      perform_get(endpoint)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
stash_core_api-0.1.8 lib/stash_core_api/commits.rb
stash_core_api-0.1.7 lib/stash_core_api/commits.rb