Class: Octopi::Commit

Inherits:
Base
  • Object
show all
Includes:
Resource
Defined in:
lib/octopi/commit.rb

Constant Summary

Constants inherited from Base

Base::VALID

Instance Attribute Summary collapse

Attributes inherited from Base

#api

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Resource

for, included

Methods inherited from Base

#error=, #initialize, #property, #save

Constructor Details

This class inherits a constructor from Octopi::Base

Instance Attribute Details

#addedObject

Returns the value of attribute added.



7
8
9
# File 'lib/octopi/commit.rb', line 7

def added
  @added
end

#authorObject

Returns the value of attribute author.



7
8
9
# File 'lib/octopi/commit.rb', line 7

def author
  @author
end

#authored_dateObject

Returns the value of attribute authored_date.



7
8
9
# File 'lib/octopi/commit.rb', line 7

def authored_date
  @authored_date
end

#committed_dateObject

Returns the value of attribute committed_date.



7
8
9
# File 'lib/octopi/commit.rb', line 7

def committed_date
  @committed_date
end

#committerObject

Returns the value of attribute committer.



7
8
9
# File 'lib/octopi/commit.rb', line 7

def committer
  @committer
end

#idObject

Returns the value of attribute id.



7
8
9
# File 'lib/octopi/commit.rb', line 7

def id
  @id
end

#messageObject

Returns the value of attribute message.



7
8
9
# File 'lib/octopi/commit.rb', line 7

def message
  @message
end

#modifiedObject

Returns the value of attribute modified.



7
8
9
# File 'lib/octopi/commit.rb', line 7

def modified
  @modified
end

#parentsObject

Returns the value of attribute parents.



7
8
9
# File 'lib/octopi/commit.rb', line 7

def parents
  @parents
end

#removedObject

Returns the value of attribute removed.



7
8
9
# File 'lib/octopi/commit.rb', line 7

def removed
  @removed
end

#repositoryObject

Returns the value of attribute repository.



7
8
9
# File 'lib/octopi/commit.rb', line 7

def repository
  @repository
end

#treeObject

Returns the value of attribute tree.



7
8
9
# File 'lib/octopi/commit.rb', line 7

def tree
  @tree
end

#urlObject

Returns the value of attribute url.



7
8
9
# File 'lib/octopi/commit.rb', line 7

def url
  @url
end

Class Method Details

.find(options = {}) ⇒ Object

Finds all commits for the given options:

:repo or :repository or :name - A repository object or the name of a repository :user - A user object or the login of a user :branch - A branch object or the name of a branch. Defaults to master. :sha - The commit ID

Sample usage:

>> find(:user => "fcoury", :repo => "octopi", :sha => "f6609209c3ac0badd004512d318bfaa508ea10ae")
=> <Commit f6609209c3ac0badd004512d318bfaa508ea10ae for branch master>

>> find(:user => "fcoury", :repo => "octopi", :branch => "lazy", :sha => "f6609209c3ac0badd004512d318bfaa508ea10ae") # branch is set to lazy.
=> <Commit f6609209c3ac0badd004512d318bfaa508ea10ae for branch lazy>


52
53
54
55
56
# File 'lib/octopi/commit.rb', line 52

def self.find(options={})
  ensure_hash(options)
  user, repo, branch, sha = gather_details(options)
  super [user, repo, sha]
end

.find_all(options = {}) ⇒ Object

Finds all commits for the given options:

:repo or :repository or :name - A repository object or the name of a repository :user - A user object or the login of a user :branch - A branch object or the name of a branch. Defaults to master.

Sample usage:

>> find_all(:user => "fcoury", :repo => "octopi")
=> <Latest 30 commits for master branch>

=> find_all(:user => "fcoury", :repo => "octopi", :branch => "lazy") # branch is set to lazy.
=> <Latest 30 commits for lazy branch>


24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/octopi/commit.rb', line 24

def self.find_all(options={})
  ensure_hash(options)
  user, repo, branch = gather_details(options)
  commits = if options[:path]
    super user, repo.name, branch, options[:path]
  else
    super user, repo.name, branch
  end
  # Repository is not passed in from the data, set it manually.
  commits.each { |c| c.repository = repo }
  commits
end

Instance Method Details

#repo_identifierObject



58
59
60
61
62
63
64
65
66
67
# File 'lib/octopi/commit.rb', line 58

def repo_identifier
  url_parts = url.split('/')
  if @repository
    parts = [@repository.owner, @repository.name, url_parts[6]] 
  else
    parts = [url_parts[3], url_parts[4], url_parts[6]]
  end
  
  parts.join('/')
end