use query parameter for commit branch

This commit is contained in:
Alex Suraci 2014-04-06 15:03:51 -07:00
parent 10c3c8108e
commit 055ed199a1
9 changed files with 27 additions and 19 deletions

View file

@ -222,9 +222,9 @@ func setupHandlers() {
m.Post("/install", handler.ErrorHandler(handler.InstallPost))
// handlers for repository, commits and build details
m.Get("/:host/:owner/:name/commit/:branch/:commit/build/:label/out.txt", handler.RepoHandler(handler.BuildOut))
m.Get("/:host/:owner/:name/commit/:branch/:commit/build/:label", handler.RepoHandler(handler.CommitShow))
m.Get("/:host/:owner/:name/commit/:branch/:commit", handler.RepoHandler(handler.CommitShow))
m.Get("/:host/:owner/:name/commit/:commit/build/:label/out.txt", handler.RepoHandler(handler.BuildOut))
m.Get("/:host/:owner/:name/commit/:commit/build/:label", handler.RepoHandler(handler.CommitShow))
m.Get("/:host/:owner/:name/commit/:commit", handler.RepoHandler(handler.CommitShow))
m.Get("/:host/:owner/:name/tree", handler.RepoHandler(handler.RepoDashboard))
m.Get("/:host/:owner/:name/status.svg", handler.ErrorHandler(handler.Badge))
m.Get("/:host/:owner/:name/settings", handler.RepoAdminHandler(handler.RepoSettingsForm))

View file

@ -9,7 +9,11 @@ import (
// Returns the combined stdout / stderr for an individual Build.
func BuildOut(w http.ResponseWriter, r *http.Request, u *User, repo *Repo) error {
branch := r.FormValue(":branch")
branch := r.FormValue("branch")
if branch == "" {
branch = "master"
}
hash := r.FormValue(":commit")
labl := r.FormValue(":label")

View file

@ -11,7 +11,11 @@ import (
// Display a specific Commit.
func CommitShow(w http.ResponseWriter, r *http.Request, u *User, repo *Repo) error {
branch := r.FormValue(":branch")
branch := r.FormValue("branch")
if branch == "" {
branch = "master"
}
hash := r.FormValue(":commit")
labl := r.FormValue(":label")

View file

@ -10,7 +10,7 @@
<table class="commit-table" style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; width: 100%; margin: 0; padding: 0;">
<tr style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; margin: 0; padding: 0;">
<th style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; text-align: left; color: #333; margin: 0; padding: 0 30px 0 20px;" align="left">commit:</th>
<td style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; width: 99%; color: #333; margin: 0; padding: 0;"><a href="{{.Host}}/{{.Repo.Slug}}/commit/{{.Commit.Branch}}/{{ .Commit.Hash }}" style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; color: #2a6496; font-weight: normal; margin: 0; padding: 0;">{{ .Commit.HashShort }}</a></td>
<td style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; width: 99%; color: #333; margin: 0; padding: 0;"><a href="{{.Host}}/{{.Repo.Slug}}/commit/{{ .Commit.Hash }}?branch={{.Commit.Branch}}" style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; color: #2a6496; font-weight: normal; margin: 0; padding: 0;">{{ .Commit.HashShort }}</a></td>
</tr>
<tr style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; margin: 0; padding: 0;">
<th style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; text-align: left; color: #333; margin: 0; padding: 0 30px 0 20px;" align="left">branch:</th>

View file

@ -10,7 +10,7 @@
<table class="commit-table" style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; width: 100%; margin: 0; padding: 0;">
<tr style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; margin: 0; padding: 0;">
<th style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; text-align: left; color: #333; margin: 0; padding: 0 30px 0 20px;" align="left">commit:</th>
<td style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; width: 99%; color: #333; margin: 0; padding: 0;"><a href="{{.Host}}/{{.Repo.Slug}}/commit/{{ .Commit.Branch }}/{{ .Commit.Hash }}" style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; color: #2a6496; font-weight: normal; margin: 0; padding: 0;">{{ .Commit.HashShort }}</a></td>
<td style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; width: 99%; color: #333; margin: 0; padding: 0;"><a href="{{.Host}}/{{.Repo.Slug}}/commit/{{ .Commit.Hash }}?branch={{ .Commit.Branch }}" style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; color: #2a6496; font-weight: normal; margin: 0; padding: 0;">{{ .Commit.HashShort }}</a></td>
</tr>
<tr style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; margin: 0; padding: 0;">
<th style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; text-align: left; color: #333; margin: 0; padding: 0 30px 0 20px;" align="left">branch:</th>

View file

@ -5,7 +5,7 @@
<div class="subhead">
<div class="container">
<ul class="nav nav-tabs pull-right">
<li class="active"><a href="/{{.Repo.Slug}}/commit/{{ .Commit.Branch }}/{{ .Commit.Hash }}">{{ .Commit.HashShort }}</a></li>
<li class="active"><a href="/{{.Repo.Slug}}/commit/{{ .Commit.Hash }}?branch={{ .Commit.Branch }}">{{ .Commit.HashShort }}</a></li>
<li><a href="/{{.Repo.Slug}}">Commits</a></li>
<li><a href="/{{.Repo.Slug}}/settings">Settings</a></li>
</ul> <!-- ./nav -->
@ -18,7 +18,7 @@
<div class="container">
<div class="alert alert-build-{{ .Build.Status }}">
<a href="/{{.Repo.Slug}}/{{.Commit.Branch}}/commit/{{ .Commit.Branch }}/{{ .Commit.Hash }}" class="btn btn-{{ .Build.Status }}"></a>
<a href="/{{.Repo.Slug}}/commit/{{ .Commit.Hash }}?branch={{ .Commit.Branch }}" class="btn btn-{{ .Build.Status }}"></a>
{{ if .Commit.PullRequest }}
<span>opened pull request <span># {{ .Commit.PullRequest }}</span></span>
{{ else }}
@ -78,7 +78,7 @@
});
{{ else }}
$.get("/{{ .Repo.Slug }}/commit/{{ .Commit.Branch }}/{{ .Commit.Hash }}/build/{{ .Build.Slug }}/out.txt", function( data ) {
$.get("/{{ .Repo.Slug }}/commit/{{ .Commit.Hash }}/build/{{ .Build.Slug }}/out.txt?branch={{ .Commit.Branch }}", function( data ) {
var lineFormatter = new Drone.LineFormatter();
$( "#stdout" ).html(lineFormatter.format(data));
});

View file

@ -28,12 +28,12 @@
<ul class="commit-list commit-list-alt">
{{ range .Commits }}
<li>
<a href="/{{$repo.Slug}}/commit/{{.Branch}}/{{.Hash}}" class="btn btn-{{.Status}}"></a>
<a href="/{{$repo.Slug}}/commit/{{.Hash}}?branch={{.Branch}}" class="btn btn-{{.Status}}"></a>
<h3>
<a href="/{{$repo.Slug}}/commit/{{.Branch}}/{{.Hash}}">{{.HashShort}}</a>
<a href="/{{$repo.Slug}}/commit/{{.Hash}}?branch={{.Branch}}">{{.HashShort}}</a>
<small class="timeago" title="{{.CreatedString}}"></small>
{{ if .PullRequest }}
<p>opened pull request <a href="/{{$repo.Slug}}/commit/{{.Branch}}/{{.Hash}}"># {{.PullRequest}}</a></p>
<p>opened pull request <a href="/{{$repo.Slug}}/commit/{{.Hash}}?branch={{.Branch}}"># {{.PullRequest}}</a></p>
{{ else }}
<p>{{.Message}} &nbsp;</p>
{{ end }}

View file

@ -45,14 +45,14 @@
<ul class="commit-list">
{{ range $commit := .Commits }}
<li>
<a href="/{{$commit.Slug}}/commit/{{$commit.Branch}}/{{$commit.Hash}}" class="btn btn-{{$commit.Status}}"></a>
<a href="/{{$commit.Slug}}/commit/{{$commit.Hash}}?branch={{$commit.Branch}}" class="btn btn-{{$commit.Status}}"></a>
<h3>
<a href="/{{$commit.Slug}}">{{$commit.Owner}} / {{$commit.Name}}</a>
<small class="timeago" title="{{$commit.CreatedString}}"></small>
{{ if $commit.PullRequest }}
<p>opened pull request <a href="/{{$commit.Slug}}/commit/{{$commit.Branch}}/{{$commit.Hash}}"># {{$commit.PullRequest}}</a></p>
<p>opened pull request <a href="/{{$commit.Slug}}/commit/{{$commit.Hash}}?branch={{$commit.Branch}}"># {{$commit.PullRequest}}</a></p>
{{ else }}
<p>commit <a href="/{{$commit.Slug}}/commit/{{$commit.Branch}}/{{$commit.Hash}}">{{$commit.HashShort}}</a> to <a href="/{{$commit.Slug}}?branch={{$commit.Branch}}">{{$commit.Branch}}</a> branch</p>
<p>commit <a href="/{{$commit.Slug}}/commit/{{$commit.Hash}}?branch={{$commit.Branch}}">{{$commit.HashShort}}</a> to <a href="/{{$commit.Slug}}?branch={{$commit.Branch}}">{{$commit.Branch}}</a> branch</p>
{{ end }}
</h3>
</li>

View file

@ -43,14 +43,14 @@
<ul class="commit-list">
{{ range $commit := .Commits }}
<li>
<a href="/{{$commit.Slug}}/commit/{{$commit.Branch}}/{{$commit.Hash}}" class="btn btn-{{$commit.Status}}"></a>
<a href="/{{$commit.Slug}}/commit/{{$commit.Hash}}?branch={{$commit.Branch}}" class="btn btn-{{$commit.Status}}"></a>
<h3>
<a href="/{{$commit.Slug}}">{{$commit.Owner}} / {{$commit.Name}}</a>
<small class="timeago" title="{{$commit.CreatedString}}"></small>
{{ if $commit.PullRequest }}
<p>opened pull request <a href="/{{$commit.Slug}}/commit/{{$commit.Branch}}/{{$commit.Hash}}"># {{$commit.PullRequest}}</a></p>
<p>opened pull request <a href="/{{$commit.Slug}}/commit/{{$commit.Hash}}?branch={{$commit.Branch}}"># {{$commit.PullRequest}}</a></p>
{{ else }}
<p>commit <a href="/{{$commit.Slug}}/commit/{{$commit.Branch}}/{{$commit.Hash}}">{{$commit.HashShort}}</a> to <a href="/{{$commit.Slug}}?branch={{$commit.Branch}}">{{$commit.Branch}}</a> branch</p>
<p>commit <a href="/{{$commit.Slug}}/commit/{{$commit.Hash}}?branch={{$commit.Branch}}">{{$commit.HashShort}}</a> to <a href="/{{$commit.Slug}}?branch={{$commit.Branch}}">{{$commit.Branch}}</a> branch</p>
{{ end }}
</h3>
</li>