Merge remote-tracking branch 'origin/master'

This commit is contained in:
Brad Rydzewski 2014-02-10 03:03:37 -07:00
commit 453caf033d
5 changed files with 87 additions and 9 deletions

24
deb/drone/DEBIAN/postinst Executable file
View file

@ -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
deb/drone/DEBIAN/prerm Executable file
View file

@ -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

View file

@ -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

View file

@ -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
}

View file

@ -40,6 +40,7 @@
<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>
@ -51,4 +52,27 @@
{{ 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 }}