On Mon, Mar 01, 2021 at 04:02:35PM +0800, Luan Shengde wrote:
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
To check if it's a hash is not enough, as user's action can not be controlled, I have to make sure it's exactly what I want.
Thanks, Yuanchao