Skip to content
This repository was archived by the owner on Jan 16, 2025. It is now read-only.

Commit 44c6a88

Browse files
authored
Merge pull request #24 from alibaba/jx/sync-published-ref
sync: check published ref if has --check-published option
2 parents 5de308e + 434bf94 commit 44c6a88

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

cmd/sync.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ type syncCommand struct {
4747
NetworkOnly bool
4848
DetachHead bool
4949
CurrentBranchOnly bool
50+
CheckPublished bool
5051
Jobs int
5152
ManifestName string
5253
NoCache bool
@@ -105,6 +106,10 @@ func (v *syncCommand) Command() *cobra.Command {
105106
"c",
106107
false,
107108
"fetch only current branch from server")
109+
v.cmd.Flags().BoolVar(&v.O.CheckPublished,
110+
"check-published",
111+
false,
112+
"do not sync project which is published but not merged")
108113
v.cmd.Flags().IntVarP(&v.O.Jobs,
109114
"jobs",
110115
"j",

project/local-half.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ import (
2323
type CheckoutOptions struct {
2424
RepoSettings
2525

26-
Quiet bool
27-
DetachHead bool
28-
IsManifest bool
26+
Quiet bool
27+
DetachHead bool
28+
IsManifest bool
29+
CheckPublished bool
2930
}
3031

3132
// IsClean indicates git worktree is clean.
@@ -300,7 +301,7 @@ func (v Project) SyncLocalHalf(o *CheckoutOptions) error {
300301
}
301302

302303
// Manifest project do not need to check publish ref.
303-
if !o.IsManifest {
304+
if !o.IsManifest && o.CheckPublished {
304305
pubid := v.PublishedRevision(branch)
305306
// Local branched is published.
306307
if pubid != "" {

0 commit comments

Comments
 (0)