From e030109b5af9015c018cdc6f18655e201f6008bf Mon Sep 17 00:00:00 2001 From: Unknwon Date: Sun, 15 Nov 2015 17:07:44 -0500 Subject: [PATCH] fix api broken --- cmd/cert.go | 12 ++++++------ cmd/cmd.go | 42 ++++++++++++++++++++++++++++++++++++++++++ cmd/dump.go | 4 ++-- cmd/serve.go | 2 +- cmd/update.go | 2 +- cmd/web.go | 4 ++-- models/action.go | 4 ++++ modules/ssh/ssh.go | 1 + 8 files changed, 59 insertions(+), 12 deletions(-) create mode 100644 cmd/cmd.go diff --git a/cmd/cert.go b/cmd/cert.go index 5b182da9..7b68f330 100644 --- a/cmd/cert.go +++ b/cmd/cert.go @@ -32,12 +32,12 @@ var CmdCert = cli.Command{ Outputs to 'cert.pem' and 'key.pem' and will overwrite existing files.`, Action: runCert, Flags: []cli.Flag{ - cli.StringFlag{"host", "", "Comma-separated hostnames and IPs to generate a certificate for", ""}, - cli.StringFlag{"ecdsa-curve", "", "ECDSA curve to use to generate a key. Valid values are P224, P256, P384, P521", ""}, - cli.IntFlag{"rsa-bits", 2048, "Size of RSA key to generate. Ignored if --ecdsa-curve is set", ""}, - cli.StringFlag{"start-date", "", "Creation date formatted as Jan 1 15:04:05 2011", ""}, - cli.DurationFlag{"duration", 365 * 24 * time.Hour, "Duration that certificate is valid for", ""}, - cli.BoolFlag{"ca", "whether this cert should be its own Certificate Authority", ""}, + stringFlag("host", "", "Comma-separated hostnames and IPs to generate a certificate for"), + stringFlag("ecdsa-curve", "", "ECDSA curve to use to generate a key. Valid values are P224, P256, P384, P521"), + intFlag("rsa-bits", 2048, "Size of RSA key to generate. Ignored if --ecdsa-curve is set"), + stringFlag("start-date", "", "Creation date formatted as Jan 1 15:04:05 2011"), + durationFlag("duration", 365*24*time.Hour, "Duration that certificate is valid for"), + boolFlag("ca", "whether this cert should be its own Certificate Authority"), }, } diff --git a/cmd/cmd.go b/cmd/cmd.go new file mode 100644 index 00000000..8df02d5c --- /dev/null +++ b/cmd/cmd.go @@ -0,0 +1,42 @@ +// Copyright 2015 The Gogs Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package cmd + +import ( + "time" + + "github.com/codegangsta/cli" +) + +func stringFlag(name, value, usage string) cli.StringFlag { + return cli.StringFlag{ + Name: name, + Value: value, + Usage: usage, + } +} + +func boolFlag(name, usage string) cli.BoolFlag { + return cli.BoolFlag{ + Name: name, + Usage: usage, + } +} + +func intFlag(name string, value int, usage string) cli.IntFlag { + return cli.IntFlag{ + Name: name, + Value: value, + Usage: usage, + } +} + +func durationFlag(name string, value time.Duration, usage string) cli.DurationFlag { + return cli.DurationFlag{ + Name: name, + Value: value, + Usage: usage, + } +} diff --git a/cmd/dump.go b/cmd/dump.go index 44b180c3..0bf385d0 100644 --- a/cmd/dump.go +++ b/cmd/dump.go @@ -25,8 +25,8 @@ var CmdDump = cli.Command{ It can be used for backup and capture Gogs server image to send to maintainer`, Action: runDump, Flags: []cli.Flag{ - cli.StringFlag{"config, c", "custom/conf/app.ini", "Custom configuration file path", ""}, - cli.BoolFlag{"verbose, v", "show process details", ""}, + stringFlag("config, c", "custom/conf/app.ini", "Custom configuration file path"), + boolFlag("verbose, v", "show process details"), }, } diff --git a/cmd/serve.go b/cmd/serve.go index b5713752..b6ab9bb8 100644 --- a/cmd/serve.go +++ b/cmd/serve.go @@ -33,7 +33,7 @@ var CmdServ = cli.Command{ Description: `Serv provide access auth for repositories`, Action: runServ, Flags: []cli.Flag{ - cli.StringFlag{"config, c", "custom/conf/app.ini", "Custom configuration file path", ""}, + stringFlag("config, c", "custom/conf/app.ini", "Custom configuration file path"), }, } diff --git a/cmd/update.go b/cmd/update.go index 289aedbf..4cd62a7f 100644 --- a/cmd/update.go +++ b/cmd/update.go @@ -20,7 +20,7 @@ var CmdUpdate = cli.Command{ Description: `Update get pushed info and insert into database`, Action: runUpdate, Flags: []cli.Flag{ - cli.StringFlag{"config, c", "custom/conf/app.ini", "Custom configuration file path", ""}, + stringFlag("config, c", "custom/conf/app.ini", "Custom configuration file path"), }, } diff --git a/cmd/web.go b/cmd/web.go index 950c3d48..dabea0ba 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -56,8 +56,8 @@ var CmdWeb = cli.Command{ and it takes care of all the other things for you`, Action: runWeb, Flags: []cli.Flag{ - cli.StringFlag{"port, p", "3000", "Temporary port number to prevent conflict", ""}, - cli.StringFlag{"config, c", "custom/conf/app.ini", "Custom configuration file path", ""}, + stringFlag("port, p", "3000", "Temporary port number to prevent conflict"), + stringFlag("config, c", "custom/conf/app.ini", "Custom configuration file path"), }, } diff --git a/models/action.go b/models/action.go index bb15d4a3..8dd80074 100644 --- a/models/action.go +++ b/models/action.go @@ -418,6 +418,10 @@ func CommitRepoAction( isNewBranch = true } + // NOTE: limit to detect latest 100 commits. + if len(commit.Commits) > 100 { + commit.Commits = commit.Commits[len(commit.Commits)-100:] + } if err = updateIssuesCommit(u, repo, repoUserName, repoName, commit.Commits); err != nil { log.Error(4, "updateIssuesCommit: %v", err) } diff --git a/modules/ssh/ssh.go b/modules/ssh/ssh.go index 706f5e75..fec43b79 100644 --- a/modules/ssh/ssh.go +++ b/modules/ssh/ssh.go @@ -83,6 +83,7 @@ func handleServerConn(keyID string, chans <-chan ssh.NewChannel) { return } + // FIXME: check timeout if err = cmd.Start(); err != nil { log.Error(3, "Start: %v", err) return