add reponame

This commit is contained in:
nigel007 2019-06-07 18:44:46 +08:00
parent 28951b11bf
commit 883729ed9a
2 changed files with 10 additions and 9 deletions

View File

@ -60,14 +60,12 @@ module Mobile
authenticate!
# 根据repo_git_url找到repository对应的项目
rs = RepositoriesService.new
status, project = rs.findProjectByRepoUrl(params[:repo_url])
status, project, reponame = rs.findProjectByRepoUrl(params[:repo_url])
if project
blockchain = Blockchain.find_by_project_id(project.id)
if blockchain
Rails.logger.info("!!!!!!!!!find the project's blockchain info")
{status:status, genesis_content:blockchain["genesis_content"], network_id:blockchain["network_id"], connect_ip:blockchain["connect_ip"], port:blockchain["port"], enode:blockchain["enode"]}
{status:status, reponame: repo_name, genesis_content:blockchain["genesis_content"], network_id:blockchain["network_id"], connect_ip:blockchain["connect_ip"], port:blockchain["port"], enode:blockchain["enode"]}
else
Rails.logger.info("!!!!!!!!!not find the project's blockchain info")
{status:-1, message: '数据库有问题blockchain信息不存在'}
end
else

View File

@ -48,6 +48,7 @@ class RepositoriesService
status = -1
# 解析ownername
owner_name = nil
repo_name = nil
begin
index_doublesplit = repo_url.index("//")
# gitlab_address = Redmine::Configuration['gitlab_address']
@ -56,16 +57,18 @@ class RepositoriesService
gitlab_address = gitlab_address[index_split + 1..gitlab_address.length - 1]
index_split = gitlab_address.index("/")
owner_name = gitlab_address[0..index_split - 1]
index_dotgit = gitlab_address.index(".git")
repo_name = gitlab_address[index_split + 1..index_dotgit - 1]
rescue => e
Rails.logger.error("!!!!!!!!!!!!error with the repo_url: " + repo_url)
return status, nil
return status, nil, nil
end
owner = User.find_by_login(owner_name)
if owner
projects = Project.find_all_by_user_id(owner.id)
if projects.length <= 0
return status, nil
return status, nil, nil
else
projects.each do |project|
gpid = project.gpid
@ -74,15 +77,15 @@ class RepositoriesService
if http_url_to_repo
if repo_url == http_url_to_repo
status = 0
return status, project # 表示找到了
return status, project, repo_name # 表示找到了
end
end
end
end
return status, nil # 表示没找到
return status, nil, nil # 表示没找到
end
else
return status, nil # 表示数据库有问题没有对应的owner
return status, nil, nil # 表示数据库有问题没有对应的owner
end
end