This commit is contained in:
Thomas Boerger 2016-11-15 09:51:11 +01:00
Родитель 977c6fc189
Коммит 6abbe37a6b
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 5A388F55283960B6
38 изменённых файлов: 209 добавлений и 130 удалений

Просмотреть файл

@ -33,12 +33,12 @@ func GetMaintainer(c *gin.Context) {
log.Errorf("Error getting org members %s. %s", repo.Owner, merr)
c.String(404, "MAINTAINERS file not found. %s", err)
return
} else {
log.Printf("found %v members", len(members))
for _, member := range members {
file = append(file, member.Login...)
file = append(file, '\n')
}
}
log.Printf("found %v members", len(members))
for _, member := range members {
file = append(file, member.Login...)
file = append(file, '\n')
}
}
@ -51,7 +51,7 @@ func GetMaintainer(c *gin.Context) {
c.JSON(200, maintainer)
}
// GetMaintainer gets the MAINTAINER configuration file and returns
// GetMaintainerOrg gets the MAINTAINER configuration file and returns
// a subset of the file with members belonging to the specified organization.
func GetMaintainerOrg(c *gin.Context) {
var (

Просмотреть файл

@ -40,9 +40,9 @@ func GetRepos(c *gin.Context) {
// merges the slice of active and remote repositories favoring
// and swapping in local repository information when possible.
for i, repo := range repoc {
repo_, ok := repom[repo.Slug]
currRepo, ok := repom[repo.Slug]
if ok {
repoc[i] = repo_
repoc[i] = currRepo
}
}
c.JSON(200, repoc)

3
cache/cache.go поставляемый
Просмотреть файл

@ -9,15 +9,18 @@ import (
"golang.org/x/net/context"
)
// Cache provides a simple cache layer interface
type Cache interface {
Get(string) (interface{}, error)
Set(string, interface{}) error
}
// Get is the function to retrieve values from the cache.
func Get(c context.Context, key string) (interface{}, error) {
return FromContext(c).Get(key)
}
// Set is the function to write values to the cache.
func Set(c context.Context, key string, value interface{}) error {
return FromContext(c).Set(key, value)
}

2
cache/helper_test.go поставляемый
Просмотреть файл

@ -138,7 +138,7 @@ func TestHelper(t *testing.T) {
}
var (
fakeErr = errors.New("Not Found")
errFake = errors.New("Not Found")
fakeUser = &model.User{Login: "octocat"}
fakePerm = &model.Perm{Pull: true, Push: true, Admin: true}
fakeRepo = &model.Repo{Owner: "octocat", Name: "Hello-World"}

Просмотреть файл

@ -1,5 +1,6 @@
package model
// Comment represents a comment from the the remote API.
type Comment struct {
Author string
Body string

Просмотреть файл

@ -7,6 +7,7 @@ import (
"github.com/ianschenck/envflag"
)
// Config represents a repo-specific configuration file.
type Config struct {
Approvals int `json:"approvals" toml:"approvals"`
Pattern string `json:"pattern" toml:"pattern"`

Просмотреть файл

@ -1,5 +1,6 @@
package model
// Hook represents a hook from the remote API.
type Hook struct {
Repo *Repo
Issue *Issue

Просмотреть файл

@ -1,5 +1,6 @@
package model
// Issue represents an issue from the the remote API.
type Issue struct {
Number int
Title string

Просмотреть файл

@ -1,5 +1,6 @@
package model
// Repo represents a repo from the the remote API.
type Repo struct {
ID int64 `json:"id,omitempty" meddler:"repo_id,pk"`
UserID int64 `json:"-" meddler:"repo_user_id"`
@ -11,6 +12,7 @@ type Repo struct {
Secret string `json:"-" meddler:"repo_secret"`
}
// Perm represents permissions from the the remote API.
type Perm struct {
Pull bool
Push bool

Просмотреть файл

@ -1,10 +1,12 @@
package model
// Team represents a team from the the remote API.
type Team struct {
Login string `json:"login"`
Avatar string `json:"avatar"`
}
// Member represents a member from the the remote API.
type Member struct {
Login string `json:"login"`
}

Просмотреть файл

@ -1,5 +1,6 @@
package model
// User represents an user from the the remote API.
type User struct {
ID int64 `json:"id" meddler:"user_id,pk"`
Login string `json:"login" meddler:"user_login"`

Просмотреть файл

@ -21,6 +21,7 @@ const (
pathBranch = "%srepos/%s/%s/branches/%s"
)
// Client represents the simple HTTP client for the GitHub API.
type Client struct {
client *http.Client
base string // base url
@ -46,6 +47,7 @@ func (c *Client) SetClient(client *http.Client) {
c.client = client
}
// Branch retrives informations about a branch from the GitHub API.
func (c *Client) Branch(owner, name, branch string) (*Branch, error) {
out := new(Branch)
uri := fmt.Sprintf(pathBranch, c.base, owner, name, branch)
@ -53,6 +55,7 @@ func (c *Client) Branch(owner, name, branch string) (*Branch, error) {
return out, err
}
// BranchProtect enables the branch protection for a specific branch.
func (c *Client) BranchProtect(owner, name, branch string, in *Branch) error {
uri := fmt.Sprintf(pathBranch, c.base, owner, name, branch)
return c.patch(uri, in, nil)

Просмотреть файл

@ -17,6 +17,7 @@ import (
// name of the status message posted to GitHub
const context = "approvals/lgtm"
// Github provides the available configuration values.
type Github struct {
URL string
API string
@ -25,6 +26,7 @@ type Github struct {
Scopes []string
}
// GetUser retrieves the current user from the API.
func (g *Github) GetUser(res http.ResponseWriter, req *http.Request) (*model.User, error) {
var config = &oauth2.Config{
@ -67,6 +69,7 @@ func (g *Github) GetUser(res http.ResponseWriter, req *http.Request) (*model.Use
}, nil
}
// GetUserToken retrieves a user token from the API.
func (g *Github) GetUserToken(token string) (string, error) {
client := setupClient(g.API, token)
user, _, err := client.Users.Get("")
@ -76,6 +79,7 @@ func (g *Github) GetUserToken(token string) (string, error) {
return *user.Login, nil
}
// GetTeams retrieves teams from the API.
func (g *Github) GetTeams(user *model.User) ([]*model.Team, error) {
client := setupClient(g.API, user.Token)
orgs, _, err := client.Organizations.List("", &github.ListOptions{PerPage: 100})
@ -93,6 +97,7 @@ func (g *Github) GetTeams(user *model.User) ([]*model.Team, error) {
return teams, nil
}
// GetMembers retrieves members from the API.
func (g *Github) GetMembers(user *model.User, team string) ([]*model.Member, error) {
client := setupClient(g.API, user.Token)
teams, _, err := client.Organizations.ListTeams(team, &github.ListOptions{PerPage: 100})
@ -124,21 +129,23 @@ func (g *Github) GetMembers(user *model.User, team string) ([]*model.Member, err
return members, nil
}
// GetRepo retrieves a repository from the API.
func (g *Github) GetRepo(user *model.User, owner, name string) (*model.Repo, error) {
client := setupClient(g.API, user.Token)
repo_, _, err := client.Repositories.Get(owner, name)
currentRepo, _, err := client.Repositories.Get(owner, name)
if err != nil {
return nil, fmt.Errorf("Error fetching repository. %s", err)
}
return &model.Repo{
Owner: owner,
Name: name,
Slug: *repo_.FullName,
Link: *repo_.HTMLURL,
Private: *repo_.Private,
Slug: *currentRepo.FullName,
Link: *currentRepo.HTMLURL,
Private: *currentRepo.Private,
}, nil
}
// GetPerm retrieves permissions from the API.
func (g *Github) GetPerm(user *model.User, owner, name string) (*model.Perm, error) {
client := setupClient(g.API, user.Token)
repo, _, err := client.Repositories.Get(owner, name)
@ -152,6 +159,7 @@ func (g *Github) GetPerm(user *model.User, owner, name string) (*model.Perm, err
return m, nil
}
// GetRepos retrieves repositories from the API.
func (g *Github) GetRepos(u *model.User) ([]*model.Repo, error) {
client := setupClient(g.API, u.Token)
all, err := GetUserRepos(client)
@ -177,6 +185,7 @@ func (g *Github) GetRepos(u *model.User) ([]*model.Repo, error) {
return repos, nil
}
// RemoveIssueLabels removes labels from an issue.
func (g *Github) RemoveIssueLabels(user *model.User, repo *model.Repo, number int, labels []string) error {
client := setupClient(g.API, user.Token)
for _, label := range labels {
@ -188,16 +197,18 @@ func (g *Github) RemoveIssueLabels(user *model.User, repo *model.Repo, number in
return nil
}
// AddIssueLabels adds labels to an issue.
func (g *Github) AddIssueLabels(user *model.User, repo *model.Repo, number int, labels []string) error {
client := setupClient(g.API, user.Token)
_, _, err := client.Issues.AddLabelsToIssue(repo.Owner, repo.Name, number, labels)
return err
}
// SetHook injects a webhook through the API.
func (g *Github) SetHook(user *model.User, repo *model.Repo, link string) error {
client := setupClient(g.API, user.Token)
repo_, _, err := client.Repositories.Get(repo.Owner, repo.Name)
currentRepo, _, err := client.Repositories.Get(repo.Owner, repo.Name)
if err != nil {
return err
}
@ -218,17 +229,18 @@ func (g *Github) SetHook(user *model.User, repo *model.Repo, link string) error
in.Protection.Checks.Enforcement = "non_admins"
in.Protection.Checks.Contexts = []string{context}
client_ := NewClientToken(g.API, user.Token)
err = client_.BranchProtect(repo.Owner, repo.Name, *repo_.DefaultBranch, in)
currentClient := NewClientToken(g.API, user.Token)
err = currentClient.BranchProtect(repo.Owner, repo.Name, *currentRepo.DefaultBranch, in)
if err != nil {
if g.URL == "https://github.com" {
return err
}
log.Warnf("Error configuring protected branch for %s/%s@%s. %s", repo.Owner, repo.Name, *repo_.DefaultBranch, err)
log.Warnf("Error configuring protected branch for %s/%s@%s. %s", repo.Owner, repo.Name, *currentRepo.DefaultBranch, err)
}
return nil
}
// DelHook removes a webhook through the API.
func (g *Github) DelHook(user *model.User, repo *model.Repo, link string) error {
client := setupClient(g.API, user.Token)
@ -243,13 +255,13 @@ func (g *Github) DelHook(user *model.User, repo *model.Repo, link string) error
return err
}
repo_, _, err := client.Repositories.Get(repo.Owner, repo.Name)
currentRepo, _, err := client.Repositories.Get(repo.Owner, repo.Name)
if err != nil {
return err
}
client_ := NewClientToken(g.API, user.Token)
branch, _ := client_.Branch(repo.Owner, repo.Name, *repo_.DefaultBranch)
currentClient := NewClientToken(g.API, user.Token)
branch, _ := currentClient.Branch(repo.Owner, repo.Name, *currentRepo.DefaultBranch)
if len(branch.Protection.Checks.Contexts) == 0 {
return nil
}
@ -260,20 +272,21 @@ func (g *Github) DelHook(user *model.User, repo *model.Repo, link string) error
}
}
branch.Protection.Checks.Contexts = checks
return client_.BranchProtect(repo.Owner, repo.Name, *repo_.DefaultBranch, branch)
return currentClient.BranchProtect(repo.Owner, repo.Name, *currentRepo.DefaultBranch, branch)
}
// GetComments retrieves comments from the API.
func (g *Github) GetComments(u *model.User, r *model.Repo, num int) ([]*model.Comment, error) {
client := setupClient(g.API, u.Token)
opts := github.IssueListCommentsOptions{Direction: "desc", Sort: "created"}
opts.PerPage = 100
comments_, _, err := client.Issues.ListComments(r.Owner, r.Name, num, &opts)
apiComments, _, err := client.Issues.ListComments(r.Owner, r.Name, num, &opts)
if err != nil {
return nil, err
}
comments := []*model.Comment{}
for _, comment := range comments_ {
for _, comment := range apiComments {
comments = append(comments, &model.Comment{
Author: *comment.User.Login,
Body: *comment.Body,
@ -282,6 +295,7 @@ func (g *Github) GetComments(u *model.User, r *model.Repo, num int) ([]*model.Co
return comments, nil
}
// GetContents retrieves a file from the API.
func (g *Github) GetContents(u *model.User, r *model.Repo, path string) ([]byte, error) {
client := setupClient(g.API, u.Token)
content, _, _, err := client.Repositories.GetContents(r.Owner, r.Name, path, nil)
@ -291,6 +305,7 @@ func (g *Github) GetContents(u *model.User, r *model.Repo, path string) ([]byte,
return content.Decode()
}
// SetStatus sets the pull request status through the API.
func (g *Github) SetStatus(u *model.User, r *model.Repo, num, granted, required int) error {
client := setupClient(g.API, u.Token)
@ -317,6 +332,7 @@ func (g *Github) SetStatus(u *model.User, r *model.Repo, num, granted, required
return err
}
// GetHook gets a webhook from the API.
func (g *Github) GetHook(r *http.Request) (*model.Hook, error) {
// only process comment hooks

Просмотреть файл

@ -1,5 +1,6 @@
package github
// Error represents an API error.
type Error struct {
Message string `json:"message"`
}
@ -7,6 +8,7 @@ type Error struct {
func (e Error) Error() string { return e.Message }
func (e Error) String() string { return e.Message }
// Branch represents a branch, including protection.
type Branch struct {
Protection struct {
Enabled bool `json:"enabled"`

Просмотреть файл

@ -17,7 +17,7 @@ func setupClient(rawurl, accessToken string) *github.Client {
return github
}
// GetHook is a heper function that retrieves a hook by
// GetHook is a helper function that retrieves a hook by
// hostname. To do this, it will retrieve a list of all hooks
// and iterate through the list.
func GetHook(client *github.Client, owner, name, rawurl string) (*github.Hook, error) {
@ -47,6 +47,8 @@ func GetHook(client *github.Client, owner, name, rawurl string) (*github.Hook, e
return nil, nil
}
// DeleteHook is a helper function that deletes a post-commit hook
// for the specified repository.
func DeleteHook(client *github.Client, owner, name, url string) error {
hook, err := GetHook(client, owner, name, url)
if err != nil {
@ -59,7 +61,7 @@ func DeleteHook(client *github.Client, owner, name, url string) error {
return err
}
// CreateHook is a heper function that creates a post-commit hook
// CreateHook is a helper function that creates a post-commit hook
// for the specified repository.
func CreateHook(client *github.Client, owner, name, url string) (*github.Hook, error) {
var hook = new(github.Hook)
@ -72,7 +74,7 @@ func CreateHook(client *github.Client, owner, name, url string) (*github.Hook, e
return created, err
}
// GetFile is a heper function that retrieves a file from
// GetFile is a helper function that retrieves a file from
// GitHub and returns its contents in byte array format.
func GetFile(client *github.Client, owner, name, path, ref string) ([]byte, error) {
var opts = new(github.RepositoryContentGetOptions)

Просмотреть файл

@ -9,6 +9,7 @@ import (
"golang.org/x/net/context"
)
// Remote represents a general interface for remote communications.
type Remote interface {
// GetUser authenticates a user with the remote system.
GetUser(http.ResponseWriter, *http.Request) (*model.User, error)
@ -123,11 +124,12 @@ func GetHook(c context.Context, r *http.Request) (*model.Hook, error) {
return FromContext(c).GetHook(r)
}
// RemoveIssueLabels remove the labels of some issue
// RemoveIssueLabels remove the labels of some issue.
func RemoveIssueLabels(c context.Context, user *model.User, repo *model.Repo, number int, labels []string) error {
return FromContext(c).RemoveIssueLabels(user, repo, number, labels)
}
// AddIssueLabels writes labels for the requirements of reviews.
func AddIssueLabels(c context.Context, user *model.User, repo *model.Repo, number int, labels []string) error {
return FromContext(c).AddIssueLabels(user, repo, number, labels)
}

Просмотреть файл

@ -8,6 +8,7 @@ import (
"github.com/gin-gonic/gin"
)
// RepoAdmin is a middleware to check if the current user is an admin.
func RepoAdmin(c *gin.Context) {
var (
owner = c.Param("owner")
@ -32,6 +33,7 @@ func RepoAdmin(c *gin.Context) {
c.Next()
}
// RepoPull is a middleware to check if the user is allowed to pull from the repo.
func RepoPull(c *gin.Context) {
var (
owner = c.Param("owner")

Просмотреть файл

@ -13,10 +13,11 @@ var (
ttl = envflag.Duration("CACHE_TTL", time.Minute*15, "")
)
// Cache is a simple caching middleware.
func Cache() gin.HandlerFunc {
cache_ := cache.NewTTL(*ttl)
cacheInstance := cache.NewTTL(*ttl)
return func(c *gin.Context) {
c.Set("cache", cache_)
c.Set("cache", cacheInstance)
c.Next()
}
}

Просмотреть файл

@ -10,8 +10,13 @@ import (
)
const (
// DefaultURL defines the standard remote URL.
DefaultURL = "https://github.com"
// DefaultAPI defines the standard API URL
DefaultAPI = "https://api.github.com/"
// DefaultScope defines the standard scope for the remote.
DefaultScope = "user:email,read:org,public_repo"
)
@ -22,6 +27,7 @@ var (
scope = envflag.String("GITHUB_SCOPE", DefaultScope, "")
)
// Remote is a simple middleware which configures the remote authentication.
func Remote() gin.HandlerFunc {
remote := &github.Github{
API: DefaultAPI,

Просмотреть файл

@ -10,6 +10,7 @@ import (
"github.com/gin-gonic/gin"
)
// User fetches the current user from the context.
func User(c *gin.Context) *model.User {
v, ok := c.Get("user")
if !ok {
@ -22,6 +23,7 @@ func User(c *gin.Context) *model.User {
return u
}
// UserMust enforces the fetch of the current user from the context.
func UserMust(c *gin.Context) {
user := User(c)
switch {
@ -33,6 +35,7 @@ func UserMust(c *gin.Context) {
}
}
// SetUser is used as a middleware to set the current user.
func SetUser(c *gin.Context) {
var user *model.User

Просмотреть файл

@ -12,6 +12,7 @@ var (
datasource = envflag.String("DATABASE_DATASOURCE", "lgtm.sqlite", "")
)
// Store is a middleware to initialize the database.
func Store() gin.HandlerFunc {
store := datastore.New(*driver, *datasource)
return func(c *gin.Context) {

Просмотреть файл

@ -13,6 +13,7 @@ import (
"github.com/go-gitea/lgtm/web/template"
)
// Load builds a handler for the server, it also defines all available routes.
func Load(middleware ...gin.HandlerFunc) http.Handler {
e := gin.New()
e.Use(gin.Recovery())

Просмотреть файл

@ -5,11 +5,11 @@ import (
"strings"
)
// IsHttps is a helper function that evaluates the http.Request
// IsHTTPS is a helper function that evaluates the http.Request
// and returns True if the Request uses HTTPS. It is able to detect,
// using the X-Forwarded-Proto, if the original request was HTTPS and
// routed through a reverse proxy with SSL termination.
func IsHttps(r *http.Request) bool {
func IsHTTPS(r *http.Request) bool {
switch {
case r.URL.Scheme == "https":
return true
@ -91,7 +91,7 @@ func SetCookie(w http.ResponseWriter, r *http.Request, name, value string) {
Path: "/",
Domain: r.URL.Host,
HttpOnly: true,
Secure: IsHttps(r),
Secure: IsHTTPS(r),
MaxAge: 2147483647, // the cooke value (token) is responsible for expiration
}

Просмотреть файл

@ -7,23 +7,33 @@ import (
"github.com/dgrijalva/jwt-go"
)
// SecretFunc is the definition of the required secret retrieval function.
type SecretFunc func(*Token) (string, error)
const (
// UserToken is the name of the user token.
UserToken = "user"
// SessToken is the name of the session token.
SessToken = "sess"
// HookToken is the name of the hook token.
HookToken = "hook"
// CsrfToken is the name of the CSRF token.
CsrfToken = "csrf"
)
// Default algorithm used to sign JWT tokens.
// SignerAlgo defines the default algorithm used to sign JWT tokens.
const SignerAlgo = "HS256"
// Token represents our simple JWT.
type Token struct {
Kind string
Text string
}
// Parse parses a raw JWT.
func Parse(raw string, fn SecretFunc) (*Token, error) {
token := &Token{}
parsed, err := jwt.Parse(raw, keyFunc(token, fn))
@ -35,6 +45,7 @@ func Parse(raw string, fn SecretFunc) (*Token, error) {
return token, nil
}
// ParseRequest parses a JWT from the request.
func ParseRequest(r *http.Request, fn SecretFunc) (*Token, error) {
var token = r.Header.Get("Authorization")
@ -62,6 +73,7 @@ func ParseRequest(r *http.Request, fn SecretFunc) (*Token, error) {
return Parse(cookie.Value, fn)
}
// CheckCsrf checks the validity of the JWT.
func CheckCsrf(r *http.Request, fn SecretFunc) error {
// get and options requests are always
@ -77,6 +89,7 @@ func CheckCsrf(r *http.Request, fn SecretFunc) error {
return err
}
// New initializes a new JWT.
func New(kind, text string) *Token {
return &Token{Kind: kind, Text: text}
}
@ -87,7 +100,7 @@ func (t *Token) Sign(secret string) (string, error) {
return t.SignExpires(secret, 0)
}
// Sign signs the token using the given secret hash
// SignExpires signs the token using the given secret hash
// with an expiration date.
func (t *Token) SignExpires(secret string, exp int64) (string, error) {
token := jwt.New(jwt.SigningMethodHS256)

Просмотреть файл

@ -7,12 +7,15 @@ import (
"github.com/go-gitea/lgtm/store"
"github.com/go-gitea/lgtm/store/migration"
"github.com/Sirupsen/logrus"
_ "github.com/go-sql-driver/mysql"
_ "github.com/mattn/go-sqlite3"
"github.com/rubenv/sql-migrate"
"github.com/russross/meddler"
// Import the MySQL driver
_ "github.com/go-sql-driver/mysql"
// Import the SQlite3 driver
_ "github.com/mattn/go-sqlite3"
)
type datastore struct {

Просмотреть файл

@ -1,7 +1,7 @@
// Code generated by go-bindata.
// sources:
// sqlite3/1_init.sql
// mysql/1_init.sql
// sqlite3/1.sql
// mysql/1.sql
// DO NOT EDIT!
package migration
@ -69,42 +69,42 @@ func (fi bindataFileInfo) Sys() interface{} {
return nil
}
var _sqlite31_initSql = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\x8c\x92\x4d\x6e\xc2\x30\x10\x46\xf7\x3e\xc5\x2c\x41\x85\x13\xb0\x32\xcd\xb4\xb2\x0a\x36\x35\x8e\x14\x56\xc8\x6a\xad\xc8\x22\x7f\x72\x02\xed\xf1\x9b\x58\x4e\x20\x5e\x54\x64\x65\x3d\x79\xbe\xcc\x1b\xcf\x7a\x0d\x2f\xa5\xcd\x9d\xee\x0c\xa4\x0d\x21\xaf\x12\xa9\x42\x50\x74\xbb\x43\x60\x6f\xc0\x85\x02\xcc\xd8\x51\x1d\xe1\xda\x1a\xd7\xc2\x82\xf8\xc3\xd9\x7e\x83\xff\x18\x57\xf8\x8e\x12\x0e\x92\xed\xa9\x3c\xc1\x07\x9e\x80\xa6\x4a\x30\xde\x47\xed\x91\x2b\xb2\xf2\xf7\x8b\x3a\xb7\x55\x7f\x5f\x61\x36\xa2\xae\xbe\x98\x08\x99\x52\xdb\x62\x8e\xf4\x4d\x77\xda\xcd\x50\x6b\xbe\x9c\xe9\x02\x22\xab\x94\xb3\xcf\x14\x17\xf7\xdf\x2c\xc9\x72\xf3\xaf\x8a\x33\x4d\xed\x55\x86\xc3\xa4\xf2\x8c\x8b\x2f\x98\x06\x10\x0a\x02\xae\x7f\x2a\xe3\x60\xea\xde\xb3\x4a\x97\x06\x22\xd6\x16\xd7\x3c\x66\x85\xad\x2e\x31\x6b\x9c\xbd\x0d\xef\x02\x5b\x21\x76\x48\xf9\x58\x1e\xec\x23\xfd\x29\x7a\x66\xcf\x78\x82\x59\x64\x6f\x7f\xcf\xb3\x7e\x05\x1f\x07\x72\xc7\x7d\xc4\x13\x09\xe3\x20\xa2\x84\x80\x87\x36\x1e\xf7\x2b\xe9\x93\x09\x49\xa4\x38\x84\x47\xf1\x35\x9b\x47\xe2\x77\x6c\x43\xfe\x02\x00\x00\xff\xff\x54\x85\x0e\xca\x96\x02\x00\x00")
var _sqlite31SQL = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\x8c\x92\x4d\x6e\xc2\x30\x10\x46\xf7\x3e\xc5\x2c\x41\x85\x13\xb0\x32\xcd\xb4\xb2\x0a\x36\x35\x8e\x14\x56\xc8\x6a\xad\xc8\x22\x7f\x72\x02\xed\xf1\x9b\x58\x4e\x20\x5e\x54\x64\x65\x3d\x79\xbe\xcc\x1b\xcf\x7a\x0d\x2f\xa5\xcd\x9d\xee\x0c\xa4\x0d\x21\xaf\x12\xa9\x42\x50\x74\xbb\x43\x60\x6f\xc0\x85\x02\xcc\xd8\x51\x1d\xe1\xda\x1a\xd7\xc2\x82\xf8\xc3\xd9\x7e\x83\xff\x18\x57\xf8\x8e\x12\x0e\x92\xed\xa9\x3c\xc1\x07\x9e\x80\xa6\x4a\x30\xde\x47\xed\x91\x2b\xb2\xf2\xf7\x8b\x3a\xb7\x55\x7f\x5f\x61\x36\xa2\xae\xbe\x98\x08\x99\x52\xdb\x62\x8e\xf4\x4d\x77\xda\xcd\x50\x6b\xbe\x9c\xe9\x02\x22\xab\x94\xb3\xcf\x14\x17\xf7\xdf\x2c\xc9\x72\xf3\xaf\x8a\x33\x4d\xed\x55\x86\xc3\xa4\xf2\x8c\x8b\x2f\x98\x06\x10\x0a\x02\xae\x7f\x2a\xe3\x60\xea\xde\xb3\x4a\x97\x06\x22\xd6\x16\xd7\x3c\x66\x85\xad\x2e\x31\x6b\x9c\xbd\x0d\xef\x02\x5b\x21\x76\x48\xf9\x58\x1e\xec\x23\xfd\x29\x7a\x66\xcf\x78\x82\x59\x64\x6f\x7f\xcf\xb3\x7e\x05\x1f\x07\x72\xc7\x7d\xc4\x13\x09\xe3\x20\xa2\x84\x80\x87\x36\x1e\xf7\x2b\xe9\x93\x09\x49\xa4\x38\x84\x47\xf1\x35\x9b\x47\xe2\x77\x6c\x43\xfe\x02\x00\x00\xff\xff\x54\x85\x0e\xca\x96\x02\x00\x00")
func sqlite31_initSqlBytes() ([]byte, error) {
func sqlite31SQLBytes() ([]byte, error) {
return bindataRead(
_sqlite31_initSql,
"sqlite3/1_init.sql",
_sqlite31SQL,
"sqlite3/1.sql",
)
}
func sqlite31_initSql() (*asset, error) {
bytes, err := sqlite31_initSqlBytes()
func sqlite31SQL() (*asset, error) {
bytes, err := sqlite31SQLBytes()
if err != nil {
return nil, err
}
info := bindataFileInfo{name: "sqlite3/1_init.sql", size: 662, mode: os.FileMode(420), modTime: time.Unix(1478811055, 0)}
info := bindataFileInfo{name: "sqlite3/1.sql", size: 662, mode: os.FileMode(420), modTime: time.Unix(1478811055, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
var _mysql1_initSql = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\x8c\x92\x4f\x6f\xc2\x20\x18\xc6\xef\x7c\x8a\xf7\xa8\x99\x26\x9b\x99\x27\x4f\xa8\x6c\x23\x53\x70\x48\x17\x3d\x19\xb2\x91\x86\xd8\x7f\xa1\xd5\xed\xe3\xaf\x25\xb4\xb5\xce\x2e\xeb\x89\xbc\xbf\xfc\xa0\xcf\x03\xe3\x31\xdc\xc5\x26\xb4\xaa\xd0\x10\x64\x08\x2d\x04\xc1\x92\x80\xc4\xf3\x15\x01\xfa\x04\x8c\x4b\x20\x3b\xba\x95\x5b\x38\xe5\xda\xe6\x30\x40\x6e\x71\x30\x9f\xe0\x3e\xca\x24\x79\x26\x02\x36\x82\xae\xb1\xd8\xc3\x2b\xd9\x03\x0e\x24\x3f\x50\x56\xee\xb5\x26\x4c\xa2\x91\x13\xa2\x34\x34\x49\x29\xbc\x63\xb1\x78\xc1\x62\x30\x99\x4e\x87\x1e\x15\xe9\x51\xf7\x20\x1d\x2b\x13\xdd\x46\xea\xac\x0a\x65\x5b\xf4\x70\x3f\x79\xac\x59\xae\x3f\xac\x2e\xae\x34\x34\x0a\x18\x7d\x0b\xc8\xa0\xfd\x9f\x21\x1a\xce\xfe\x0c\x6d\x75\x96\xba\xd0\xd5\xa2\x09\xfd\xaf\xd4\xce\x68\xba\xf2\x86\x1f\xa7\x5f\x89\xb6\xf0\x2b\x97\x63\x89\x8a\x35\xf4\xb0\x3c\x3a\x85\x7d\x2c\x32\xc9\xb1\xc3\x7c\x21\x0e\x66\xd6\x9c\xab\x3b\x86\x39\xe7\x2b\x82\x59\xbd\x9f\xef\xa9\xa7\xa8\xe6\xcc\x4e\x4f\x94\x2d\xc9\x0e\xcc\xf7\xa1\x13\x85\xb3\xba\xac\x76\x5c\x4a\x37\x9d\xba\x95\x2b\xc7\x8f\xab\xa3\x2e\xdf\xe5\xb2\xdc\x0b\xa1\xa5\xe0\x1b\x7f\x45\xce\x99\x5d\x4e\xdc\xdb\x9c\xa1\x9f\x00\x00\x00\xff\xff\xbb\xdd\xcc\xcc\xce\x02\x00\x00")
var _mysql1SQL = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\x8c\x92\x4f\x6f\xc2\x20\x18\xc6\xef\x7c\x8a\xf7\xa8\x99\x26\x9b\x99\x27\x4f\xa8\x6c\x23\x53\x70\x48\x17\x3d\x19\xb2\x91\x86\xd8\x7f\xa1\xd5\xed\xe3\xaf\x25\xb4\xb5\xce\x2e\xeb\x89\xbc\xbf\xfc\xa0\xcf\x03\xe3\x31\xdc\xc5\x26\xb4\xaa\xd0\x10\x64\x08\x2d\x04\xc1\x92\x80\xc4\xf3\x15\x01\xfa\x04\x8c\x4b\x20\x3b\xba\x95\x5b\x38\xe5\xda\xe6\x30\x40\x6e\x71\x30\x9f\xe0\x3e\xca\x24\x79\x26\x02\x36\x82\xae\xb1\xd8\xc3\x2b\xd9\x03\x0e\x24\x3f\x50\x56\xee\xb5\x26\x4c\xa2\x91\x13\xa2\x34\x34\x49\x29\xbc\x63\xb1\x78\xc1\x62\x30\x99\x4e\x87\x1e\x15\xe9\x51\xf7\x20\x1d\x2b\x13\xdd\x46\xea\xac\x0a\x65\x5b\xf4\x70\x3f\x79\xac\x59\xae\x3f\xac\x2e\xae\x34\x34\x0a\x18\x7d\x0b\xc8\xa0\xfd\x9f\x21\x1a\xce\xfe\x0c\x6d\x75\x96\xba\xd0\xd5\xa2\x09\xfd\xaf\xd4\xce\x68\xba\xf2\x86\x1f\xa7\x5f\x89\xb6\xf0\x2b\x97\x63\x89\x8a\x35\xf4\xb0\x3c\x3a\x85\x7d\x2c\x32\xc9\xb1\xc3\x7c\x21\x0e\x66\xd6\x9c\xab\x3b\x86\x39\xe7\x2b\x82\x59\xbd\x9f\xef\xa9\xa7\xa8\xe6\xcc\x4e\x4f\x94\x2d\xc9\x0e\xcc\xf7\xa1\x13\x85\xb3\xba\xac\x76\x5c\x4a\x37\x9d\xba\x95\x2b\xc7\x8f\xab\xa3\x2e\xdf\xe5\xb2\xdc\x0b\xa1\xa5\xe0\x1b\x7f\x45\xce\x99\x5d\x4e\xdc\xdb\x9c\xa1\x9f\x00\x00\x00\xff\xff\xbb\xdd\xcc\xcc\xce\x02\x00\x00")
func mysql1_initSqlBytes() ([]byte, error) {
func mysql1SQLBytes() ([]byte, error) {
return bindataRead(
_mysql1_initSql,
"mysql/1_init.sql",
_mysql1SQL,
"mysql/1.sql",
)
}
func mysql1_initSql() (*asset, error) {
bytes, err := mysql1_initSqlBytes()
func mysql1SQL() (*asset, error) {
bytes, err := mysql1SQLBytes()
if err != nil {
return nil, err
}
info := bindataFileInfo{name: "mysql/1_init.sql", size: 718, mode: os.FileMode(420), modTime: time.Unix(1478811055, 0)}
info := bindataFileInfo{name: "mysql/1.sql", size: 718, mode: os.FileMode(420), modTime: time.Unix(1478811055, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
@ -161,8 +161,8 @@ func AssetNames() []string {
// _bindata is a table, holding each asset generator, mapped to its name.
var _bindata = map[string]func() (*asset, error){
"sqlite3/1_init.sql": sqlite31_initSql,
"mysql/1_init.sql": mysql1_initSql,
"sqlite3/1.sql": sqlite31SQL,
"mysql/1.sql": mysql1SQL,
}
// AssetDir returns the file names below a certain
@ -207,10 +207,10 @@ type bintree struct {
var _bintree = &bintree{nil, map[string]*bintree{
"mysql": &bintree{nil, map[string]*bintree{
"1_init.sql": &bintree{mysql1_initSql, map[string]*bintree{}},
"1.sql": &bintree{mysql1SQL, map[string]*bintree{}},
}},
"sqlite3": &bintree{nil, map[string]*bintree{
"1_init.sql": &bintree{sqlite31_initSql, map[string]*bintree{}},
"1.sql": &bintree{sqlite31SQL, map[string]*bintree{}},
}},
}}

Просмотреть файл

@ -2,3 +2,5 @@ package migration
//go:generate go-bindata -pkg migration -o bindata.go sqlite3/ mysql/
//go:generate go fmt bindata.go
//go:generate sed -i.bak "s/Sql/SQL/" bindata.go
//go:generate rm bindata.go.bak

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -17,6 +17,7 @@ var (
labels = []string{"lgtm/need 2", "lgtm/need 1", "lgtm/done"}
)
// Hook is the handler for hook pages.
func Hook(c *gin.Context) {
hook, err := remote.GetHook(c, c.Request)
if err != nil {
@ -64,11 +65,11 @@ func Hook(c *gin.Context) {
log.Errorf("Error getting org members %s. %s", repo.Owner, merr)
c.String(404, "MAINTAINERS file not found. %s", err)
return
} else {
for _, member := range members {
file = append(file, member.Login...)
file = append(file, '\n')
}
}
for _, member := range members {
file = append(file, member.Login...)
file = append(file, '\n')
}
}

Просмотреть файл

@ -8,6 +8,7 @@ import (
"github.com/gin-gonic/gin"
)
// Index is the handler for index pages.
func Index(c *gin.Context) {
user := session.User(c)

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 18 KiB

После

Ширина:  |  Высота:  |  Размер: 18 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 37 KiB

После

Ширина:  |  Высота:  |  Размер: 37 KiB

Просмотреть файл

@ -2,6 +2,10 @@ package static
//go:generate go-bindata -pkg static -o bindata.go files/...
//go:generate go fmt bindata.go
//go:generate sed -i.bak "s/Css/CSS/" bindata.go
//go:generate rm bindata.go.bak
//go:generate sed -i.bak "s/Html/HTML/" bindata.go
//go:generate rm bindata.go.bak
import (
"net/http"
@ -9,6 +13,7 @@ import (
"github.com/elazarl/go-bindata-assetfs"
)
// FileSystem is an HTTP filesystem handle for static files.
func FileSystem() http.FileSystem {
fs := &assetfs.AssetFS{Asset: Asset, AssetDir: AssetDir, Prefix: "files"}
return &binaryFileSystem{

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -2,6 +2,8 @@ package template
//go:generate go-bindata -pkg template -o bindata.go files/
//go:generate go fmt bindata.go
//go:generate sed -i.bak "s/Html/HTML/" bindata.go
//go:generate rm bindata.go.bak
import (
"encoding/json"
@ -9,6 +11,7 @@ import (
"path/filepath"
)
// Template is a template handler for the used templates.
func Template() *template.Template {
funcs := map[string]interface{}{
"json": marshal,