1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2024-11-24 08:02:18 +02:00

Merge pull request #333 from caffinatedmonkey/badge_fix

Fixed an Unhandled Error in badges.go
This commit is contained in:
Brad Rydzewski 2014-06-02 10:02:16 -07:00
commit 90370258bd

View File

@ -43,26 +43,29 @@ func Badge(w http.ResponseWriter, r *http.Request) error {
// get the latest commit from the database
// for the requested branch
commit, err := database.GetBranch(repo.ID, branchParam)
if err == nil {
switch {
case commit.Status == "Success" && len(successParam) == 0:
// if no success image is provided, we serve a
// badge using the shields.io service
badge = badgeSuccess
case commit.Status == "Success" && len(successParam) != 0:
// otherwise we serve the user defined success badge
badge = successParam
case commit.Status == "Failure" && len(failureParam) == 0:
// if no failure image is provided, we serve a
// badge using the shields.io service
badge = badgeFailure
case commit.Status == "Failure" && len(failureParam) != 0:
// otherwise we serve the user defined failure badge
badge = failureParam
default:
// otherwise load unknown image
badge = badgeUnknown
}
if err != nil {
http.NotFound(w, r)
return nil
}
switch {
case commit.Status == "Success" && len(successParam) == 0:
// if no success image is provided, we serve a
// badge using the shields.io service
badge = badgeSuccess
case commit.Status == "Success" && len(successParam) != 0:
// otherwise we serve the user defined success badge
badge = successParam
case commit.Status == "Failure" && len(failureParam) == 0:
// if no failure image is provided, we serve a
// badge using the shields.io service
badge = badgeFailure
case commit.Status == "Failure" && len(failureParam) != 0:
// otherwise we serve the user defined failure badge
badge = failureParam
default:
// otherwise load unknown image
badge = badgeUnknown
}
http.Redirect(w, r, badge, http.StatusSeeOther)