commands: remove last httputil usage

This commit is contained in:
risk danger olson 2017-01-04 16:10:53 -07:00
parent fecdc9e745
commit c9a03bb3bc
3 changed files with 33 additions and 5 deletions

@ -1,7 +1,7 @@
package commands package commands
import ( import (
"github.com/git-lfs/git-lfs/httputil" "github.com/git-lfs/git-lfs/lfsapi"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
@ -10,7 +10,7 @@ var (
) )
func versionCommand(cmd *cobra.Command, args []string) { func versionCommand(cmd *cobra.Command, args []string) {
Print(httputil.UserAgent) Print(lfsapi.UserAgent)
if lovesComics { if lovesComics {
Print("Nothing may see Gah Lak Tus and survive!") Print("Nothing may see Gah Lak Tus and survive!")

@ -3,11 +3,13 @@ package commands
import ( import (
"fmt" "fmt"
"os" "os"
"path/filepath"
"strings" "strings"
"sync" "sync"
"time"
"github.com/git-lfs/git-lfs/config" "github.com/git-lfs/git-lfs/config"
"github.com/git-lfs/git-lfs/httputil" "github.com/git-lfs/git-lfs/lfsapi"
"github.com/git-lfs/git-lfs/localstorage" "github.com/git-lfs/git-lfs/localstorage"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
@ -64,7 +66,7 @@ func Run() {
} }
root.Execute() root.Execute()
httputil.LogHttpStats(cfg) logHTTPStats(getAPIClient())
} }
func gitlfsCommand(cmd *cobra.Command, args []string) { func gitlfsCommand(cmd *cobra.Command, args []string) {
@ -103,3 +105,28 @@ func printHelp(commandName string) {
fmt.Fprintf(os.Stderr, "Sorry, no usage text found for %q\n", commandName) fmt.Fprintf(os.Stderr, "Sorry, no usage text found for %q\n", commandName)
} }
} }
func logHTTPStats(c *lfsapi.Client) {
if !c.LoggingStats {
return
}
file, err := statsLogFile()
if err != nil {
fmt.Fprintf(os.Stderr, "Error logging http stats: %s\n", err)
return
}
defer file.Close()
c.LogStats(file)
}
func statsLogFile() (*os.File, error) {
logBase := filepath.Join(config.LocalLogDir, "http")
if err := os.MkdirAll(logBase, 0755); err != nil {
return nil, err
}
logFile := fmt.Sprintf("http-%d.log", time.Now().Unix())
return os.Create(filepath.Join(logBase, logFile))
}

@ -102,7 +102,8 @@ begin_test "custom-transfer-upload-download"
grep "xfer: started custom adapter process" fetchcustom.log grep "xfer: started custom adapter process" fetchcustom.log
grep "xfer\[lfstest-customadapter\]:" fetchcustom.log grep "xfer\[lfstest-customadapter\]:" fetchcustom.log
grep "11 of 11 files" fetchcustom.log grep "11 of 11 files" fetchcustom.log
[ `find .git/lfs/objects -type f | wc -l` = 11 ]
objectlist=`find .git/lfs/objects -type f`
[ "$(echo "$objectlist" | wc -l)" -eq 11 ]
) )
end_test end_test