@@ -85,10 +85,10 @@ type Project struct {
85
85
yc ycfg.YCfg
86
86
}
87
87
88
- func initProject (dir string , download bool , okRepos []string ) error {
88
+ func initProject (dir string , download bool , noDeps bool , okRepos []string ) error {
89
89
var err error
90
90
91
- globalProject , err = loadProject (dir , download , okRepos )
91
+ globalProject , err = loadProject (dir , download , noDeps , okRepos )
92
92
if err != nil {
93
93
return err
94
94
}
@@ -99,29 +99,29 @@ func initProject(dir string, download bool, okRepos []string) error {
99
99
return nil
100
100
}
101
101
102
- func initialize (download bool , okRepos []string ) error {
102
+ func initialize (download bool , noDeps bool , okRepos []string ) error {
103
103
if globalProject == nil {
104
104
wd , err := os .Getwd ()
105
105
wd = filepath .ToSlash (wd )
106
106
if err != nil {
107
107
return util .NewNewtError (err .Error ())
108
108
}
109
- if err := initProject (wd , download , okRepos ); err != nil {
109
+ if err := initProject (wd , download , noDeps , okRepos ); err != nil {
110
110
return err
111
111
}
112
112
}
113
113
return nil
114
114
}
115
115
116
116
func TryGetProject () (* Project , error ) {
117
- if err := initialize (false , nil ); err != nil {
117
+ if err := initialize (false , false , nil ); err != nil {
118
118
return nil , err
119
119
}
120
120
return globalProject , nil
121
121
}
122
122
123
- func TryGetOrDownloadProject (okRepos []string ) (* Project , error ) {
124
- if err := initialize (true , okRepos ); err != nil {
123
+ func TryGetOrDownloadProject (noDeps bool , okRepos []string ) (* Project , error ) {
124
+ if err := initialize (true , noDeps , okRepos ); err != nil {
125
125
return nil , err
126
126
}
127
127
return globalProject , nil
@@ -153,10 +153,10 @@ func ResetDeps(newList interfaces.PackageList) interfaces.PackageList {
153
153
return oldList
154
154
}
155
155
156
- func newProject (dir string , download bool , okRepos []string ) (* Project , error ) {
156
+ func newProject (dir string , download bool , noDeps bool , okRepos []string ) (* Project , error ) {
157
157
proj := & Project {}
158
158
159
- if err := proj .Init (dir , download , okRepos ); err != nil {
159
+ if err := proj .Init (dir , download , noDeps , okRepos ); err != nil {
160
160
return nil , err
161
161
}
162
162
@@ -175,14 +175,14 @@ func isOkRepo(repo string, okRepos []string) bool {
175
175
return false
176
176
}
177
177
178
- func (proj * Project ) GetPkgRepos (okRepos []string ) error {
178
+ func (proj * Project ) GetPkgRepos (noDeps bool , okRepos []string ) error {
179
179
180
180
for _ , pkgList := range proj .packages {
181
181
for _ , pkg := range * pkgList {
182
182
if pkg .PkgConfig ().HasKey ("repository" ) {
183
183
for k , _ := range pkg .PkgConfig ().AllSettings () {
184
184
repoName := strings .TrimPrefix (k , "repository." )
185
- if repoName != k && isOkRepo (repoName , okRepos ) {
185
+ if repoName != k && ( ! noDeps || isOkRepo (repoName , okRepos ) ) {
186
186
fields , err := pkg .PkgConfig ().GetValStringMapString (k , nil )
187
187
util .OneTimeWarningError (err )
188
188
@@ -318,7 +318,7 @@ func (proj *Project) UpgradeIf(
318
318
predicate func (r * repo.Repo ) bool ) error {
319
319
320
320
// Make sure we have an up to date copy of all `repository.yml` files.
321
- if err := proj .downloadRepositoryYmlFiles (okRepos ); err != nil {
321
+ if err := proj .downloadRepositoryYmlFiles (noDeps , okRepos ); err != nil {
322
322
return err
323
323
}
324
324
@@ -341,7 +341,7 @@ func (proj *Project) InfoIf(predicate func(r *repo.Repo) bool,
341
341
342
342
if remote {
343
343
// Make sure we have an up to date copy of all `repository.yml` files.
344
- if err := proj .downloadRepositoryYmlFiles (nil ); err != nil {
344
+ if err := proj .downloadRepositoryYmlFiles (false , nil ); err != nil {
345
345
return err
346
346
}
347
347
}
@@ -438,7 +438,7 @@ func (proj *Project) checkNewtVer() error {
438
438
}
439
439
440
440
// Loads the `repository.yml` file for each depended-on repo. This
441
- func (proj * Project ) loadRepoDeps (download bool , okRepos []string ) error {
441
+ func (proj * Project ) loadRepoDeps (download bool , noDeps bool , okRepos []string ) error {
442
442
seen := map [string ]struct {}{}
443
443
444
444
loadDeps := func (r * repo.Repo ) ([]* repo.Repo , error ) {
@@ -447,7 +447,7 @@ func (proj *Project) loadRepoDeps(download bool, okRepos []string) error {
447
447
depMap := r .CommitDepMap ()
448
448
for _ , depSlice := range depMap {
449
449
for _ , dep := range depSlice {
450
- if ! isOkRepo (dep .Name , okRepos ) {
450
+ if ! isOkRepo (dep .Name , okRepos ) && noDeps {
451
451
log .Debugf ("Skipping repo %s" , dep .Name )
452
452
continue
453
453
}
@@ -503,7 +503,8 @@ func (proj *Project) loadRepoDeps(download bool, okRepos []string) error {
503
503
return nil
504
504
}
505
505
506
- func (proj * Project ) downloadRepositoryYmlFiles (okRepos []string ) error {
506
+ func (proj * Project ) downloadRepositoryYmlFiles (noDeps bool ,
507
+ okRepos []string ) error {
507
508
// Download the `repository.yml` file for each root-level repo (those
508
509
// specified in the `project.yml` file).
509
510
for _ , r := range proj .repos .Sorted () {
@@ -518,7 +519,7 @@ func (proj *Project) downloadRepositoryYmlFiles(okRepos []string) error {
518
519
}
519
520
520
521
// Download the `repository.yml` file for each depended-on repo.
521
- if err := proj .loadRepoDeps (true , okRepos ); err != nil {
522
+ if err := proj .loadRepoDeps (true , noDeps , okRepos ); err != nil {
522
523
return err
523
524
}
524
525
@@ -584,7 +585,7 @@ func (proj *Project) addRepo(r *repo.Repo, download bool, isDep bool) error {
584
585
return nil
585
586
}
586
587
587
- func (proj * Project ) loadConfig (download bool , okRepos []string ) error {
588
+ func (proj * Project ) loadConfig (download bool , noDeps bool , okRepos []string ) error {
588
589
yc , err := config .ReadFile (proj .BasePath + "/" + PROJECT_FILE_NAME )
589
590
if err != nil {
590
591
return util .NewNewtError (err .Error ())
@@ -643,7 +644,7 @@ func (proj *Project) loadConfig(download bool, okRepos []string) error {
643
644
// Read `repository.yml` files belonging to dependee repos from disk.
644
645
// These repos might not be specified in the `project.yml` file, but they
645
646
// are still part of the project.
646
- if err := proj .loadRepoDeps (download , okRepos ); err != nil {
647
+ if err := proj .loadRepoDeps (download , noDeps , okRepos ); err != nil {
647
648
return err
648
649
}
649
650
@@ -680,7 +681,7 @@ func (proj *Project) loadConfig(download bool, okRepos []string) error {
680
681
return nil
681
682
}
682
683
683
- func (proj * Project ) Init (dir string , download bool , okRepos []string ) error {
684
+ func (proj * Project ) Init (dir string , download bool , noDeps bool , okRepos []string ) error {
684
685
proj .BasePath = filepath .ToSlash (filepath .Clean (dir ))
685
686
686
687
// Only one project per system, when created, set it as the global project
@@ -690,7 +691,7 @@ func (proj *Project) Init(dir string, download bool, okRepos []string) error {
690
691
proj .rootRepoReqs = map [string ]newtutil.RepoVersion {}
691
692
692
693
// Load Project configuration
693
- if err := proj .loadConfig (download , okRepos ); err != nil {
694
+ if err := proj .loadConfig (download , noDeps , okRepos ); err != nil {
694
695
return err
695
696
}
696
697
@@ -831,13 +832,13 @@ func (proj *Project) PackagesOfType(pkgType interfaces.PackageType) []interfaces
831
832
return matches
832
833
}
833
834
834
- func loadProject (dir string , download bool , okRepos []string ) (* Project , error ) {
835
+ func loadProject (dir string , download bool , noDeps bool , okRepos []string ) (* Project , error ) {
835
836
projDir , err := findProjectDir (dir )
836
837
if err != nil {
837
838
return nil , err
838
839
}
839
840
840
- proj , err := newProject (projDir , download , okRepos )
841
+ proj , err := newProject (projDir , download , noDeps , okRepos )
841
842
842
843
return proj , err
843
844
}
0 commit comments