change reponame to identifier
This commit is contained in:
parent
7b1b03ab41
commit
11023cbc70
|
@ -958,305 +958,7 @@ class ApplicationController < ActionController::Base
|
|||
# author: zxh
|
||||
# blockchain相关项目活动调用函数
|
||||
# return true: 表示上链操作成功; return false: 表示上链操作失败
|
||||
# 北大数瑞的被注释掉
|
||||
#def push_activity_2_blockchain(activity_type, model)
|
||||
# if activity_type == "issue_create"
|
||||
#
|
||||
# project_id = model['project_id']
|
||||
# project = Project.find(project_id)
|
||||
# if project['use_blockchain'] == 0 || project['use_blockchain'] == false
|
||||
# # 无需执行上链操作
|
||||
# return true
|
||||
# end
|
||||
#
|
||||
# id = model['id']
|
||||
#
|
||||
# owner_id = project['user_id']
|
||||
# owner = User.find(owner_id)
|
||||
# ownername = owner['login']
|
||||
# reponame = project['name']
|
||||
#
|
||||
# author_id = project['user_id']
|
||||
# author = User.find(author_id)
|
||||
# username = author['login']
|
||||
#
|
||||
# action = 'opened'
|
||||
#
|
||||
# title = model['subject']
|
||||
# content = model['description']
|
||||
# created_at = model['created_on']
|
||||
# updated_at = model['updated_on']
|
||||
#
|
||||
# # 调用区块链接口
|
||||
# param = {
|
||||
# "action": "executeContract",
|
||||
# "contractID": "RepositoryDB1",
|
||||
# "operation": "putIssue",
|
||||
# "arg": {
|
||||
# "issue_id": id,
|
||||
# "repo_id": project_id,
|
||||
# "reponame": reponame,
|
||||
# "ownername": ownername,
|
||||
# "username": username,
|
||||
# "action": action,
|
||||
# "title": title,
|
||||
# "content": content,
|
||||
# "created_at": created_at,
|
||||
# "updated_at": updated_at
|
||||
# }.to_json
|
||||
# }.to_json
|
||||
# success_blockchain = invoke_blockchain_api(Blockchain.blockchain_config[:api_url], param)
|
||||
# return success_blockchain
|
||||
#
|
||||
# elsif activity_type == "issue_comment_create"
|
||||
# issue_comment_id = model['id']
|
||||
# issue_id = model['journalized_id']
|
||||
# parent_id = model['parent_id'].nil? ? "" : model['parent_id']
|
||||
#
|
||||
# issue = Issue.find(issue_id)
|
||||
# issue_classify = issue['issue_classify'] # issue或pull_request
|
||||
# project_id = issue['project_id']
|
||||
# project = Project.find(project_id)
|
||||
#
|
||||
# if project['use_blockchain'] == 0 || project['use_blockchain'] == false
|
||||
# # 无需执行上链操作
|
||||
# return true
|
||||
# end
|
||||
#
|
||||
# reponame = project['name']
|
||||
# owner_id = project['user_id']
|
||||
# owner = User.find(owner_id)
|
||||
# ownername = owner['login']
|
||||
#
|
||||
# author_id = model['user_id']
|
||||
# author = User.find(author_id)
|
||||
# username = author['login']
|
||||
#
|
||||
# action = 'created'
|
||||
#
|
||||
# content = model['notes']
|
||||
# created_at = model['created_on']
|
||||
#
|
||||
# if issue_classify == "issue"
|
||||
# param = {
|
||||
# "action": "executeContract",
|
||||
# "contractID": "RepositoryDB1",
|
||||
# "operation": "putIssueComment",
|
||||
# "arg": {
|
||||
# "issue_comment_id": issue_comment_id,
|
||||
# "issue_id": issue_id,
|
||||
# "parent_id": parent_id,
|
||||
# "reponame": reponame,
|
||||
# "ownername": ownername,
|
||||
# "username": username,
|
||||
# "action": action,
|
||||
# "content": content,
|
||||
# "created_at": created_at,
|
||||
# }.to_json
|
||||
# }.to_json
|
||||
# elsif issue_classify == "pull_request"
|
||||
# param = {
|
||||
# "action": "executeContract",
|
||||
# "contractID": "RepositoryDB0",
|
||||
# "operation": "putPullRequestComment",
|
||||
# "arg": {
|
||||
# "pull_request_comment_id": issue_comment_id,
|
||||
# "pull_request_id": issue_id,
|
||||
# "parent_id": parent_id,
|
||||
# "reponame": reponame,
|
||||
# "ownername": ownername,
|
||||
# "username": username,
|
||||
# "action": action,
|
||||
# "content": content,
|
||||
# "created_at": created_at,
|
||||
# }.to_json
|
||||
# }.to_json
|
||||
# end
|
||||
#
|
||||
# # 调用区块链接口
|
||||
# success_blockchain = invoke_blockchain_api(Blockchain.blockchain_config[:api_url], param)
|
||||
# return success_blockchain
|
||||
# elsif activity_type == "pull_request_create"
|
||||
# # 调用区块链接口
|
||||
# project_id = model['project_id']
|
||||
# project = Project.find(project_id)
|
||||
# if project['use_blockchain'] == 0 || project['use_blockchain'] == false
|
||||
# # 无需执行上链操作
|
||||
# return true
|
||||
# end
|
||||
#
|
||||
# pull_request_id = model['id']
|
||||
# reponame = project['name']
|
||||
# owner_id = project['user_id']
|
||||
# owner = User.find(owner_id)
|
||||
# ownername = owner['login']
|
||||
#
|
||||
# action = 'opened'
|
||||
#
|
||||
# title = model['title']
|
||||
# content = model['body']
|
||||
#
|
||||
# source_branch = model['head']
|
||||
# source_repo_id = model['fork_project_id'].nil? ? project_id : model['fork_project_id']
|
||||
#
|
||||
# target_branch = model['base']
|
||||
# target_repo_id = project_id
|
||||
#
|
||||
# author_id = model['user_id']
|
||||
# author = User.find(author_id)
|
||||
# username = author['login']
|
||||
#
|
||||
# created_at = model['created_at']
|
||||
# updated_at = model['updated_at']
|
||||
#
|
||||
# # 查询pull request对应的commit信息
|
||||
# commits = Gitea::PullRequest::CommitsService.call(ownername, reponame, model['gitea_number'])
|
||||
# commit_shas = []
|
||||
# commits.each do |c|
|
||||
# commit_shas << c["Sha"]
|
||||
# end
|
||||
# param = {
|
||||
# "action": "executeContract",
|
||||
# "contractID": "RepositoryDB0",
|
||||
# "operation": "putPullRequest",
|
||||
# "arg": {
|
||||
# "pull_request_id": pull_request_id,
|
||||
# "repo_id": project_id,
|
||||
# "ownername": ownername,
|
||||
# "reponame": reponame,
|
||||
# "username": username,
|
||||
# "action": action,
|
||||
# "title": title,
|
||||
# "content": content,
|
||||
# "source_branch": source_branch,
|
||||
# "target_branch": target_branch,
|
||||
# "commit_shas": commit_shas,
|
||||
# "created_at": created_at,
|
||||
# "updated_at": updated_at
|
||||
# }.to_json
|
||||
# }.to_json
|
||||
# success_blockchain = invoke_blockchain_api(Blockchain.blockchain_config[:api_url], param)
|
||||
# return success_blockchain
|
||||
# elsif activity_type == "pull_request_merge"
|
||||
#
|
||||
# # 调用区块链接口
|
||||
# project_id = model['project_id']
|
||||
# project = Project.find(project_id)
|
||||
# if project['use_blockchain'] == 0 || project['use_blockchain'] == false
|
||||
# # 无需执行上链操作
|
||||
# return true
|
||||
# end
|
||||
#
|
||||
# pull_request_id = model['id']
|
||||
# reponame = project['name']
|
||||
# owner_id = project['user_id']
|
||||
# owner = User.find(owner_id)
|
||||
# ownername = owner['login']
|
||||
#
|
||||
# action = 'merged'
|
||||
#
|
||||
# # 查询pull request对应的commit信息
|
||||
# commits = Gitea::PullRequest::CommitsService.call(ownername, reponame, model['gitea_number'])
|
||||
# commit_shas = []
|
||||
# commits.each do |c|
|
||||
# commit_shas << c["Sha"]
|
||||
# end
|
||||
#
|
||||
# # 将pull request相关信息写入链上
|
||||
# param = {
|
||||
# "action": "executeContract",
|
||||
# "contractID": "RepositoryDB0",
|
||||
# "operation": "putPullRequest",
|
||||
# "arg": {
|
||||
# "pull_request_id": pull_request_id,
|
||||
# "repo_id": project_id,
|
||||
# "ownername": ownername,
|
||||
# "reponame": reponame,
|
||||
# "username": username,
|
||||
# "action": action,
|
||||
# "title": title,
|
||||
# "content": content,
|
||||
# "source_branch": source_branch,
|
||||
# "target_branch": target_branch,
|
||||
# "commit_shas": commit_shas,
|
||||
# "created_at": created_at,
|
||||
# "updated_at": updated_at
|
||||
# }.to_json
|
||||
# }.to_json
|
||||
# success_blockchain = invoke_blockchain_api(Blockchain.blockchain_config[:api_url], param)
|
||||
#
|
||||
#
|
||||
# # 将commit相关信息写入链上
|
||||
# commit_shas.each do |commit_sha|
|
||||
# commit_diff = Gitea::Commit::DiffService.call(ownername, reponame, commit_sha)
|
||||
# commit = Gitea::Commit::InfoService.call(ownername, reponame, commit_sha)
|
||||
# param = {
|
||||
# "action": "executeContract",
|
||||
# "contractID": "RepositoryDB1",
|
||||
# "operation": "putCommit",
|
||||
# "arg": {
|
||||
# "commit_hash": commit_sha,
|
||||
# "repo_id": project_id,
|
||||
# "author": commit['author']['login'],
|
||||
# "author_email": commit['author']['email'],
|
||||
# "committer": commit['committer']['login'],
|
||||
# "committer_email": commit['committer']['email'],
|
||||
# "author_time": commit['commit']['author']['date'],
|
||||
# "committer_time": commit['commit']['committer']['date'],
|
||||
# "message": commit['commit']['message'],
|
||||
# "diff": commit_diff['Files']
|
||||
# }.to_json
|
||||
# }.to_json
|
||||
# success_blockchain_commit = invoke_blockchain_api(Blockchain.blockchain_config[:api_url], param)
|
||||
# success_blockchain = success_blockchain & success_blockchain_commit
|
||||
# end
|
||||
# return success_blockchain
|
||||
#
|
||||
# elsif activity_type == "pull_request_refuse"
|
||||
#
|
||||
# # 调用区块链接口
|
||||
# project_id = model['project_id']
|
||||
# project = Project.find(project_id)
|
||||
# if project['use_blockchain'] == 0 || project['use_blockchain'] == false
|
||||
# # 无需执行上链操作
|
||||
# return true
|
||||
# end
|
||||
#
|
||||
# pull_request_id = model['id']
|
||||
# reponame = project['name']
|
||||
# owner_id = project['user_id']
|
||||
# owner = User.find(owner_id)
|
||||
# ownername = owner['login']
|
||||
#
|
||||
# action = 'refused'
|
||||
#
|
||||
# # 将pull request相关信息写入链上
|
||||
# param = {
|
||||
# "action": "executeContract",
|
||||
# "contractID": "RepositoryDB0",
|
||||
# "operation": "putPullRequest",
|
||||
# "arg": {
|
||||
# "pull_request_id": pull_request_id,
|
||||
# "repo_id": project_id,
|
||||
# "ownername": ownername,
|
||||
# "reponame": reponame,
|
||||
# "username": username,
|
||||
# "action": action,
|
||||
# "title": title,
|
||||
# "content": content,
|
||||
# "source_branch": source_branch,
|
||||
# "target_branch": target_branch,
|
||||
# "created_at": created_at,
|
||||
# "updated_at": updated_at
|
||||
# }.to_json
|
||||
# }.to_json
|
||||
# success_blockchain = invoke_blockchain_api(Blockchain.blockchain_config[:api_url], param)
|
||||
# return success_blockchain
|
||||
# end
|
||||
#end
|
||||
|
||||
|
||||
def push_activity_2_blockchain(activity_type, model)
|
||||
def push_activity_2_blockchain(activity_type, model)
|
||||
if activity_type == "issue_create"
|
||||
|
||||
project_id = model['project_id']
|
||||
|
@ -1271,7 +973,7 @@ class ApplicationController < ActionController::Base
|
|||
owner_id = project['user_id']
|
||||
owner = User.find(owner_id)
|
||||
ownername = owner['login']
|
||||
reponame = project['name']
|
||||
identifier = project['identifier']
|
||||
|
||||
author_id = project['user_id']
|
||||
author = User.find(author_id)
|
||||
|
@ -1290,7 +992,7 @@ class ApplicationController < ActionController::Base
|
|||
"issue_id": "gitlink-" + id.to_s,
|
||||
"repo_id": "gitlink-" + project_id.to_s,
|
||||
"issue_number": 0, # 暂时不需要改字段
|
||||
"reponame": reponame,
|
||||
"reponame": identifier,
|
||||
"ownername": ownername,
|
||||
"username": username,
|
||||
"action": action,
|
||||
|
@ -1317,7 +1019,7 @@ class ApplicationController < ActionController::Base
|
|||
return true
|
||||
end
|
||||
|
||||
reponame = project['name']
|
||||
identifier = project['identifier']
|
||||
owner_id = project['user_id']
|
||||
owner = User.find(owner_id)
|
||||
ownername = owner['login']
|
||||
|
@ -1340,7 +1042,7 @@ class ApplicationController < ActionController::Base
|
|||
"issue_id": "gitlink-" + issue_id.to_s,
|
||||
"repo_id": "gitlink-" + project.id.to_s,
|
||||
"parent_id": parent_id.to_s,
|
||||
"reponame": reponame,
|
||||
"reponame": identifier,
|
||||
"ownername": ownername,
|
||||
"username": username,
|
||||
"action": action,
|
||||
|
@ -1356,7 +1058,7 @@ class ApplicationController < ActionController::Base
|
|||
"pull_request_id": "gitlink-" + issue_id.to_s,
|
||||
"parent_id": parent_id.to_s,
|
||||
"repo_id": "gitlink-" + project.id.to_s,
|
||||
"reponame": reponame,
|
||||
"reponame": identifier,
|
||||
"ownername": ownername,
|
||||
"username": username,
|
||||
"action": action,
|
||||
|
@ -1379,7 +1081,6 @@ class ApplicationController < ActionController::Base
|
|||
|
||||
pull_request_id = model['id']
|
||||
identifier = project['identifier']
|
||||
reponame = project['reponame']
|
||||
owner_id = project['user_id']
|
||||
owner = User.find(owner_id)
|
||||
ownername = owner['login']
|
||||
|
@ -1417,7 +1118,7 @@ class ApplicationController < ActionController::Base
|
|||
"pull_request_number": 0, # trustie没有该字段
|
||||
"repo_id": "gitlink-" + project_id.to_s,
|
||||
"ownername": ownername,
|
||||
"reponame": reponame,
|
||||
"reponame": identifier,
|
||||
"username": username,
|
||||
"action": action,
|
||||
"title": title,
|
||||
|
@ -1444,7 +1145,6 @@ class ApplicationController < ActionController::Base
|
|||
|
||||
pull_request_id = model['id']
|
||||
identifier = project['identifier']
|
||||
reponame = project['reponame']
|
||||
owner_id = project['user_id']
|
||||
owner = User.find(owner_id)
|
||||
ownername = owner['login']
|
||||
|
@ -1471,7 +1171,7 @@ class ApplicationController < ActionController::Base
|
|||
"pull_request_number": 0, # trustie没有该字段
|
||||
"repo_id": "gitlink-" + project_id.to_s,
|
||||
"ownername": ownername,
|
||||
"reponame": reponame,
|
||||
"reponame": identifier,
|
||||
"username": username,
|
||||
"action": action,
|
||||
"title": title,
|
||||
|
@ -1489,8 +1189,8 @@ class ApplicationController < ActionController::Base
|
|||
|
||||
# 将commit相关信息写入链上
|
||||
commit_shas.each do |commit_sha|
|
||||
commit_diff = Gitea::Commit::DiffService.call(ownername, reponame, commit_sha, owner['gitea_token'])
|
||||
commit = Gitea::Commit::InfoService.call(ownername, reponame, commit_sha, owner['gitea_token'])
|
||||
commit_diff = Gitea::Commit::DiffService.call(ownername, identifier, commit_sha, owner['gitea_token'])
|
||||
commit = Gitea::Commit::InfoService.call(ownername, identifier, commit_sha, owner['gitea_token'])
|
||||
param = {
|
||||
"request-type": "upload commit info",
|
||||
"commit_hash": commit_sha,
|
||||
|
@ -1520,7 +1220,7 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
|
||||
pull_request_id = model['id']
|
||||
reponame = project['name']
|
||||
identifier = project['identifier']
|
||||
owner_id = project['user_id']
|
||||
owner = User.find(owner_id)
|
||||
ownername = owner['login']
|
||||
|
@ -1534,7 +1234,7 @@ class ApplicationController < ActionController::Base
|
|||
"pull_request_number": 0, # trustie没有该字段
|
||||
"repo_id": "gitlink-" + project_id.to_s,
|
||||
"ownername": ownername,
|
||||
"reponame": reponame,
|
||||
"reponame": identifier,
|
||||
"username": username,
|
||||
"action": action,
|
||||
"title": title,
|
||||
|
|
Loading…
Reference in New Issue