diff --git a/deb/drone/DEBIAN/postinst b/deb/drone/DEBIAN/postinst new file mode 100755 index 00000000..776f572b --- /dev/null +++ b/deb/drone/DEBIAN/postinst @@ -0,0 +1,24 @@ +#!/bin/sh +set -e + +case "$1" in + abort-upgrade|abort-remove|abort-deconfigure|configure) + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +echo "Starting drone ..." +if [ -f /etc/init/drone.conf ]; then + if pidof /usr/local/bin/droned >/dev/null; then + service drone stop || exit $? + fi + service drone start && echo "Drone started." +fi + +#DEBHELPER# + +exit 0 diff --git a/deb/drone/DEBIAN/prerm b/deb/drone/DEBIAN/prerm new file mode 100755 index 00000000..a0f7be8c --- /dev/null +++ b/deb/drone/DEBIAN/prerm @@ -0,0 +1,26 @@ +#!/bin/sh + +set -e +set -u + +case "$1" in + remove|remove-in-favour|deconfigure|deconfigure-in-favour) + if [ -f /etc/init/drone.conf ]; then + echo "Stopping drone ..." + service drone stop || exit $? + echo "Drone Stopped." + fi + ;; + + upgrade|failed-upgrade) + ;; + + *) + echo "prerm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# + +exit 0 diff --git a/pkg/handler/repos.go b/pkg/handler/repos.go index 99195e10..7c4c87ac 100644 --- a/pkg/handler/repos.go +++ b/pkg/handler/repos.go @@ -274,7 +274,7 @@ func RepoDelete(w http.ResponseWriter, r *http.Request, u *User, repo *Repo) err // the user must confirm their password before deleting password := r.FormValue("password") if err := u.ComparePassword(password); err != nil { - return err + return RenderError(w, err, http.StatusBadRequest) } // delete the repo diff --git a/pkg/queue/queue.go b/pkg/queue/queue.go index 643df98d..5d9a9e61 100644 --- a/pkg/queue/queue.go +++ b/pkg/queue/queue.go @@ -12,6 +12,7 @@ import ( "github.com/drone/drone/pkg/mail" . "github.com/drone/drone/pkg/model" "github.com/drone/go-github/github" + "log" "path/filepath" "time" ) @@ -134,6 +135,15 @@ func (b *BuildTask) execute() error { builder.Key = []byte(b.Repo.PrivateKey) builder.Stdout = buf builder.Timeout = 300 * time.Minute + + defer func() { + // update the status of the commit using the + // GitHub status API. + if err := updateGitHubStatus(b.Repo, b.Commit); err != nil { + log.Printf("error updating github status: %s\n", err.Error()) + } + }() + buildErr := builder.Run() b.Build.Finished = time.Now().UTC() @@ -181,12 +191,6 @@ func (b *BuildTask) execute() error { b.Script.Notifications.Send(context) } - // update the status of the commit using the - // GitHub status API. - if err := updateGitHubStatus(b.Repo, b.Commit); err != nil { - return err - } - return nil } @@ -218,7 +222,7 @@ func updateGitHubStatus(repo *Repo, commit *Commit) error { // get the user from the database // since we need his / her GitHub token user, err := database.GetUser(repo.UserID) - if err == nil { + if err != nil { return err } diff --git a/pkg/template/pages/repo_delete.html b/pkg/template/pages/repo_delete.html index d2ef3722..b36c3707 100644 --- a/pkg/template/pages/repo_delete.html +++ b/pkg/template/pages/repo_delete.html @@ -40,6 +40,7 @@