diff --git a/app/api/mobile/apis/blockchains.rb b/app/api/mobile/apis/blockchains.rb index 760f5c9f7..d8d5e020f 100644 --- a/app/api/mobile/apis/blockchains.rb +++ b/app/api/mobile/apis/blockchains.rb @@ -91,6 +91,16 @@ module Mobile end end + ### + # + # 测试 + # ## + desc "测试" + get 'test' do + puts "pause" + end + + desc "获取两次代码提交之间的区别" params do requires :username, type: String @@ -115,6 +125,8 @@ module Mobile branch_sha_array << branch_commit.id end + # modificationLines = 0 + params[:shaList].each do |sha| # Rails.logger.info project.gpid commit = g.commit(project.gpid, sha) @@ -129,8 +141,22 @@ module Mobile else result << false 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 {status:0, result:result} + # {status:0, result:result, modificationLines:modificationLines} else {status:1, message: '该项目不存在或已被删除' } end diff --git a/app/controllers/pull_requests_controller.rb b/app/controllers/pull_requests_controller.rb index e95209033..531a564d8 100644 --- a/app/controllers/pull_requests_controller.rb +++ b/app/controllers/pull_requests_controller.rb @@ -308,6 +308,10 @@ class PullRequestsController < ApplicationController pushTXInfo["author_id"] = author_id commits = @g.merge_request_commits(@project.gpid, params[:id]) + + # 获取版本库名称 + versionName = @g.project(@project.gpid).name + shas = [] commits.each do |c| itemHash = Hash.new @@ -333,12 +337,42 @@ class PullRequestsController < ApplicationController end 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 + # realReponame = @project.name + # realReponameStr = realReponame.to_s + # realReponameStr1 = realReponameStr.join("") # 发送交易 Rails.logger.info("before executing chain_trustie command...") Rails.logger.info(pushTXInfoJson) - cmd = 'chain_trustie pushPRTX ' + pushTXInfoJson + + cmd = 'fabricChain trustiePush '+author_name+'-'+versionName+' ' + pushTXInfoJson Rails.logger.info(cmd) + puts cmd # result = system # 执行失败了 output = StringIO.new @@ -348,6 +382,7 @@ class PullRequestsController < ApplicationController end end Rails.logger.info(output.string) + puts output.string # Rails.logger.info(result) Rails.logger.info("after executing chain_trustie command...") # add by zxh end