On Wed, Sep 30, 2020 at 09:39:07AM +0800, Li Ping wrote:
On Wed, Sep 30, 2020 at 07:22:13AM +0800, Wu Fengguang wrote:
On Tue, Sep 29, 2020 at 05:49:03PM +0800, Li Ping wrote:
On Tue, Sep 29, 2020 at 03:33:06PM +0800, Wu Fengguang wrote:
What's the problem it tries to fix? Please give examples for different situation.
git-mirror监控/srv/git/路径下的仓库,那里的目录结构和upstream_repos下的目录结构 是一样的,查询上游仓库是否在该目录下,可以根据仓库的$project和$fork确定一个repo 字段,然后判断这个repo是否存放在/srv/git/路径下,存放repo的目录结构有以下四种形式: /srv/git/$project/$fork.git /srv/git/$project/$project.git /srv/git/p/$project/$fork.git /srv/git/p/$project/$project.git 如果这几个目录下都不存在那就是没有了
initialize() 参数 $repo 的具体内容会是啥? 它从哪里来?
$repo = $fork/$project 能从git_url中提取出来: https://gitee.com/Siguyi/compass-ci
肯定不是. url是url, 跟repo名字没有自动推理关系.
申请账号时,用户需要提供git_url
那个是用来wget content后确认是开源开发者用的, 没有额外用途.
Thanks, Fengguang
On Mon, Sep 28, 2020 at 09:02:48PM +0800, Li Ping wrote:
lib/git.rb | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-)
diff --git a/lib/git.rb b/lib/git.rb index db97c47..a181ec9 100644 --- a/lib/git.rb +++ b/lib/git.rb @@ -3,8 +3,34 @@ # wrap common git commands class GitCommit def initialize(repo, commit)
- @git_prefix = "git -C /srv/git/#{repo}.git"
@repo = repo @commit = commit
@git_prefix = cd_repo_path
end
def check_repo
fork_name = @repo.split('/')[0]
project = @repo.split('/')[1]
first_letter = project[0]
fork_name = 'linus' if project == 'linux'
path_a = find_path("/srv/git/#{first_letter}/#{project}/#{project}.git")
path_b = find_path("/srv/git/#{first_letter}/#{project}/#{fork_name}.git")
path_c = find_path("/srv/git/#{project}/#{fork_name}.git")
path_d = find_path("/srv/git/#{project}/#{project}.git")
path_a || path_b || path_c || path_d
end
def find_path(path)
return false if Dir.glob(path).empty?
Dir.glob(path).first
end
def cd_repo_path
find_repo = check_repo
return unless find_repo
"git -C #{find_repo}" end
def author_name
-- 2.23.0