Class: YKUtitlityGitModule::YKGitManager

Inherits:
Object
  • Object
show all
Includes:
YKPod::YKLogTool
Defined in:
lib/cocoapods-ykutility/command/push/yk_git_manager.rb

Instance Method Summary collapse

Methods included from YKPod::YKLogTool

#ykError, #ykMessage, #ykNotice, #ykWarning

Constructor Details

#initialize(dir) ⇒ YKGitManager

Returns a new instance of YKGitManager.



25
26
27
28
29
30
31
# File 'lib/cocoapods-ykutility/command/push/yk_git_manager.rb', line 25

def initialize(dir)
  @dir = dir

  Dir.chdir(dir) do
    @git = Git.open(Dir.pwd)
  end
end

Instance Method Details

#commit_for_api(commit_message) ⇒ Object



42
43
44
45
46
47
48
49
50
# File 'lib/cocoapods-ykutility/command/push/yk_git_manager.rb', line 42

def commit_for_api(commit_message)
  begin
    @git.add(:all => true)
    @git.commit(commit_message)
    @git.push('origin', @git.current_branch)
  rescue Git::FailedError => e
    puts(e.to_s)
  end
end

#prepareObject



33
34
35
36
37
38
39
40
# File 'lib/cocoapods-ykutility/command/push/yk_git_manager.rb', line 33

def prepare
  is_clean = @git.is_clean
  if is_clean == false
    ykNotice("work tree dirty, work finish") unless is_clean
    return false
  end
  return true
end

#update_tag(dest_tag) ⇒ Object



52
53
54
55
# File 'lib/cocoapods-ykutility/command/push/yk_git_manager.rb', line 52

def update_tag(dest_tag)
  delete_dest_tag(dest_tag.to_s) # 删除原有tag
  create_dest_tag(dest_tag.to_s) # 新建tag
end