add modificationLines function
This commit is contained in:
parent
0e8e39ee8c
commit
a56e888ef5
|
@ -91,6 +91,16 @@ module Mobile
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
###
|
||||||
|
#
|
||||||
|
# 测试
|
||||||
|
# ##
|
||||||
|
desc "测试"
|
||||||
|
get 'test' do
|
||||||
|
puts "pause"
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
desc "获取两次代码提交之间的区别"
|
desc "获取两次代码提交之间的区别"
|
||||||
params do
|
params do
|
||||||
requires :username, type: String
|
requires :username, type: String
|
||||||
|
@ -115,6 +125,8 @@ module Mobile
|
||||||
branch_sha_array << branch_commit.id
|
branch_sha_array << branch_commit.id
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# modificationLines = 0
|
||||||
|
|
||||||
params[:shaList].each do |sha|
|
params[:shaList].each do |sha|
|
||||||
# Rails.logger.info project.gpid
|
# Rails.logger.info project.gpid
|
||||||
commit = g.commit(project.gpid, sha)
|
commit = g.commit(project.gpid, sha)
|
||||||
|
@ -129,8 +141,22 @@ module Mobile
|
||||||
else
|
else
|
||||||
result << false
|
result << false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# add by qiubing
|
||||||
|
# commit_diff = g.commit_diff(project.gpid, sha)
|
||||||
|
# (0...commit_diff.length).each do |i|
|
||||||
|
# tempDiff = commit_diff[i]
|
||||||
|
# tempDiffArry = tempDiff.diff.split("\n")
|
||||||
|
# (2...tempDiffArry.length).each do |j|
|
||||||
|
# if tempDiffArry[j][0] == "+" or tempDiffArry[j][0] == "-"
|
||||||
|
# modificationLines += 1
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
# end by qiubing
|
||||||
end
|
end
|
||||||
{status:0, result:result}
|
{status:0, result:result}
|
||||||
|
# {status:0, result:result, modificationLines:modificationLines}
|
||||||
else
|
else
|
||||||
{status:1, message: '该项目不存在或已被删除' }
|
{status:1, message: '该项目不存在或已被删除' }
|
||||||
end
|
end
|
||||||
|
|
|
@ -308,6 +308,10 @@ class PullRequestsController < ApplicationController
|
||||||
pushTXInfo["author_id"] = author_id
|
pushTXInfo["author_id"] = author_id
|
||||||
|
|
||||||
commits = @g.merge_request_commits(@project.gpid, params[:id])
|
commits = @g.merge_request_commits(@project.gpid, params[:id])
|
||||||
|
|
||||||
|
# 获取版本库名称
|
||||||
|
versionName = @g.project(@project.gpid).name
|
||||||
|
|
||||||
shas = []
|
shas = []
|
||||||
commits.each do |c|
|
commits.each do |c|
|
||||||
itemHash = Hash.new
|
itemHash = Hash.new
|
||||||
|
@ -333,12 +337,42 @@ class PullRequestsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
pushTXInfo["shas"] = shas # 后续修改为shaList
|
pushTXInfo["shas"] = shas # 后续修改为shaList
|
||||||
|
|
||||||
|
# commitInfo = @g.commit(@project.gpid, shas[0])
|
||||||
|
modificationLines = 0
|
||||||
|
(0...shas.length).each do |z|
|
||||||
|
commit_diff = @g.commit_diff(@project.gpid, shas[z])
|
||||||
|
(0...commit_diff.length).each do |i|
|
||||||
|
tempDiff = commit_diff[i]
|
||||||
|
tempDiffArry = tempDiff.diff.split("\n")
|
||||||
|
(2...tempDiffArry.length).each do |j|
|
||||||
|
# if tempDiffArry[j].match(/^\+/) != nil or tempDiffArry[j].match(/^-/) != nil
|
||||||
|
if tempDiffArry[j][0] == "+" or tempDiffArry[j][0] == "-"
|
||||||
|
modificationLines += 1
|
||||||
|
# else
|
||||||
|
# # puts "shitttttty"
|
||||||
|
# next
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
# commit_diff = @g.commit_diff(@project.gpid, shas[-1])
|
||||||
|
|
||||||
|
puts "!!!!!!!!!!!!!!!!!!@@@@@@@@@@@" + modificationLines.to_s
|
||||||
|
|
||||||
|
pushTXInfo["modificationLines"] = modificationLines
|
||||||
|
|
||||||
pushTXInfoJson = pushTXInfo.to_json
|
pushTXInfoJson = pushTXInfo.to_json
|
||||||
|
# realReponame = @project.name
|
||||||
|
# realReponameStr = realReponame.to_s
|
||||||
|
# realReponameStr1 = realReponameStr.join("")
|
||||||
# 发送交易
|
# 发送交易
|
||||||
Rails.logger.info("before executing chain_trustie command...")
|
Rails.logger.info("before executing chain_trustie command...")
|
||||||
Rails.logger.info(pushTXInfoJson)
|
Rails.logger.info(pushTXInfoJson)
|
||||||
cmd = 'chain_trustie pushPRTX ' + pushTXInfoJson
|
|
||||||
|
cmd = 'fabricChain trustiePush '+author_name+'-'+versionName+' ' + pushTXInfoJson
|
||||||
Rails.logger.info(cmd)
|
Rails.logger.info(cmd)
|
||||||
|
puts cmd
|
||||||
|
|
||||||
# result = system # 执行失败了
|
# result = system # 执行失败了
|
||||||
output = StringIO.new
|
output = StringIO.new
|
||||||
|
@ -348,6 +382,7 @@ class PullRequestsController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Rails.logger.info(output.string)
|
Rails.logger.info(output.string)
|
||||||
|
puts output.string
|
||||||
# Rails.logger.info(result)
|
# Rails.logger.info(result)
|
||||||
Rails.logger.info("after executing chain_trustie command...")
|
Rails.logger.info("after executing chain_trustie command...")
|
||||||
# add by zxh end
|
# add by zxh end
|
||||||
|
|
Loading…
Reference in New Issue