[why] use 'git clone repo_url' will clone the whole repo it will need more time and network bandwidth
[how] use 'git clone --bare repo_url' instead
Signed-off-by: Luan Shengde shdluan@163.com --- container/mail-robot/lib/gitee-commit-url-check.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/container/mail-robot/lib/gitee-commit-url-check.rb b/container/mail-robot/lib/gitee-commit-url-check.rb index 72c948f..7cac0d5 100755 --- a/container/mail-robot/lib/gitee-commit-url-check.rb +++ b/container/mail-robot/lib/gitee-commit-url-check.rb @@ -21,12 +21,12 @@ class GiteeCommitUrlCheck end
def gitee_commit_check - repo_dir = @url.split('/')[-3] repo_url = [@base_url, 'git'].join('.') + repo_dir = repo_url.split('/')[-1] commit_id = @url.split('/')[-1]
Dir.chdir '/tmp' - %x(/usr/bin/git clone #{repo_url} #{repo_dir}) + %x(/usr/bin/git clone --bare #{repo_url} #{repo_dir})
email_index = %x(/usr/bin/git -C #{repo_dir} show #{commit_id}).index @my_info['my_email']