Class: WithGitRepo

Inherits:
Object
  • Object
show all
Defined in:
lib/with_git_repo.rb,
lib/with_git_repo/version.rb

Constant Summary collapse

VERSION =
'0.3.0'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ WithGitRepo

Returns a new instance of WithGitRepo.



9
10
11
12
13
# File 'lib/with_git_repo.rb', line 9

def initialize(options = {})
  @clone_url = options.fetch(:clone_url)
  @user_name = options.fetch(:user_name, 'with_git_repo')
  @user_email = options.fetch(:user_email, '[email protected]')
end

Instance Attribute Details

#clone_urlObject (readonly)

Returns the value of attribute clone_url.



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

def clone_url
  @clone_url
end

#user_emailObject (readonly)

Returns the value of attribute user_email.



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

def user_email
  @user_email
end

#user_nameObject (readonly)

Returns the value of attribute user_name.



6
7
8
# File 'lib/with_git_repo.rb', line 6

def user_name
  @user_name
end

Instance Method Details

#commit_changes_to_branch(branch, message) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/with_git_repo.rb', line 15

def commit_changes_to_branch(branch, message)
  checkout_branch!(branch)
  git.chdir { yield }
  git.add
  return unless git.status.changed.any? || git.status.added.any?
  git.commit(message)
  git.push('origin', branch)
end