Class: GitDataCommits

Inherits:
Object
  • Object
show all
Defined in:
lib/github/gitdata/gitdata_commits.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(github) ⇒ GitDataCommits

Returns a new instance of GitDataCommits.



4
5
6
# File 'lib/github/gitdata/gitdata_commits.rb', line 4

def initialize(github)
  @github = github
end

Instance Attribute Details

#githubObject

Returns the value of attribute github.



2
3
4
# File 'lib/github/gitdata/gitdata_commits.rb', line 2

def github
  @github
end

Instance Method Details

#createCommit(repo, message, tree, parents, authorName = nil, authorEmail = nil, authorDate = nil, committerName = nil, committerEmail = nil, commiterDate = nil, user = nil) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/github/gitdata/gitdata_commits.rb', line 14

def createCommit(repo, message, tree, parents, authorName=nil,
    authorEmail=nil, authorDate=nil, committerName=nil,
    committerEmail=nil, commiterDate=nil, user=nil)
  username = user == nil ? @github.username : user
  author = {
      :name => authorName,
      :email => authorEmail,
      :date => authorDate,
  }
  author = @github.removeEmptyParams(author)
  committer = {
      :name => committerName,
      :email => committerEmail,
      :date => commiterDate
  }
  committer = @github.removeEmptyParams(committer)
  params = {
      :message => message,
      :author => author,
      :committer => committer,
      :parents => parents,
      :tree => tree
  }
  params = @github.removeEmptyParams(params)
  data = params.to_json
  @github.post(
      'repos/%s/%s/git/commits' % [username, repo], data)
end

#getCommit(repo, sha, user = nil) ⇒ Object



8
9
10
11
12
# File 'lib/github/gitdata/gitdata_commits.rb', line 8

def getCommit(repo, sha, user=nil)
  username = user == nil ? @github.username : user
  @github.get(
      'repos/%s/%s/git/commits/%s' % [username, repo, sha])
end