try to fix Duplicate of files in directory (gogs#2254 )

https://github.com/gogits/gogs/issues/2254
This commit is contained in:
novaeye
2015-12-25 18:23:47 +08:00
parent 9dc84c9ed6
commit d18ad23cae
+5 -4
View File
@@ -110,6 +110,7 @@ func (tes Entries) Sort() {
type commitInfo struct {
id string
entry string
infos []interface{}
err error
}
@@ -128,7 +129,7 @@ func (tes Entries) GetCommitsInfo(commit *Commit, treePath string) ([][]interfac
for i := range tes {
if tes[i].Type != OBJECT_COMMIT {
go func(i int) {
cinfo := commitInfo{id: tes[i].ID.String()}
cinfo := commitInfo{id: tes[i].ID.String(), entry: tes[i].Name()}
c, err := commit.GetCommitByPath(filepath.Join(treePath, tes[i].Name()))
if err != nil {
cinfo.err = fmt.Errorf("GetCommitByPath (%s/%s): %v", treePath, tes[i].Name(), err)
@@ -142,7 +143,7 @@ func (tes Entries) GetCommitsInfo(commit *Commit, treePath string) ([][]interfac
// Handle submodule
go func(i int) {
cinfo := commitInfo{id: tes[i].ID.String()}
cinfo := commitInfo{id: tes[i].ID.String(), entry: tes[i].Name()}
sm, err := commit.GetSubModule(path.Join(treePath, tes[i].Name()))
if err != nil {
cinfo.err = fmt.Errorf("GetSubModule (%s/%s): %v", treePath, tes[i].Name(), err)
@@ -171,7 +172,7 @@ func (tes Entries) GetCommitsInfo(commit *Commit, treePath string) ([][]interfac
return nil, info.err
}
infoMap[info.id] = info.infos
infoMap[info.entry] = info.infos
i++
if i == len(tes) {
break
@@ -180,7 +181,7 @@ func (tes Entries) GetCommitsInfo(commit *Commit, treePath string) ([][]interfac
commitsInfo := make([][]interface{}, len(tes))
for i := 0; i < len(tes); i++ {
commitsInfo[i] = infoMap[tes[i].ID.String()]
commitsInfo[i] = infoMap[tes[i].Name()]
}
return commitsInfo, nil
}