Skip to content
This repository has been archived by the owner on Apr 12, 2019. It is now read-only.

Fix retrieve file last commit branchName #98

Merged
merged 4 commits into from
Dec 20, 2017
Merged

Fix retrieve file last commit branchName #98

merged 4 commits into from
Dec 20, 2017

Conversation

lunny
Copy link
Member

@lunny lunny commented Dec 15, 2017

This will be a part of PR to fix go-gitea/gitea#3181

@lunny lunny added the kind/bug label Dec 15, 2017
@lafriks
Copy link
Member

lafriks commented Dec 15, 2017

LGTM

Copy link
Member

@strk strk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm concerned about the API change, is it really needed ?

commit_info.go Outdated
treePath: treePath,
headCommit: headCommit,
}
}

// GetCommitsInfo gets information of all commits that are corresponding to these entries
func (tes Entries) GetCommitsInfo(commit *Commit, treePath string) ([][]interface{}, error) {
state := initGetCommitInfoState(tes, commit, treePath)
func (tes Entries) GetCommitsInfo(commit *Commit, branchName, treePath string) ([][]interface{}, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

branch name seems redundant here, a commit is enough to identify an entity in a repository. Also changing this signature needlessly changes API of the module

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, sometimes when calling this function there won't be a branch (e.g. viewing the source tree at a particular commit)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd call it revision like git does https://git-scm.com/docs/gitrevisions

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@strk maybe right. HEAD -> commit.ID.String(). I will fix this.

Copy link
Member

@ethantkoenig ethantkoenig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll also need to modify the git log command in getCommitInfos(..) to use the correct revision.

@lunny
Copy link
Member Author

lunny commented Dec 16, 2017

@strk @ethantkoenig also should fix go-gitea/gitea#3202

commit_info.go Outdated
@@ -90,7 +90,9 @@ func targetedSearch(state *getCommitsInfoState, done chan error) {
done <- err
return
}
state.lock.Lock()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to lock here? I don't see why it would be a problem if two threads run a read-only git command in parallel.

@strk
Copy link
Member

strk commented Dec 16, 2017

Please include a test for the fix

@lunny
Copy link
Member Author

lunny commented Dec 17, 2017

@strk will include a test on gitea's integration test.

@lunny
Copy link
Member Author

lunny commented Dec 17, 2017

@ethantkoenig I think you are right. Done.

@appleboy
Copy link
Member

LGTM

@lunny lunny merged commit 4573c63 into go-gitea:master Dec 20, 2017
@lunny lunny deleted the lunny/fix_non_master branch December 20, 2017 02:57
@ethantkoenig
Copy link
Member

@strk I will add tests (which is probably fair, since I introduced the bug)

@lunny
Copy link
Member Author

lunny commented Dec 20, 2017

@ethantkoenig maybe add an integration test and compare github's home page tree list and gitea's home page tree list.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

500 when viewing a repo without a master branch
7 participants