liuxiaoyun111 发表于 2018-1-12 14:48:42

ruby 规整git commit 信息

souNotesPath = '/home/shench/script/releaseNotes/'  
sdk_ProjectPath
= '/home/devProject/sdk/sense-crowd'  
sdk_crossline
= '/home/devProject/sdk/crossline'  
server_nodeProjectPath
= '/home/devProject/server/Crowd2.1-node'  
server_appProjectPath
= '/home/devProject/server/CrowdAnalyze-app'  
server_forwardProjectPath
= '/home/devProject/server/VideoForward'  
webStatic_projectPath
= '/home/devProject/web/crowd-web-static'  
webServer_projectPath
= '/home/devProject/web/crowd-web-server'  

  
branch
= ARGV.to_s.sub('[','').sub(']','')  
ciBranch
= ARGV.to_s.sub('[','').sub(']','')  
devBranch
= 'v2.3.0'  
sdk_CL_branch
= 'v1.0.0'  

  
system(
"cd /home/CrowdProduct;git checkout #{branch};git status;git pull #{branch} #{branch};cat>
#获取上次编译时间  
File.readlines('/home/CrowdProduct/releaseNotes.txt').each do |line|
  @lastBuilt = line.sub('build time:','') if line=~/build/
  
end
  
puts "last built time:#{@lastBuilt}"
  
puts "get git log"
  
source_releaseNotes = "git log --pretty=format:'%an | %cd | %s' --after=#{@lastBuilt.chomp.inspect}"
  
# puts source_releaseNotes
  

  
puts "get sdk git log"
  
#获取sdk编译日志
  
system("cd #{sdk_ProjectPath};pwd;git checkout #{devBranch};git pull #{devBranch} #{devBranch};git status;#{source_releaseNotes} > #{souNotesPath}sdk_sourceNotes.txt")
  
system("cd #{sdk_crossline};pwd;git checkout #{sdk_CL_branch};git pull #{sdk_CL_branch} #{sdk_CL_branch};git status;#{source_releaseNotes} > #{souNotesPath}sdk_CLsourceNotes.txt")
  

  
puts "get server git log"
  
#获取server编译日志
  
#node -tianshuai
  
system("cd #{server_nodeProjectPath};pwd;git checkout #{devBranch};git pull #{devBranch} #{devBranch};git status;#{source_releaseNotes} > #{souNotesPath}server_node_sourceNotes.txt;cat #{so
  
uNotesPath}server_node_sourceNotes.txt")
  

  
#app - kesong
  
system("cd #{server_appProjectPath};pwd;git checkout #{devBranch};git pull #{devBranch} #{devBranch};git status;#{source_releaseNotes} > #{souNotesPath}server_app_sourceNotes.txt;cat #{souN
  
otesPath}server_app_sourceNotes.txt")
  
#forward -zhongxing
  
system("cd #{server_forwardProjectPath};pwd;git checkout #{devBranch};git pull #{devBranch} #{devBranch};git status;#{source_releaseNotes} > #{souNotesPath}server_forward_sourceNotes.txt;ca
  
t #{souNotesPath}server_forward_sourceNotes.txt")
  

  
puts "get web git log"
  
#获取web编译日志system("cd #{web_projectPath};pwd;git checkout #{branch};git pull #{branch} #{branch};git status;#{source_releaseNotes} > #{souNotesPath}web_sourceNotes_#{branch}.txt;cat #{souNotesPath}w
  
eb_sourceNotes_#{branch}.txt")
  
system("cd #{webStatic_projectPath};pwd;git checkout #{branch};git pull #{branch} #{branch};git status;#{source_releaseNotes} > #{souNotesPath}webStatic_sourceNotes_#{branch}.txt;cat #{souN
  
otesPath}webStatic_sourceNotes_#{branch}.txt")
  
system("cd #{webServer_projectPath};pwd;git checkout #{branch};git pull #{branch} #{branch};git status;#{source_releaseNotes} > #{souNotesPath}webServer_sourceNotes_#{branch}.txt;cat #{souN
  
otesPath}webServer_sourceNotes_#{branch}.txt")
  

  
#规整输出日志
  
currTime = Time.now.strftime("%Y-%m-%d %H:%M")
  
puts "build time:#{currTime}"
  
file = File.open('releaseNotes.txt',"w+")
  
file.puts "build time:#{currTime}"
  
filter1 = 'gitlab-ci.yml'
  
filter2 = 'Merge branch'
  
filter3 = 'xxxxxhui'
  

  
File.readlines('sdk_sourceNotes.txt').each do |line|
  file.puts " 【sdk】"+line if !line.include?(filter1) and !line.include?(filter2) and !line.include?(filter3)
  
end
  
File.readlines('sdk_CLsourceNotes.txt').each do |line|
  file.puts " 【sdk】"+line if !line.include?(filter1) and !line.include?(filter2) and !line.include?(filter3)
  
end
  
File.readlines('server_node_sourceNotes.txt').each do |line|
  file.puts " 【server】"+line if !line.include?(filter1) and !line.include?(filter2)   and !line.include?(filter3)
  
end
  
File.readlines('server_app_sourceNotes.txt').each do |line|
  file.puts " 【server】"+line if !line.include?(filter1) and !line.include?(filter2)   and !line.include?(filter3)
  
end
  
File.readlines('server_forward_sourceNotes.txt').each do |line|
  file.puts " 【server】"+line if !line.include?(filter1) and !line.include?(filter2) and !line.include?(filter3)
  
end
  
File.readlines("webStatic_sourceNotes_#{branch.sub('"','').sub('"','')}.txt").each do |line|
  file.puts " 【web】"+line if !line.include?(filter1) and !line.include?(filter2) and !line.include?(filter3)
  
end
  
File.readlines("webServer_sourceNotes_#{branch.sub('"','').sub('"','')}.txt").each do |line|
  file.puts " 【web】"+line if !line.include?(filter1) and !line.include?(filter2) and !line.include?(filter3)
  
end
  
file.close

  
puts "format>  
system("pwd;cat #{souNotesPath}releaseNotes.txt;du -sh *")
页: [1]
查看完整版本: ruby 规整git commit 信息