change the acquire of project's owner name

This commit is contained in:
nigel007 2019-06-07 16:38:19 +08:00
parent 192ee15a59
commit 55009f2365
1 changed files with 13 additions and 5 deletions

View File

@ -47,11 +47,19 @@ class RepositoriesService
def findProjectByRepoUrl repo_url
status = -1
# 解析ownername
gitlab_address = Redmine::Configuration['gitlab_address']
gitlab_address = gitlab_address[gitlab_address.index("//") + 2..gitlab_address.length - 1]
repo_url = repo_url[repo_url.index(gitlab_address) + gitlab_address.length + 1..repo_url.length - 1]
index_split = repo_url.index("/")
owner_name = repo_url[0..index_split - 1]
owner_name = nil
begin
index_doublesplit = repo_url.index("//")
# gitlab_address = Redmine::Configuration['gitlab_address']
gitlab_address = repo_url[index_doublesplit + 2..repo_url.length - 1]
index_split = gitlab_address.index("/")
gitlab_address = gitlab_address[index_split + 1..gitlab_address.length - 1]
index_split = gitlab_address.index("/")
owner_name = gitlab_address[0..index_split - 1]
rescue => e
Rails.logger.error("error with the repo_url: " + repo_url)
return status, nil
end
owner = User.find_by_login(owner_name)
if owner