-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Adds Parent property to the repo API #1687
Adds Parent property to the repo API #1687
Conversation
@guyzmo you need to create PR to https://github.com/go-gitea/go-sdk to add required field |
done |
93beb0f
to
9d5ce90
Compare
I just changed the content, to expose |
9d5ce90
to
e879a31
Compare
cf github API, the parent is a full object. The only difference is that the parent does not contain its own parent in the project's tree (to avoid blowing up the connection). Also there's a I guess that we can start iteratively, and give the |
This code will panic when |
👌, so we need the code to keep calm when I don't know the code base enough to tell how to hack that, so any pointers are welcomed ☺ |
@guyzmo first at all, you should use |
2541322
to
683316b
Compare
Now that dependency is set correctly you can see that unit tests is failing where BaseRepo is nil |
So what can be done, how can we make sure it's 👌 when the pointer is |
you need to move out assignment up something like: var parent *api.Repository
if repo.BaseRepo != nil {
parent = repo.BaseRepo.APIFormat(AccessModeNone)
} |
and to make sure the |
Then just assign |
If you meant to actually load BaseRepo than it should be done outside APIFormat in function from where APIFormat is called |
683316b
to
7565d77
Compare
ok, I've tried something to force load the |
7565d77
to
fb60313
Compare
models/repo.go
Outdated
log.Error(4, "GetRepositoryByID[%d]: %v", id, err) | ||
} | ||
if repo.BaseRepo != nil { | ||
parent := repo.BaseRepo.APIFormat(AccessModeNone) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it must be parent = repo.BaseRepo...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and I guess parent := nil
as well. My bad! 👍
4cf7027
to
5567d85
Compare
models/repo.go
Outdated
cloneLink := repo.CloneLink() | ||
permission := &api.Permission{ | ||
Admin: mode >= AccessModeAdmin, | ||
Push: mode >= AccessModeWrite, | ||
Pull: mode >= AccessModeRead, | ||
} | ||
err := repo.GetBaseRepo() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if isParent
is true no need to try to call GetBaseRepo
as it's result will not be used anyway
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌
models/repo.go
Outdated
cloneLink := repo.CloneLink() | ||
permission := &api.Permission{ | ||
Admin: mode >= AccessModeAdmin, | ||
Push: mode >= AccessModeWrite, | ||
Pull: mode >= AccessModeRead, | ||
} | ||
err := repo.GetBaseRepo() | ||
if err != nil { | ||
log.Error(4, "APIFormat issue: %v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just "APIFormat: %v", err
;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌
25875cf
to
7f67717
Compare
now it's LGTM 🎉 |
LGTM |
models/repo.go
Outdated
@@ -272,12 +272,26 @@ func (repo *Repository) APIURL() string { | |||
|
|||
// APIFormat converts a Repository to api.Repository | |||
func (repo *Repository) APIFormat(mode AccessMode) *api.Repository { | |||
return repo.innerAPIFormat(mode, false) | |||
} | |||
func (repo *Repository) innerAPIFormat(mode AccessMode, isParent bool) *api.Repository { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blank line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done 👌
Signed-off-by: Guyzmo <[email protected]>
7f67717
to
a541d73
Compare
let L-G-T-M work |
changes introduced to repo format by : go-gitea#1687 go-gitea/go-sdk#58 go-gitea#1668 go-gitea/go-sdk#56
changes introduced to repo format by : #1687 go-gitea/go-sdk#58 #1668 go-gitea/go-sdk#56
hop! 👍
cf gogs/go-gogs-client#64