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

Drop db operations from hook commands #1514

Merged
merged 4 commits into from
May 4, 2017

Conversation

lunny
Copy link
Member

@lunny lunny commented Apr 19, 2017

No description provided.

@lunny lunny added the type/enhancement An improvement of existing functionality label Apr 19, 2017
@lunny lunny added this to the 1.2.0 milestone Apr 19, 2017
Copy link
Member

@bkcsoft bkcsoft left a comment

Choose a reason for hiding this comment

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

Just documenting this

)

// GetProtectedBranchBy get protected branch information
func GetProtectedBranchBy(repoID int64, branchName string) (*models.ProtectedBranch, error) {
Copy link
Member

Choose a reason for hiding this comment

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

This should be moved to go-gitea/sdk later on... I'm not gonna ask you to do it now , but we're gonna have to move it at some point.

Copy link
Member Author

Choose a reason for hiding this comment

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

Why should we move it to go-gitea/sdk later? It is an internal SDK.

Copy link
Member

Choose a reason for hiding this comment

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

Should still be in the SDK. That way other implementations of gitea serv could re-use this :)

Copy link
Member

Choose a reason for hiding this comment

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

I don't think that the sdk contain any internal route but we could maybe add it in an other time.

Copy link
Member

Choose a reason for hiding this comment

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

In fact it add /api/v1 to url request (https://github.com/go-gitea/go-sdk/blob/master/gitea/gitea.go#L42) so no internal route.

"strings"

macaron "gopkg.in/macaron.v1"

Copy link
Member

Choose a reason for hiding this comment

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

local package -> public package.

Copy link
Member Author

Choose a reason for hiding this comment

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

done.

@lunny
Copy link
Member Author

lunny commented Apr 20, 2017

related #1023

@tboerger tboerger added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Apr 20, 2017
cmd/hook.go Outdated
log.NewGitLogger(filepath.Join(setting.LogRootPath, logPath))
models.LoadConfigs()

return nil
Copy link
Member

Choose a reason for hiding this comment

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

No error return. Maybe changed to

func hookSetup(logPath string) {

Copy link
Member Author

Choose a reason for hiding this comment

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

done.

@appleboy
Copy link
Member

LGTM

@andreynering
Copy link
Contributor

@lunny Why do you think this is a good idea? Just trying to get the intention...

Doing GET and POST from hooks seems unstable to me. Will they work when HTTPS is being used?

@tboerger tboerger 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 Apr 25, 2017
@bkcsoft
Copy link
Member

bkcsoft commented Apr 25, 2017

Will they work when HTTPS is being used?

@andreynering They will use localhost:{port} AFAIK. Otherwise it's extremly fragile yes 😄

// GetProtectedBranchBy get protected branch information
func GetProtectedBranchBy(repoID int64, branchName string) (*models.ProtectedBranch, error) {
// Ask for running deliver hook and test pull request tasks.
reqURL := setting.LocalURL + fmt.Sprintf("api/internal/branch/%d/%s", repoID, branchName)
Copy link
Member

Choose a reason for hiding this comment

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

@andreynering As you can see here it uses LocalURL which is fine 🙂

@bkcsoft
Copy link
Member

bkcsoft commented Apr 25, 2017

@andreynering As far as "is this a good idea?", this is actually how gitlab-shell works as well, which seems to work just fine 😉

@lunny
Copy link
Member Author

lunny commented Apr 26, 2017

@andreynering It will let us avoid open db on gitea serv, gitea hook pre-receive, gitea hook update and gitea hook post-receive four times.

@sapk
Copy link
Member

sapk commented May 4, 2017

LGTM

@tboerger tboerger 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 4, 2017
@lunny lunny merged commit 1773e88 into go-gitea:master May 4, 2017
@lunny lunny deleted the lunny/drop_db_from_hook branch May 4, 2017 05:42
@go-gitea go-gitea locked and limited conversation to collaborators Nov 23, 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/enhancement An improvement of existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants