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

Allow extended config on cron settings #12939

Merged
merged 3 commits into from
Sep 25, 2020

Conversation

zeripath
Copy link
Contributor

Workaround odd behaviour in go-ini whereby an embedded field does not get the values from the same section.

Fix #12934

Signed-off-by: Andrew Thornton art27@cantab.net

Fix go-gitea#12934

Signed-off-by: Andrew Thornton <art27@cantab.net>
@zeripath zeripath added this to the 1.13.0 milestone Sep 24, 2020
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Sep 24, 2020
Signed-off-by: Andrew Thornton <art27@cantab.net>
@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 Sep 24, 2020
@codecov-commenter
Copy link

codecov-commenter commented Sep 24, 2020

Codecov Report

Merging #12939 into master will increase coverage by 0.00%.
The diff coverage is 63.63%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #12939   +/-   ##
=======================================
  Coverage   42.82%   42.82%           
=======================================
  Files         661      661           
  Lines       72977    72986    +9     
=======================================
+ Hits        31250    31254    +4     
- Misses      36658    36660    +2     
- Partials     5069     5072    +3     
Impacted Files Coverage Δ
modules/setting/cron.go 66.66% <63.63%> (-33.34%) ⬇️
modules/indexer/stats/db.go 60.86% <0.00%> (-8.70%) ⬇️
services/pull/check.go 48.46% <0.00%> (+0.76%) ⬆️

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 3c36080...d52f3cd. Read the comment docs.

// GetCronSettings maps the cron subsection to the provided config
func GetCronSettings(name string, config interface{}) (interface{}, error) {
err := Cfg.Section("cron." + name).MapTo(config)
return config, err
if err := Cfg.Section("cron." + name).MapTo(config); err != nil {
Copy link

Choose a reason for hiding this comment

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

I have 0 experience in Go, but it was hard for me to read this line. I did some research and potentially this may help to avoid such init statements in if with return inside

https://golang.org/doc/effective_go.html#if

In the Go libraries, you'll find that when an if statement doesn't flow into the next statement—that is, the body ends in break, continue, goto, or return—the unnecessary else is omitted.

f, err := os.Open(name)
if err != nil {
    return err
}
codeUsing(f)

More to read
https://www.calhoun.io/one-liner-if-statements-with-errors/

@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 Sep 25, 2020
@zeripath zeripath merged commit f1ab1c5 into go-gitea:master Sep 25, 2020
@zeripath zeripath deleted the fix-12934-ini-misbehaviour branch September 25, 2020 08:58
zeripath added a commit to zeripath/gitea that referenced this pull request Sep 25, 2020
Backport go-gitea#12939

Fix go-gitea#12934

Signed-off-by: Andrew Thornton <art27@cantab.net>
@zeripath zeripath added the backport/done All backports for this PR have been created label Sep 25, 2020
jolheiser pushed a commit that referenced this pull request Sep 25, 2020
Backport #12939

Fix #12934

Signed-off-by: Andrew Thornton <art27@cantab.net>
@zeripath zeripath mentioned this pull request Oct 16, 2020
7 tasks
@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
backport/done All backports for this PR have been created 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.

LDAP regular Sync of User attributes
6 participants