
+ repo_url = [base_url, 'git'].join('.') + repo_dir = repo_url.split('/')[-1]
This is no need, git use this as the default
I need to remove the repo after check. so I need to get the repo name.
+ commit_id = url.split('/')[-1] + + Dir.chdir '/tmp' + %x(/usr/bin/git clone --bare #{repo_url} #{repo_dir})
Use %x(git -C /tmp clone --bare #{repo_url})
I will optimize it Thanks, Luan Shengde
Thanks, Xueliang
+ + # get all commit IDs and check commit id exists + repo_commits = %x(git -C #{repo_dir} log --pretty=format:'%H').split(/\n/) + check_commit_exist(commit_id, repo_commits)
- def gitee_commit(url, base_url) - my_gitee_commit = GiteeCommitUrlCheck.new(@my_info, url, base_url) - my_gitee_commit.gitee_commit_check + # get the auther's email for the commit + author_email = %x(/usr/bin/git -C #{repo_dir} show -s --format=%aE #{commit_id}).chomp + check_commit_email(author_email) + + FileUtils.rm_rf repo_dir end
- def non_gitee_commit(url) - url_fdback = RestClient.get(url).body - email_index = url_fdback.index @my_info['my_email'] + def check_commit_exist(commit_id, repo_commits) + return if repo_commits.include? commit_id.chomp + + raise 'NO_COMMIT_ID' + end
- return unless email_index.nil? + def check_commit_email(author_email) + return if author_email.eql? @my_info['my_email'].chomp
- raise 'COMMIT_URL_NOT_AVAILABLE' + raise 'COMMIT_AUTHOR_ERROR' end
def parse_pub_key -- 2.23.0