Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #6813: Allow git.GetTree to take both commit and tree names #6816

Merged
merged 4 commits into from
May 3, 2019

Conversation

filipnavara
Copy link
Contributor

@filipnavara filipnavara commented May 1, 2019

Fixes two separate bugs reported in #6813:

  • Allow git.GetTree to take both commit and tree names; this matches GitHub behavior on the Trees API
  • Return full paths on entries listed through Tree.ListEntriesRecursive. Technically this is abuse of the API but I am just doing a hot-fix here. A proper fix would be to move the recursive enumeration to different layer and add unit tests for it.

…hs on entries listed through Tree.ListEntriesRecursive

Signed-off-by: Filip Navara <filip.navara@gmail.com>
@filipnavara filipnavara changed the title Fix #6812: Allow git.GetTree to take both commit and tree names Fix #6813: Allow git.GetTree to take both commit and tree names May 1, 2019
@lafriks
Copy link
Member

lafriks commented May 1, 2019

Looks like unit tests needs to be updated as well

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label May 1, 2019
@lafriks lafriks added the type/enhancement An improvement of existing functionality label May 1, 2019
@lafriks lafriks added this to the 1.9.0 milestone May 1, 2019
@filipnavara
Copy link
Contributor Author

I will look into the failures later today. It should not have broken any tests...

@filipnavara
Copy link
Contributor Author

Ah, I propagate wrong SHA into the Tree object now. :/

@lafriks lafriks added type/bug and removed type/enhancement An improvement of existing functionality labels May 1, 2019
…olic name

Signed-off-by: Filip Navara <filip.navara@gmail.com>
@codecov-io
Copy link

codecov-io commented May 1, 2019

Codecov Report

Merging #6816 into master will increase coverage by 0.01%.
The diff coverage is 54.54%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #6816      +/-   ##
==========================================
+ Coverage   41.21%   41.23%   +0.01%     
==========================================
  Files         421      421              
  Lines       58120    58125       +5     
==========================================
+ Hits        23956    23966      +10     
+ Misses      30993    30988       -5     
  Partials     3171     3171
Impacted Files Coverage Δ
modules/git/tree_entry.go 71.18% <0%> (-1.86%) ⬇️
modules/git/tree.go 46.05% <0%> (-0.62%) ⬇️
modules/git/repo_tree.go 81.25% <100%> (+19.95%) ⬆️
modules/repofiles/tree.go 84% <100%> (ø) ⬆️
modules/log/file.go 75.52% <0%> (-2.1%) ⬇️
routers/repo/view.go 43.03% <0%> (+1.01%) ⬆️
models/repo_list.go 67.89% <0%> (+1.05%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a27d5d2...d3b17f9. Read the comment docs.

@zeripath
Copy link
Contributor

zeripath commented May 1, 2019

Hmm...

I wonder would it better to use:

object, err := repo.gogitRepo.Object(plumbing.AnyObject, plumbing.Hash(id))
if err != nil {
    return nil, err
}

And then test the type of the object, if it's a Commit - then grab the Tree, if it's a Tree cool.

If it's a Blob then there's likely nothing we can do

If it's a Tag then we can check the target -> Commit-> Tree, Tree, and so on.

@filipnavara
Copy link
Contributor Author

filipnavara commented May 1, 2019

@zeripath Perhaps. I don't like the code as-is and I like your way of restructuring it a bit more than whatever is in this PR. Then again, before doing any bigger change I would prefer to update the unit tests to test those cases. The tests currently don't test tree hashes, tag hashes (which don't work; thanks for pointing it out) or the error case with blob hash.

@lunny
Copy link
Member

lunny commented May 2, 2019

@filipnavara It seems we should also change the test if there is one.

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels May 2, 2019
@lafriks
Copy link
Member

lafriks commented May 2, 2019

@filipnavara @zeripath that most probably would ok to be in other PR

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels May 2, 2019
@techknowlogick techknowlogick merged commit dbb0c96 into go-gitea:master May 3, 2019
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants