GiteeCommitUrlCheck check commit url availability for hub gitee - clone the repo - check commit log for the commit
usage: reference parse-apply-account-email.rb
Signed-off-by: Luan Shengde shdluan@163.com --- lib/gitee-commit-url-check.rb | 44 +++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100755 lib/gitee-commit-url-check.rb
diff --git a/lib/gitee-commit-url-check.rb b/lib/gitee-commit-url-check.rb new file mode 100755 index 0000000..a9439ad --- /dev/null +++ b/lib/gitee-commit-url-check.rb @@ -0,0 +1,44 @@ +#!/usr/bin/env ruby +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. +# frozen_string_literal: true + +require 'json' +require 'mail' + +# check commit url availability for hub gitee.com +# gitee_commit_index +# clone the repo +# check commit available +class GiteeCommitUrlCheck + 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 whether 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
On Wed, Nov 11, 2020 at 07:05:05PM +0800, Luan Shengde wrote:
GiteeCommitUrlCheck check commit url availability for hub gitee
- clone the repo
- check commit log for the commit
usage: reference parse-apply-account-email.rb
Signed-off-by: Luan Shengde shdluan@163.com
lib/gitee-commit-url-check.rb | 44 +++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100755 lib/gitee-commit-url-check.rb
diff --git a/lib/gitee-commit-url-check.rb b/lib/gitee-commit-url-check.rb new file mode 100755 index 0000000..a9439ad --- /dev/null +++ b/lib/gitee-commit-url-check.rb @@ -0,0 +1,44 @@ +#!/usr/bin/env ruby +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. +# frozen_string_literal: true
+require 'json' +require 'mail'
+# check commit url availability for hub gitee.com +# gitee_commit_index +# clone the repo +# check commit available +class GiteeCommitUrlCheck
- 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 whether 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.'
^^ your email
Thanks, Baijing
- raise error_message
- end
+end
2.23.0
- def gitee_commit_exist(email_index)
- return unless email_index.nil?
- error_message = "We can not conform whether 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.'
^^ your email
I will fix it
Thanks, Luan Shengde
Thanks, Baijing
- raise error_message
- end
+end
2.23.0