Dear Gitlab users, due to maintenance reasons, Gitlab will not be available on Thursday 30.09.2021 from 5:00 pm to approximately 5:30 pm.

Commit 9e315b40 authored by Andreas Wagner's avatar Andreas Wagner
Browse files

Fix github putfile method.

parent 89b19c7b
......@@ -332,14 +332,21 @@ func ProcessHook(hookType string, r io.ReadSeeker, conf *tei2zenodo.Config) (map
log.Errorf("Error processing push hook: %+v", err)
return nil, tei2zenodo.NewError("errInternal", fmt.Sprintf("error processing push hook: %s", err.Error()), 500, err)
}
if payload.Repository.FullName != conf.Git.Repo && conf.Git.Repo != "" {
// Filtering based on repo, pusher or branch
if conf.Git.Repo != "" && payload.Repository.FullName != conf.Git.Repo {
log.Warnf("Repo not allowed: %s", payload.Repository.FullName)
return nil, tei2zenodo.NewError("errBadRequest", fmt.Sprintf("repo not allowed: %s", payload.Repository.FullName), 500, nil)
}
if payload.Pusher.Name != conf.Git.HookUser && conf.Git.HookUser != "" {
if conf.Git.HookUser != "" && payload.Pusher.Name != conf.Git.HookUser {
log.Warnf("Git user not allowed as pusher: %s", payload.Pusher.Name)
return nil, tei2zenodo.NewError("errBadRequest", fmt.Sprintf("git user not allowed as pusher: %s", payload.Pusher.Name), 500, nil)
}
if conf.Git.Branch != "" && payload.Ref != "refs/heads/"+conf.Git.Branch {
log.Warnf("Git push to the wrong branch: %s instead of %s", payload.Ref, conf.Git.Branch)
return nil, tei2zenodo.NewError("errBadRequest", fmt.Sprintf("git push to the wrong branch: %s instead of %s", payload.Ref, conf.Git.Branch), 500, nil)
}
log.Tracef("Push payload: %+v", payload)
commitsURL := payload.Repository.CommitsURL
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment