Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
util
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
刘旋尧
util
Commits
f208cd14
Commit
f208cd14
authored
Oct 20, 2016
by
刘旋尧
Browse files
Options
Browse Files
Download
Plain Diff
as
parents
b8e4d06c
37f4a12e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
55 additions
and
64 deletions
+55
-64
repo.go
git-module/repo.go
+3
-3
app.conf
service/conf/app.conf
+5
-0
git.go
service/controllers/git.go
+46
-60
test.log
service/test.log
+0
-0
conf.go
tel/conf.go
+1
-1
No files found.
git-module/repo.go
View file @
f208cd14
...
@@ -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.
...
...
service/conf/app.conf
View file @
f208cd14
...
@@ -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
=
staticydl
uppassword
=
ydl12345com
upbucket
=
staticydl
service/controllers/git.go
View file @
f208cd14
...
@@ -2,10 +2,12 @@ package controllers
...
@@ -2,10 +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"
"io/ioutil"
"fmt"
"github.com/upyun/go-sdk/upyun"
"os"
)
)
type
GitController
struct
{
type
GitController
struct
{
...
@@ -31,63 +33,47 @@ type PData struct{
...
@@ -31,63 +33,47 @@ type PData struct{
* @return {[type]} [description]
* @return {[type]} [description]
*/
*/
func
(
c
*
GitController
)
Hook
()
{
func
(
c
*
GitController
)
Hook
()
{
resp
:=&
HookInfo
{}
repoPath
:=
"/var/www/static.yidianling.com/"
//ffjson.Unmarshal(c.Ctx.Input.RequestBody,resp)
options
:=
git
.
PullRemoteOptions
{
false
,
0
}
pc
,
_
:=
ioutil
.
ReadAll
(
c
.
Ctx
.
Request
.
Body
)
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
,
err
:=
os
.
Open
(
repoPath
+
v
[
1
])
// "after": "219aa13d45276a5cae7436ecc66053da67ec2a2d",
if
err
!=
nil
{
// "ref": "refs/heads/master",
continue
// "user_id": 449815,
}
// "user_name": "gitlabu6d4bu8bd5u8d26u53f72",
_
,
err
=
up
.
Put
(
"/"
+
v
[
1
],
fd
,
false
,
nil
)
// "user": {
if
err
!=
nil
{
// "id": 449815,
fmt
.
Println
(
err
)
// "email": "gitlabtest_2@gitlab.com",
}
// "name": "gitlabu6d4bu8bd5u8d26u53f72",
fmt
.
Println
(
v
[
1
])
// "time": "2015-11-06T14:51:55+08:00"
fd
.
Close
()
// },
}
// "repository": {
}
// "name": "test_gitosc_20151106145021322",
// "url": "git@git.oschina.net:gitlab_test_1/test_gitosc_20151106145021322.git",
crRe
:=
regexp
.
MustCompile
(
"
\\
s+create
\\
s+mode
\\
s+
\\
d+
\\
s+([^
\\
s]*)"
)
// "description": "test_gitosc_20151106145021322 testting",
crList
:=
crRe
.
FindAllStringSubmatch
(
string
(
info
),
-
1
)
// "homepage": "http://git.oschina.net/gitlab_test_1/test_gitosc_20151106145021322"
if
len
(
crList
)
>
0
{
// },
for
_
,
cr
:=
range
crList
{
// "commits": [
// {
fd
,
err
:=
os
.
Open
(
repoPath
+
cr
[
1
])
// "id": "219aa13d45276a5cae7436ecc66053da67ec2a2d",
if
err
!=
nil
{
// "message": "commit_access_test",
continue
// "timestamp": "2015-11-06T14:50:47+08:00",
}
// "url": "http://git.oschina.net/gitlab_test_1/test_gitosc_20151106145021322/commit/219aa13d45276a5cae7436ecc66053da67ec2a2d",
up
.
Put
(
"/"
+
cr
[
1
],
fd
,
false
,
nil
)
// "author": {
fmt
.
Println
(
cr
[
1
])
// "name": "gitlab_test_2",
fd
.
Close
()
// "email": "gitlabtest_2@gitlab.com",
}
// "time": "2015-11-06T14:50:47+08:00"
}
// }
// }
// ],
log
.
Info
(
string
(
info
))
// "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
()
}
}
...
...
service/test.log
View file @
f208cd14
This source diff could not be displayed because it is too large. You can
view the blob
instead.
tel/conf.go
View file @
f208cd14
...
@@ -2,7 +2,7 @@ package tel
...
@@ -2,7 +2,7 @@ package tel
var
AppKey
=
"34429289df7c45ac90cbd91debcfa5c1"
var
AppKey
=
"34429289df7c45ac90cbd91debcfa5c1"
var
AppSecret
=
"7b90b109fc059f03"
var
AppSecret
=
"7b90b109fc059f03"
var
DispayNumber
=
"+865715615062
5
"
var
DispayNumber
=
"+865715615062
6
"
var
CallbackUrl
=
"aHR0cDovL2gueWlkaWFubGluZy5jb20vbGlzdGVuL2NiLWNt"
var
CallbackUrl
=
"aHR0cDovL2gueWlkaWFubGluZy5jb20vbGlzdGVuL2NiLWNt"
var
CerPath
=
"/var/www/yidianling/common/components/yunxun/iSimularClient.pem"
var
CerPath
=
"/var/www/yidianling/common/components/yunxun/iSimularClient.pem"
var
DialUrl
=
"https://aep.sdp.com:1101/tropo/click2CallEx/v1"
var
DialUrl
=
"https://aep.sdp.com:1101/tropo/click2CallEx/v1"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment