Class: Fuselage::Commit

Inherits:
Base
  • Object
show all
Defined in:
lib/fuselage/commit.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#api

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

delete_method, get, #initialize, post

Constructor Details

This class inherits a constructor from Fuselage::Base

Instance Attribute Details

#authorObject

Returns the value of attribute author.



4
5
6
# File 'lib/fuselage/commit.rb', line 4

def author
  @author
end

#committerObject

Returns the value of attribute committer.



4
5
6
# File 'lib/fuselage/commit.rb', line 4

def committer
  @committer
end

#messageObject

Returns the value of attribute message.



4
5
6
# File 'lib/fuselage/commit.rb', line 4

def message
  @message
end

#parentsObject

Returns the value of attribute parents.



4
5
6
# File 'lib/fuselage/commit.rb', line 4

def parents
  @parents
end

#shaObject

Returns the value of attribute sha.



4
5
6
# File 'lib/fuselage/commit.rb', line 4

def sha
  @sha
end

#treeObject

Returns the value of attribute tree.



4
5
6
# File 'lib/fuselage/commit.rb', line 4

def tree
  @tree
end

#urlObject

Returns the value of attribute url.



4
5
6
# File 'lib/fuselage/commit.rb', line 4

def url
  @url
end

Class Method Details

.create(repo, message, tree, parents = [], options = {}) ⇒ Object

Create a commit

Options:

:author
   :name
   :date
   :email
:committer
   :name
   :date
   :email

 examples:
   Commit.create('cockpit', 'This is a new commit', '45f6d8e74e145b910be4e15f67ef3892fe7abb26', ['45f6d8e74e145b910be4e15f67ef3892fe7abb26'])

   Commit.create('cockpit', 'Comit with author', '45f6d8e74e145b910be4e15f67ef3892fe7abb26', ['45f6d8e74e145b910be4e15f67ef3892fe7abb26'], {
     :author => {:name => 'Corey', :email => '[email protected]'}
   })


34
35
36
37
38
39
# File 'lib/fuselage/commit.rb', line 34

def self.create(repo, message, tree, parents=[], options={})
  raise AuthenticationRequired unless Api.authenticated
  params = {:message => message, :tree => tree, :parents => parents}.merge(options)
  user = User.current.
  Commit.new(post("/repos/#{user}/#{repo}/git/commits", params))
end

.find(repo, sha, user = nil) ⇒ Object

Find a commit

examples:
  Blob.find('cockpit', '45f6d8e74e145b910be4e15f67ef3892fe7abb26')


10
11
12
13
14
# File 'lib/fuselage/commit.rb', line 10

def self.find(repo, sha, user=nil)
  raise AuthenticationRequired unless Api.authenticated
  user ||= User.current.
  Commit.new(get("/repos/#{user}/#{repo}/git/commits/#{sha}"))
end

Instance Method Details

#merge_attributes(attributes) ⇒ Object



41
42
43
44
45
46
# File 'lib/fuselage/commit.rb', line 41

def merge_attributes(attributes)
  attributes.each do |key, value|
    method = "#{key}="
    self.send(method, value) if respond_to? method
  end
end