Commit f208cd14 by 刘旋尧

as

parents b8e4d06c 37f4a12e
......@@ -111,7 +111,7 @@ type PullRemoteOptions struct {
}
// Pull pulls changes from remotes.
func Pull(repoPath string, opts PullRemoteOptions) error {
func Pull(repoPath string, opts PullRemoteOptions) ([]byte,error) {
cmd := NewCommand("pull")
if opts.All {
cmd.AddArguments("--all")
......@@ -121,8 +121,8 @@ func Pull(repoPath string, opts PullRemoteOptions) error {
opts.Timeout = -1
}
_, err := cmd.RunInDirTimeout(opts.Timeout, repoPath)
return err
info, err := cmd.RunInDirTimeout(opts.Timeout, repoPath)
return info,err
}
// Push pushs local commits to given remote branch.
......
......@@ -2,3 +2,8 @@ appname = service
httpport = 8080
runmode = dev
copyrequestbody = true
autorender=false
upusername=staticydl
uppassword=ydl12345com
upbucket=staticydl
......@@ -2,10 +2,12 @@ package controllers
import (
"github.com/astaxie/beego"
//"github.com/usual2970/util/git-module"
"github.com/usual2970/util/git-module"
"github.com/astaxie/beego/logs"
"github.com/pquerna/ffjson/ffjson"
"io/ioutil"
"regexp"
"fmt"
"github.com/upyun/go-sdk/upyun"
"os"
)
type GitController struct {
......@@ -31,63 +33,47 @@ type PData struct{
* @return {[type]} [description]
*/
func (c *GitController) Hook() {
resp:=&HookInfo{}
//ffjson.Unmarshal(c.Ctx.Input.RequestBody,resp)
pc,_:=ioutil.ReadAll(c.Ctx.Request.Body)
log.Info(string(pc))
ffjson.Unmarshal(pc,resp)
log.Info(resp.HookName)
// str:=`{
// "password": "hod20x4hnkecy63",
// "hook_name": "push_hooks",
// "push_data": {
// "before": "26c9fb3533d1c63e3b822d58a8831b1caf6d9cd7",
// "after": "219aa13d45276a5cae7436ecc66053da67ec2a2d",
// "ref": "refs/heads/master",
// "user_id": 449815,
// "user_name": "gitlabu6d4bu8bd5u8d26u53f72",
// "user": {
// "id": 449815,
// "email": "gitlabtest_2@gitlab.com",
// "name": "gitlabu6d4bu8bd5u8d26u53f72",
// "time": "2015-11-06T14:51:55+08:00"
// },
// "repository": {
// "name": "test_gitosc_20151106145021322",
// "url": "git@git.oschina.net:gitlab_test_1/test_gitosc_20151106145021322.git",
// "description": "test_gitosc_20151106145021322 testting",
// "homepage": "http://git.oschina.net/gitlab_test_1/test_gitosc_20151106145021322"
// },
// "commits": [
// {
// "id": "219aa13d45276a5cae7436ecc66053da67ec2a2d",
// "message": "commit_access_test",
// "timestamp": "2015-11-06T14:50:47+08:00",
// "url": "http://git.oschina.net/gitlab_test_1/test_gitosc_20151106145021322/commit/219aa13d45276a5cae7436ecc66053da67ec2a2d",
// "author": {
// "name": "gitlab_test_2",
// "email": "gitlabtest_2@gitlab.com",
// "time": "2015-11-06T14:50:47+08:00"
// }
// }
// ],
// "total_commits_count": 1,
// "commits_more_than_ten": false
// }
// }`
// resp:=&HookInfo{}
// ffjson.Unmarshal([]byte(str),resp)
// println(resp.PushData.Before)
// rs,_:=git.Diff("/var/www/ydl","bba21848d31031eaf975c1ee858274a9f64a5dd6","b304de0b79cb113ce8ac6f139fcf1d204f476c50")
// log.Info(rs)
c.ServeJSON()
repoPath:="/var/www/static.yidianling.com/"
options:=git.PullRemoteOptions{false,0}
info,_:=git.Pull(repoPath,options)
re := regexp.MustCompile("\\s+(.*)\\s+\\|\\s+\\d+\\s.*\n")
upList:=re.FindAllStringSubmatch(string(info),-1)
up:=upyun.NewUpYun(beego.AppConfig.String("upbucket"),beego.AppConfig.String("upusername"),beego.AppConfig.String("uppassword"))
if len(upList)>0{
for _,v:=range upList{
fd,err:=os.Open(repoPath+v[1])
if err!=nil{
continue
}
_,err=up.Put("/"+v[1],fd,false,nil)
if err!=nil{
fmt.Println(err)
}
fmt.Println(v[1])
fd.Close()
}
}
crRe:= regexp.MustCompile("\\s+create\\s+mode\\s+\\d+\\s+([^\\s]*)")
crList:=crRe.FindAllStringSubmatch(string(info),-1)
if len(crList)>0{
for _,cr:=range crList{
fd,err:=os.Open(repoPath+cr[1])
if err!=nil{
continue
}
up.Put("/"+cr[1],fd,false,nil)
fmt.Println(cr[1])
fd.Close()
}
}
log.Info(string(info))
}
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -2,7 +2,7 @@ package tel
var AppKey = "34429289df7c45ac90cbd91debcfa5c1"
var AppSecret = "7b90b109fc059f03"
var DispayNumber = "+8657156150625"
var DispayNumber = "+8657156150626"
var CallbackUrl = "aHR0cDovL2gueWlkaWFubGluZy5jb20vbGlzdGVuL2NiLWNt"
var CerPath="/var/www/yidianling/common/components/yunxun/iSimularClient.pem"
var DialUrl="https://aep.sdp.com:1101/tropo/click2CallEx/v1"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment