refactor(3p/gerrit-queue): use go:embed, bump go1.16, drop shell.nix
Previously, gerrit-queue used statik to embed files. Since go1.16, we have go:embed, which solves this much nicer, without any requirements to have the statik binary around. As the only other thing the shell.nix and .envrc plumbing did was bring a version of Go in scope, it's dropped now. We assume to have a recent-enough go binary around, else go will complain. Imported from https://github.com/flokli/gerrit-queue/pull/9 Change-Id: I851b06777a29d4f2d955cf3a7db6455a7189bc46 Reviewed-on: https://cl.tvl.fyi/c/depot/+/4329 Tested-by: BuildkiteCI Reviewed-by: tazjin <mail@tazj.in> Autosubmit: tazjin <mail@tazj.in>
This commit is contained in:
parent
b68f7eebb9
commit
b3c4057f4b
10 changed files with 10 additions and 52 deletions
18
third_party/gerrit-queue/frontend/frontend.go
vendored
18
third_party/gerrit-queue/frontend/frontend.go
vendored
|
@ -1,36 +1,34 @@
|
|||
package frontend
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"encoding/json"
|
||||
|
||||
"html/template"
|
||||
|
||||
"github.com/rakyll/statik/fs"
|
||||
|
||||
"github.com/apex/log"
|
||||
|
||||
"github.com/tweag/gerrit-queue/gerrit"
|
||||
"github.com/tweag/gerrit-queue/misc"
|
||||
_ "github.com/tweag/gerrit-queue/statik" // register static assets
|
||||
"github.com/tweag/gerrit-queue/submitqueue"
|
||||
)
|
||||
|
||||
//loadTemplate loads a list of templates, relative to the statikFS root, and a FuncMap, and returns a template object
|
||||
//go:embed templates
|
||||
var templates embed.FS
|
||||
|
||||
//loadTemplate loads a list of templates, relative to the templates root, and a
|
||||
//FuncMap, and returns a template object
|
||||
func loadTemplate(templateNames []string, funcMap template.FuncMap) (*template.Template, error) {
|
||||
if len(templateNames) == 0 {
|
||||
return nil, fmt.Errorf("templateNames can't be empty")
|
||||
}
|
||||
tmpl := template.New(templateNames[0]).Funcs(funcMap)
|
||||
statikFS, err := fs.New()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, templateName := range templateNames {
|
||||
r, err := statikFS.Open("/" + templateName)
|
||||
r, err := templates.Open("/" + templateName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
15
third_party/gerrit-queue/frontend/templates/changeset.tmpl.html
vendored
Normal file
15
third_party/gerrit-queue/frontend/templates/changeset.tmpl.html
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
{{ define "changeset" }}
|
||||
<tr>
|
||||
<td>{{ .OwnerName }}</td>
|
||||
<td>
|
||||
<strong>{{ .Subject }}</strong> (<a href="{{ changesetURL . }}" target="_blank">#{{ .Number }}</a>)<br />
|
||||
<small><code>{{ .CommitID }}</code></small>
|
||||
</td>
|
||||
<td>
|
||||
<span>
|
||||
{{ if .IsVerified }}<span class="badge badge-success badge-pill">+1 (CI)</span>{{ end }}
|
||||
{{ if .IsCodeReviewed }}<span class="badge badge-info badge-pill">+2 (CR)</span>{{ end }}
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
{{ end }}
|
76
third_party/gerrit-queue/frontend/templates/index.tmpl.html
vendored
Normal file
76
third_party/gerrit-queue/frontend/templates/index.tmpl.html
vendored
Normal file
|
@ -0,0 +1,76 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Gerrit Submit Queue</title>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.js" integrity="sha256-WpOohJOqMqqyKL9FccASB9O0KwACQJpFTUBLTYOVvVU=" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha256-CjSoeELFOcH0/uxWu6mC/Vlrc1AARqbm/jiiImDGV3s=" crossorigin="anonymous"></script>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha256-YLGeXaapI0/5IgZopewRJcFXomhRMlYYjugPLSyNjTY=" crossorigin="anonymous" />
|
||||
</head>
|
||||
<body>
|
||||
<nav class="navbar sticky-top navbar-expand-sm navbar-dark bg-dark">
|
||||
<div class="container">
|
||||
<a class="navbar-brand" href="#">Gerrit Submit Queue</a>
|
||||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||
<ul class="navbar-nav mr-auto">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#region-info">Info</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#region-wipserie">WIP Serie</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#region-log">Log</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<div class="container">
|
||||
<h2 id="region-info">Info</h2>
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th scope="row">Project Name:</th>
|
||||
<td>{{ .projectName }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Branch Name:</th>
|
||||
<td>{{ .branchName }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Currently running:</th>
|
||||
<td>
|
||||
{{ if .currentlyRunning }}yes{{ else }}no{{ end }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">HEAD:</th>
|
||||
<td>
|
||||
{{ if .HEAD }}{{ .HEAD }}{{ else }}-{{ end }}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<h2 id="region-wipserie">WIP Serie</h2>
|
||||
{{ if .wipSerie }}
|
||||
{{ block "serie" .wipSerie }}{{ end }}
|
||||
{{ else }}
|
||||
-
|
||||
{{ end }}
|
||||
|
||||
<h2 id="region-log">Log</h2>
|
||||
{{ range $entry := .memory.Entries }}
|
||||
<div class="d-flex flex-row bg-dark {{ levelToClasses $entry.Level }} text-monospace">
|
||||
<div class="p-2"><small>{{ $entry.Timestamp.Format "2006-01-02 15:04:05 UTC"}}</small></div>
|
||||
<div class="p-2 flex-grow-1"><small><strong>{{ $entry.Message }}</strong></small></div>
|
||||
</div>
|
||||
<div class="bg-dark {{ levelToClasses $entry.Level }} text-monospace text-break" style="padding-left: 4rem">
|
||||
<small>{{ fieldsToJSON $entry.Fields }}</small>
|
||||
</div>
|
||||
{{ end }}
|
||||
</body>
|
||||
</html>
|
19
third_party/gerrit-queue/frontend/templates/serie.tmpl.html
vendored
Normal file
19
third_party/gerrit-queue/frontend/templates/serie.tmpl.html
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
{{ define "serie" }}
|
||||
<table class="table table-sm table-hover">
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<th scope="col">Owner</th>
|
||||
<th scope="col">Changeset</th>
|
||||
<th scope="col">Flags</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td colspan="3" class="table-success">Serie with {{ len .ChangeSets }} changes</td>
|
||||
</tr>
|
||||
{{ range $changeset := .ChangeSets }}
|
||||
{{ block "changeset" $changeset }}{{ end }}
|
||||
{{ end }}
|
||||
</tbody>
|
||||
</table>
|
||||
{{ end }}
|
Loading…
Add table
Add a link
Reference in a new issue