Class: PodsOrz::PodsCheckMerge
- Inherits:
-
Object
- Object
- PodsOrz::PodsCheckMerge
- Defined in:
- lib/podsorz/core/PodsOrz/pods_check_merge.rb
Instance Method Summary collapse
-
#branchList(path) ⇒ Object
def check_Podfile(filePath) # 返回 path 的绝对路径,扩展 ~ 为进程所有者的主目录,~user 为用户的主目录。相对路径是相对于 dir 指定的目录,如果 dir 被省略则相对于当前工作目录 tempPath = File.expand_path(“Podfile”,filePath) result = File::exist?tempPath if result puts(“存在– #tempPath”) else puts(“不存在– #tempPath”) end tempPath end.
- #git_isMerged(branch, path) ⇒ Object
-
#localBranch(filePath, fileName) ⇒ Object
git log -n1 –format=format:“%H”.
Instance Method Details
#branchList(path) ⇒ Object
def check_Podfile(filePath)
# 返回 path 的绝对路径,扩展 ~ 为进程所有者的主目录,~user 为用户的主目录。相对路径是相对于 dir 指定的目录,如果 dir 被省略则相对于当前工作目录
tempPath = File.("Podfile",filePath)
result = File::exist?tempPath
if result
puts("存在-- #{tempPath}")
else
puts("不存在-- #{tempPath}")
end
tempPath
end
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/podsorz/core/PodsOrz/pods_check_merge.rb', line 21 def branchList(path) list = [] # IO.popen("cd '#{path}';git branch -r") do |io| # io.each do |line| # puts("branch -- #{line}") # # has_branch = true if line.include? branch_name # end # end # Open3.popen3("cd '#{File.dirname(__FILE__ )}';git branch -r"){|stdin, stdout, stderr, wait_thr| # while line = stdout.gets # puts("branch- #{line}") # end # } # puts "里层 #{@kx_pods_directory}" # kx_pods_path /Users/yuyutao/Desktop/rubyGem/kx_pods # 里层 /Library/Ruby/Gems/2.6.0/gems/podsorz-0.0.5/lib/podsorz/core/kx_pods # dir = Dir.open("#{@kx_pods_directory}") # while name = dir.read # p name # end # dir.close # @kx_pods_directory = "/Users/yuyutao/Desktop/rubyGem/kx_pods" Dir.open("#{path}") do |dir| tempAry = ['.','..'] dirAry = dir.to_a ary = dirAry-tempAry ary.each do |name| dir_path = "#{path}/#{name}" is_directory = File.directory?(dir_path) if is_directory localBranch("#{dir_path}",name) else # puts "#{name} 空文件" end end end end |
#git_isMerged(branch, path) ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/podsorz/core/PodsOrz/pods_check_merge.rb', line 117 def git_isMerged(branch,path) merge_destination_branch = "origin/develop" merge_source_branch = "#{branch}" merge_base = "" merge_current_commit = "" is_merge_all = true cmd = "cd '#{path}';git merge-base #{merge_destination_branch} #{branch}" IO.popen(cmd) do |io| io.each do |line| if line merge_base = line else puts("git merge-base 无hash值 #{path}") end end end cmd = "git rev-parse #{branch}" IO.popen("cd '#{path}';#{cmd}") do |io| io.each do |line| if line merge_current_commit = line else puts("git rev-parse 无hash值 #{path}") end end end if merge_base == merge_current_commit else is_merge_all = false end is_merge_all end |
#localBranch(filePath, fileName) ⇒ Object
git log -n1 –format=format:“%H”
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/podsorz/core/PodsOrz/pods_check_merge.rb', line 69 def localBranch(filePath,fileName) @git_operator = PodsOrz::GitOperator.new() has_changes = @git_operator.has_changes(filePath) if has_changes branch = @git_operator.current_branch(filePath) Logger.error("【#{filePath}】 on branch: \"#{branch}\" has unstaged/uncommit changes, please staged and commit local first") return end is_merge_all = true branch = "" Open3.popen3("cd '#{filePath}';git branch -l"){|stdin, stdout, stderr, wait_thr| if stdout.gets while line = stdout.gets if line.include? "master" # puts("master分支-#{fileName}") elsif line.include? "develop" # puts("develop分支-#{fileName}") elsif line.include? "release" # puts("release分支-#{fileName}") else # puts("#{fileName} branch- #{line}") branch = line.strip if branch.include? "*" branch.delete!("*",) end is_merge_all = git_isMerged("#{branch}",filePath) end end else # puts("未发现本地分支-#{fileName}") end } # puts("all commit success!") if is_merge_all if is_merge_all puts("check result: all commit success! #{filePath}") else Logger.warning("#{filePath} - #{branch} commit not merge") end end |