Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
bradrydzewski committed Feb 10, 2014
2 parents 8d135d7 + a1699fb commit 453caf0
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 9 deletions.
24 changes: 24 additions & 0 deletions deb/drone/DEBIAN/postinst
Original file line number Diff line number Diff line change
@@ -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
26 changes: 26 additions & 0 deletions deb/drone/DEBIAN/prerm
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion pkg/handler/repos.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 11 additions & 7 deletions pkg/queue/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down
26 changes: 25 additions & 1 deletion pkg/template/pages/repo_delete.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ <h1>
<div>
<input class="form-control" type="password" name="password" value="" />
</div>
<div class="alert alert-error hide" id="failureAlert"></div>
<div class="form-actions">
<input class="btn btn-danger" id="submitButton" type="submit" value="Delete Repository" />
<a class="btn btn-default" href="/{{.Repo.Slug}}/settings">Cancel</a>
Expand All @@ -51,4 +52,27 @@ <h1>
{{ end }}

{{ define "script" }}
{{ end }}
<script>
document.forms[0].onsubmit = function(event) {

$("#failureAlert").hide();
$('#submitButton').button('loading');

var form = event.target
var formData = new FormData(form);
xhr = new XMLHttpRequest();
xhr.open('POST', form.action);
xhr.onload = function() {
if (this.status == 400) {
$("#failureAlert").text("The password you entered was incorrect.");
$("#failureAlert").show().removeClass("hide");
$('#submitButton').button('reset')
} else {
window.location.href = "/dashboard";
}
};
xhr.send(formData);
return false;
}
</script>
{{ end }}

0 comments on commit 453caf0

Please sign in to comment.