Class: VSTS::Changeset

Inherits:
BaseModel show all
Defined in:
lib/vsts/changeset.rb

Overview

Changeset model

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#underscore

Constructor Details

#initialize(h = {}) ⇒ Changeset

Create new changeset instance from a hash

Parameters:

  • h (Hash) (defaults to: {})

    changeset data as returned by the VSTS API



10
11
12
13
14
15
16
17
18
# File 'lib/vsts/changeset.rb', line 10

def initialize(h = {})
  @id = h["changesetId"]
  @url = h["url"]
  @author = Identity.new(h["author"])
  @checked_in_by = Identity.new(h["checkedInBy"])
  @created_date = DateTime.rfc3339(h["createdDate"])
  @comment = h["comment"]
  @_changes = nil
end

Instance Attribute Details

#authorObject

Returns the value of attribute author.



5
6
7
# File 'lib/vsts/changeset.rb', line 5

def author
  @author
end

#checked_in_byObject

Returns the value of attribute checked_in_by.



5
6
7
# File 'lib/vsts/changeset.rb', line 5

def checked_in_by
  @checked_in_by
end

#commentObject

Returns the value of attribute comment.



5
6
7
# File 'lib/vsts/changeset.rb', line 5

def comment
  @comment
end

#created_dateObject

Returns the value of attribute created_date.



5
6
7
# File 'lib/vsts/changeset.rb', line 5

def created_date
  @created_date
end

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/vsts/changeset.rb', line 5

def id
  @id
end

#urlObject

Returns the value of attribute url.



5
6
7
# File 'lib/vsts/changeset.rb', line 5

def url
  @url
end

Class Method Details

.find(id, opts = {}) ⇒ Changeset?

Parameters:

  • id (int)

    the changeset id

  • opts (Hash) (defaults to: {})

    options

Options Hash (opts):

  • :maxCommentLength (int)
  • :maxChangeCount (int)
  • :includeDetails (boolean)
  • :includeWorkItems (boolean)

Returns:

  • (Changeset, nil)

    the changeset found or nil



70
71
72
73
74
# File 'lib/vsts/changeset.rb', line 70

def self.find(id, opts = {})
  urlparams = APIClient.build_params(opts, [:includeDetails, :includeWorkItems, :maxCommentLength, :maxChangeCount])
  resp = APIClient.get("/changesets/#{id}", area: "tfvc", urlparams: urlparams)
  Changeset.new(resp.parsed)
end

.find_all(search_criteria = {}) ⇒ array of Changeset

Parameters:

  • search_criteria (Hash) (defaults to: {})

Returns:



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/vsts/changeset.rb', line 37

def self.find_all(search_criteria = {})
  urlparams = APIClient.build_params(
    search_criteria,
    [
      ["searchCriteria.", :itemPath],
      ["searchCriteria.", :version],
      ["searchCriteria.", :versionType],
      ["searchCriteria.", :versionOption],
      ["searchCriteria.", :author],
      ["searchCriteria.", :fromId],
      ["searchCriteria.", :toId],
      ["searchCriteria.", :fromDate],
      ["searchCriteria.", :toDate],
      ["$", :top],
      ["$", :skip],
      ["$", :orderBy],
      :maxCommentLength
    ]
  )
  resp = APIClient.get("/changesets", area: "tfvc", urlparams: urlparams)
  resp.parsed["value"].map { |o| Changeset.new(o) }
end

Instance Method Details

#changes(opts = {}) ⇒ array of Change

Parameters:

  • opts (Hash) (defaults to: {})

Returns:

  • (array of Change)

    list of changes in the changeset



25
26
27
28
29
30
# File 'lib/vsts/changeset.rb', line 25

def changes(opts = {})
  return @_changes if @_changes.instance_of?(Array)
  urlparams = APIClient.build_params(opts, [["$", :top], ["$", :skip]])
  resp = APIClient.get("/changesets/#{id}/changes", area: "tfvc", urlparams: urlparams)
  @_changes = resp.parsed["value"].map { |o| Change.new(o) }
end