OpenCSGs/csghub

The file was added in the main branch, but it also exists in the file list of other branches. An error occurred when viewing the file content.

leipeizhao opened this issue · 3 comments

Describe the bug
The file was added in the main branch, but it also exists in the file list of other branches. An error occurred when viewing the file content.

Environment
CSGHub Version: v0.9
OS: Linux
Hardware: 4c8G |...
Launch: docker compose

To Reproduce
Steps to reproduce the behavior:

  1. add file “test” in the main branch
  2. go other branch
  3. file list has “test” file
  4. view “test” file,error
Rader commented

@leipeizhao thanks for report this issue!
Does the file exist in a wrong branch, after you clone the repo to local disk?

@leipeizhao感谢您报告此问题! 将 repo 克隆到本地磁盘后,文件是否存在于错误的分支中?

问题已定位到component/repo.go文件中Tree方法里面错误

// getRepoFileTree.Ref = repo.DefaultBranch
tree, err := c.git.GetRepoFileTree(ctx, getRepoFileTree)

注释掉上面一行就好了,否则每次查看的都是默认分支的文件内容

Rader commented

yes, you are right.
There is already a bug fix for this issue: OpenCSGs/csghub-server#134