Commit 5d69cb4f by usual2970

静态资源同步到又拍云

parent 2078ddfd
...@@ -111,7 +111,7 @@ type PullRemoteOptions struct { ...@@ -111,7 +111,7 @@ type PullRemoteOptions struct {
} }
// Pull pulls changes from remotes. // Pull pulls changes from remotes.
func Pull(repoPath string, opts PullRemoteOptions) error { func Pull(repoPath string, opts PullRemoteOptions) ([]byte,error) {
cmd := NewCommand("pull") cmd := NewCommand("pull")
if opts.All { if opts.All {
cmd.AddArguments("--all") cmd.AddArguments("--all")
...@@ -121,8 +121,8 @@ func Pull(repoPath string, opts PullRemoteOptions) error { ...@@ -121,8 +121,8 @@ func Pull(repoPath string, opts PullRemoteOptions) error {
opts.Timeout = -1 opts.Timeout = -1
} }
_, err := cmd.RunInDirTimeout(opts.Timeout, repoPath) info, err := cmd.RunInDirTimeout(opts.Timeout, repoPath)
return err return info,err
} }
// Push pushs local commits to given remote branch. // Push pushs local commits to given remote branch.
......
...@@ -2,3 +2,8 @@ appname = service ...@@ -2,3 +2,8 @@ appname = service
httpport = 8080 httpport = 8080
runmode = dev runmode = dev
copyrequestbody = true copyrequestbody = true
autorender=false
upusername=ydl
uppassword=ydl123com
upbucket=staticydl
...@@ -2,9 +2,12 @@ package controllers ...@@ -2,9 +2,12 @@ package controllers
import ( import (
"github.com/astaxie/beego" "github.com/astaxie/beego"
//"github.com/usual2970/util/git-module" "github.com/usual2970/util/git-module"
"github.com/astaxie/beego/logs" "github.com/astaxie/beego/logs"
"github.com/pquerna/ffjson/ffjson" "regexp"
"fmt"
"github.com/upyun/go-sdk/upyun"
"os"
) )
type GitController struct { type GitController struct {
...@@ -30,63 +33,39 @@ type PData struct{ ...@@ -30,63 +33,39 @@ type PData struct{
* @return {[type]} [description] * @return {[type]} [description]
*/ */
func (c *GitController) Hook() { func (c *GitController) Hook() {
resp:=&HookInfo{} repoPath:="/var/www/worry/"
//ffjson.Unmarshal(c.Ctx.Input.RequestBody,resp) options:=git.PullRemoteOptions{false,0}
pc:=c.Ctx.Input.RequestBody info,_:=git.Pull(repoPath,options)
log.Info(string(pc)) re := regexp.MustCompile("\\s+(.*)\\s+\\|\\s+\\d+\\s.*\n")
upList:=re.FindAllStringSubmatch(string(info),-1)
ffjson.Unmarshal(pc,resp)
log.Info(resp.HookName)
// str:=`{ up:=upyun.NewUpYun(beego.AppConfig.String("upbucket"),beego.AppConfig.String("upusername"),beego.AppConfig.String("uppassword"))
// "password": "hod20x4hnkecy63",
// "hook_name": "push_hooks", if len(upList)>0{
// "push_data": { for _,v:=range upList{
// "before": "26c9fb3533d1c63e3b822d58a8831b1caf6d9cd7", fd,_:=os.Open(repoPath+v[1])
// "after": "219aa13d45276a5cae7436ecc66053da67ec2a2d", _,err:=up.Put("/"+v[1],fd,false,nil)
// "ref": "refs/heads/master", if err!=nil{
// "user_id": 449815, fmt.Println(err)
// "user_name": "gitlabu6d4bu8bd5u8d26u53f72", }
// "user": { fmt.Println(v[1])
// "id": 449815, }
// "email": "gitlabtest_2@gitlab.com", }
// "name": "gitlabu6d4bu8bd5u8d26u53f72",
// "time": "2015-11-06T14:51:55+08:00" crRe:= regexp.MustCompile("\\s+create\\s+mode\\s+\\d+\\s+([^\\s]*)")
// }, crList:=crRe.FindAllStringSubmatch(string(info),-1)
// "repository": { if len(crList)>0{
// "name": "test_gitosc_20151106145021322", for _,cr:=range crList{
// "url": "git@git.oschina.net:gitlab_test_1/test_gitosc_20151106145021322.git",
// "description": "test_gitosc_20151106145021322 testting", fd,_:=os.Open(repoPath+cr[1])
// "homepage": "http://git.oschina.net/gitlab_test_1/test_gitosc_20151106145021322" up.Put("/"+cr[1],fd,false,nil)
// }, fmt.Println(cr[1])
// "commits": [ }
// { }
// "id": "219aa13d45276a5cae7436ecc66053da67ec2a2d",
// "message": "commit_access_test",
// "timestamp": "2015-11-06T14:50:47+08:00", log.Info(string(info))
// "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()
} }
......
...@@ -2063,3 +2063,100 @@ index 3fd94c7..da99ca0 100644 ...@@ -2063,3 +2063,100 @@ index 3fd94c7..da99ca0 100644
2016/07/29 12:35:45 [I] 2016/07/29 12:35:45 [I]
2016/07/29 12:35:46 [I] asdfasdfadfasdfadfadf 2016/07/29 12:35:46 [I] asdfasdfadfasdfadfadf
2016/07/29 12:35:46 [I] 2016/07/29 12:35:46 [I]
2016/07/29 12:46:29 [I]
2016/07/29 12:46:29 [I]
2016/07/29 12:46:30 [I]
2016/07/29 12:46:30 [I]
2016/07/29 12:46:30 [I]
2016/07/29 12:46:30 [I]
2016/07/29 12:46:30 [I]
2016/07/29 12:46:30 [I]
2016/07/29 12:46:30 [I]
2016/07/29 12:46:30 [I]
2016/07/29 12:46:31 [I]
2016/07/29 12:46:31 [I]
2016/07/29 12:46:31 [I]
2016/07/29 12:46:31 [I]
2016/07/29 12:46:41 [I]
2016/07/29 12:46:41 [I]
2016/07/29 12:46:42 [I]
2016/07/29 12:46:42 [I]
2016/07/29 12:46:42 [I]
2016/07/29 12:46:42 [I]
2016/07/29 12:46:42 [I]
2016/07/29 12:46:42 [I]
2016/07/29 12:46:43 [I]
2016/07/29 12:46:43 [I]
2016/07/29 12:46:44 [I]
2016/07/29 12:46:44 [I]
2016/07/29 12:46:47 [I]
2016/07/29 12:46:47 [I]
2016/07/29 13:30:08 [I] Updating a328265..3dcefe7
Fast-forward
m/themes/mobile/views/baidu/index.php | 30 +++++++++++++++---------------
m/themes/mobile/views/baidu/index2.php | 30 +++++++++++++++---------------
www/protected/views/index/index3.php | 4 ++--
3 files changed, 32 insertions(+), 32 deletions(-)
2016/07/29 14:05:28 [I] Already up-to-date.
2016/07/29 14:06:41 [I] Already up-to-date.
2016/07/29 14:15:50 [I] Already up-to-date.
2016/07/29 14:19:38 [I] Updating dc46faa..2be13d4
Fast-forward
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
2016/07/29 14:20:56 [I] Updating 2be13d4..16ec843
Fast-forward
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
2016/07/29 14:24:28 [I] Updating 16ec843..2e0c7fb
Fast-forward
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
2016/07/29 14:26:19 [I] Updating 2e0c7fb..6ace840
Fast-forward
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
2016/07/29 15:15:35 [I] Already up-to-date.
2016/07/29 15:17:49 [I] Updating 6ace840..8c9df74
Fast-forward
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
2016/07/29 15:20:50 [I] Updating 8c9df74..08eb823
Fast-forward
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
2016/07/29 15:20:51 [I] Already up-to-date.
2016/07/29 15:22:19 [I] Updating 08eb823..15f0edb
Fast-forward
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
2016/07/29 15:28:27 [I] Updating 15f0edb..76ac97d
Fast-forward
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
2016/07/29 15:30:06 [I] Updating 76ac97d..c21ebab
Fast-forward
test.haha | 1 +
1 file changed, 1 insertion(+)
create mode 100644 test.haha
2016/07/29 15:31:31 [I] Updating c21ebab..6663109
Fast-forward
test.hahl | 1 +
1 file changed, 1 insertion(+)
create mode 100644 test.hahl
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