On Thu, Feb 25, 2021 at 07:18:19PM +0800, Li Yuanchao wrote:
Sometimes there would be some not yaml like file in upstream-repos, such as README.md or user's temporary file.
Now we'll do a judge after load and before any other actions, if it's not repo file, just return.
Signed-off-by: Li Yuanchao lyc163mail@163.com
lib/git_mirror.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/lib/git_mirror.rb b/lib/git_mirror.rb index 76cdd1b..22c4e07 100644 --- a/lib/git_mirror.rb +++ b/lib/git_mirror.rb @@ -223,7 +223,10 @@ end class MirrorMain def load_repo_file(repodir, project, fork_name)
it seems that repodir is the file for repo's url. why use 'dir'? use repo_file or repo_url_file is better
git_repo = "#{project}/#{fork_name}"
- @git_info[git_repo] = YAML.safe_load(File.open(repodir))
- git_info = YAML.safe_load(File.open(repodir))
- return if git_info.nil? || git_info['url'].nil?
case the repodir is a common file, when execute: git_info = YAML.safe_load(File.open(repodir)) the class may be string, while it's not nil. you may check whether the class of git info is a hash
btw, you can use YAML.load_file(filename) to load the file content.
Thanks, Luan Shengde
- @git_info[git_repo] = git_info @git_info[git_repo]['git_repo'] = git_repo @git_info[git_repo] = merge_defaults(git_repo, @git_info[git_repo]) fork_stat_init(git_repo)
-- 2.23.0