<commit_before>// Copyright 2014 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 main

import (
"os"
"os/exec"
"strings"
"strconv"
"container/list"

"github.com/codegangsta/cli"
//"github.com/gogits/gogs/modules/log"
"github.com/gogits/gogs/models"
"github.com/gogits/gogs/modules/base"
"github.com/qiniu/log"
"github.com/gogits/git"
)

var CmdUpdate = cli.Command{
	Name:  "update",
	Usage: "This command just should be called by ssh shell",
	Description: `
gogs serv provide access auth for repositories`,
	Action: runUpdate,
	Flags:  []cli.Flag{},
}

// for command: ./gogs update
func runUpdate(c *cli.Context) {
	//level := "0"
	//os.MkdirAll("log", os.ModePerm)
	//log.NewLogger(10000, "file", fmt.Sprintf(`{"level":%s,"filename":"%s"}`, level, "log/serv.log"))
	//log.Info("start update logging...")

	w, _ := os.Create("update.log")
	defer w.Close()

	log.SetOutput(w)



	args := c.Args()
	if len(args) != 3 {
		log.Error("received less 3 parameters")
		return
	}

	refName := args[0]
	oldCommitId := args[1]
	newCommitId := args[2]

	userName := os.Getenv("userName")
	userId := os.Getenv("userId")
	//repoId := os.Getenv("repoId")
	repoName := os.Getenv("repoName")

	log.Info("username", userName)
	log.Info("repoName", repoName)
	f := models.RepoPath(userName, repoName)
	log.Debug("f", f)

	gitUpdate := exec.Command("git", "update-server-info")
	gitUpdate.Dir = f
	gitUpdate.Run()
<commit_msg>bug fixed<commit_after>// Copyright 2014 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 main

import (
"os"
"os/exec"
"strings"
"strconv"
"container/list"

"github.com/codegangsta/cli"
//"github.com/gogits/gogs/modules/log"
"github.com/gogits/gogs/models"
"github.com/gogits/gogs/modules/base"
"github.com/qiniu/log"
"github.com/gogits/git"
)

var CmdUpdate = cli.Command{
	Name:  "update",
	Usage: "This command just should be called by ssh shell",
	Description: `
gogs serv provide access auth for repositories`,
	Action: runUpdate,
	Flags:  []cli.Flag{},
}

// for command: ./gogs update
func runUpdate(c *cli.Context) {
	//level := "0"
	//os.MkdirAll("log", os.ModePerm)
	//log.NewLogger(10000, "file", fmt.Sprintf(`{"level":%s,"filename":"%s"}`, level, "log/serv.log"))
	//log.Info("start update logging...")

	w, _ := os.Create("update.log")
	defer w.Close()

	log.SetOutput(w)



	args := c.Args()
	if len(args) != 3 {
		log.Error("received less 3 parameters")
		return
	}

	refName := args[0]
	oldCommitId := args[1]
	newCommitId := args[2]

	userName := os.Getenv("userName")
	userId := os.Getenv("userId")
	//repoId := os.Getenv("repoId")
	repoName := os.Getenv("repoName")

	log.Info("username", userName)
	log.Info("repoName", repoName)
	f := models.RepoPath(userName, repoName)
	log.Info("f", f)

	gitUpdate := exec.Command("git", "update-server-info")
	gitUpdate.Dir = f
	gitUpdate.Run()

{'fraction_non_alphanumeric': 0.17952964557800596, 'fraction_numerical': 0.009937065253395164, 'mean_word_length': 4.189003436426117, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2694105', 'n_tokens_mistral': 1174, 'n_tokens_neox': 1133, 'n_words': 265}