+# check commit url availability for hub gitee.com +class GiteeCommitUrl
How about one file has one class?
Thanks, Xueliang
- def initialize(my_info, url, base_url)
- @my_info = my_info
- @url = url
- @base_url = base_url
- end
- def gitee_commit_index
- repo_dir = @url.split('/')[-3]
- repo_url = [@base_url, 'git'].join('.')
- commit_id = @url.split('/')[-1]
- Dir.chdir '/tmp'
- %x(/usr/bin/git clone #{repo_url} #{repo_dir})
- email_index = %x(/usr/bin/git -C #{repo_dir} show #{commit_id}).index @my_info['my_email']
- FileUtils.rm_rf repo_dir
- gitee_commit_exist(email_index)
- end
- def gitee_commit_exist(email_index)
- return unless email_index.nil?
- error_message = "We can not conform the commit url matches your email.\n"
- error_message += 'Make sure that the commit url is right,'
- error_message += ' or it is truely submitted with you email.'
- raise error_message
- end
+end
2.23.0