Class: RoboPigeon::GitLab::Commit

Inherits:
Object
  • Object
show all
Defined in:
lib/robopigeon/gitlab/commit.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCommit

Returns a new instance of Commit.



4
5
6
7
8
9
# File 'lib/robopigeon/gitlab/commit.rb', line 4

def initialize
  self.files = []
  self.author_name = ENV['GITLAB_USER_NAME']
  self.author_email = ENV['GITLAB_USER_EMAIL']
  self.branch = RoboPigeon::GitLab::Client.branch
end

Instance Attribute Details

#author_emailObject

Returns the value of attribute author_email.



3
4
5
# File 'lib/robopigeon/gitlab/commit.rb', line 3

def author_email
  @author_email
end

#author_nameObject

Returns the value of attribute author_name.



3
4
5
# File 'lib/robopigeon/gitlab/commit.rb', line 3

def author_name
  @author_name
end

#branchObject

Returns the value of attribute branch.



3
4
5
# File 'lib/robopigeon/gitlab/commit.rb', line 3

def branch
  @branch
end

#filesObject

Returns the value of attribute files.



3
4
5
# File 'lib/robopigeon/gitlab/commit.rb', line 3

def files
  @files
end

#messageObject

Returns the value of attribute message.



3
4
5
# File 'lib/robopigeon/gitlab/commit.rb', line 3

def message
  @message
end

Instance Method Details

#add_file(file, content = nil, method = 'update') ⇒ Object



11
12
13
14
# File 'lib/robopigeon/gitlab/commit.rb', line 11

def add_file(file, content=nil, method='update')
  content ||= File.read(file)
  files.push(action: method, file_path: file, content: content)
end

#clientObject



16
17
18
# File 'lib/robopigeon/gitlab/commit.rb', line 16

def client
  RoboPigeon::GitLab::Client.client
end

#commit!Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/robopigeon/gitlab/commit.rb', line 20

def commit!
  client.create_commit(
    RoboPigeon::GitLab::Client.project,
    branch,
    message,
    files,
    author_name: author_name,
    author_email: author_email
  )
end