我正在使用以下代码递归地迭代目录和子文件夹中的文件:
我正在进行迭代的结果如下:
以下是我想要的表单。
Dir.glob("**/*").each do |file|
filename = "#{File.basename(file)}"
output = `git log -1 -r -n 1 --pretty=format:\"%h: #{filename}\" -- #{filename}`
end
我正在进行迭代的结果如下:
这是我得到的结果:
Actual Output:
<The format I choose>: folder1
<The format I choose>: a_file
<The format I choose>: folder2
<The format I choose>: a_file
<The format I choose>: another_file
<The format I choose>: folder3
<The format I choose>: a_file
以下是我想要的表单。
Expected Output:
<The format I choose>: folder1/a_file
<The format I choose>: folder2/a_file
<The format I choose>: folder2/another_file
<The format I choose>: folder3/a_file
你能指出并解释一下我的循环错误吗?