Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
5aba5f00
Commit
5aba5f00
authored
Jan 29, 2015
by
Johan Euphrosine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
contrib/git-sync: add wait
parent
0415b63a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
6 deletions
+24
-6
main.go
contrib/git-sync/main.go
+24
-6
No files found.
contrib/git-sync/main.go
View file @
5aba5f00
...
@@ -25,22 +25,37 @@ import (
...
@@ -25,22 +25,37 @@ import (
"os"
"os"
"os/exec"
"os/exec"
"path"
"path"
"strconv"
"strings"
"strings"
"time"
)
)
var
flRepo
=
flag
.
String
(
"repo"
,
env
(
"GIT_SYNC_REPO"
,
""
),
"git repo url"
)
var
flRepo
=
flag
.
String
(
"repo"
,
envString
(
"GIT_SYNC_REPO"
,
""
),
"git repo url"
)
var
flBranch
=
flag
.
String
(
"branch"
,
env
(
"GIT_SYNC_BRANCH"
,
"master"
),
"git branch"
)
var
flBranch
=
flag
.
String
(
"branch"
,
envString
(
"GIT_SYNC_BRANCH"
,
"master"
),
"git branch"
)
var
flRev
=
flag
.
String
(
"rev"
,
env
(
"GIT_SYNC_BRANCH"
,
"HEAD"
),
"git rev"
)
var
flRev
=
flag
.
String
(
"rev"
,
envString
(
"GIT_SYNC_BRANCH"
,
"HEAD"
),
"git rev"
)
var
flDest
=
flag
.
String
(
"dest"
,
env
(
"GIT_SYNC_DEST"
,
""
),
"destination path"
)
var
flDest
=
flag
.
String
(
"dest"
,
envString
(
"GIT_SYNC_DEST"
,
""
),
"destination path"
)
var
flWait
=
flag
.
Int
(
"wait"
,
envInt
(
"GIT_SYNC_WAIT"
,
0
),
"number of seconds to wait before exit"
)
func
env
(
key
,
def
string
)
string
{
func
env
String
(
key
,
def
string
)
string
{
if
env
:=
os
.
Getenv
(
key
);
env
!=
""
{
if
env
:=
os
.
Getenv
(
key
);
env
!=
""
{
return
env
return
env
}
}
return
def
return
def
}
}
const
usage
=
"usage: GIT_SYNC_REPO= GIT_SYNC_DEST= [GIT_SYNC_BRANCH=] git-sync -repo GIT_REPO_URL -dest PATH [-branch]"
func
envInt
(
key
string
,
def
int
)
int
{
if
env
:=
os
.
Getenv
(
key
);
env
!=
""
{
val
,
err
:=
strconv
.
Atoi
(
env
)
if
err
!=
nil
{
log
.
Println
(
"invalid value for %q: using default: %q"
,
key
,
def
)
return
def
}
return
val
}
return
def
}
const
usage
=
"usage: GIT_SYNC_REPO= GIT_SYNC_DEST= [GIT_SYNC_BRANCH= GIT_SYNC_WAIT=] git-sync -repo GIT_REPO_URL -dest PATH [-branch -wait]"
func
main
()
{
func
main
()
{
flag
.
Parse
()
flag
.
Parse
()
...
@@ -54,6 +69,9 @@ func main() {
...
@@ -54,6 +69,9 @@ func main() {
if
err
:=
syncRepo
(
*
flRepo
,
*
flDest
,
*
flBranch
,
*
flRev
);
err
!=
nil
{
if
err
:=
syncRepo
(
*
flRepo
,
*
flDest
,
*
flBranch
,
*
flRev
);
err
!=
nil
{
log
.
Fatalf
(
"error syncing repo: %v"
,
err
)
log
.
Fatalf
(
"error syncing repo: %v"
,
err
)
}
}
log
.
Printf
(
"wait %d seconds"
,
*
flWait
)
time
.
Sleep
(
time
.
Duration
(
*
flWait
)
*
time
.
Second
)
log
.
Println
(
"done"
)
}
}
// syncRepo syncs the branch of a given repository to the destination at the given rev.
// syncRepo syncs the branch of a given repository to the destination at the given rev.
...
...
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