Add support for skipping local project state checking.

Enables 'fetch-packages' to work without a previous 'jiri update'
and in the presence of project folders it does not own.

Bug: [google internal] b/188809674

Testing:
- Unit testing
- Manual testing of update-packages

Change-Id: I0e0637a476a658f4592fa5edeaffc7c88673f9aa
Reviewed-on: https://fuchsia-review.googlesource.com/c/jiri/+/534603
Reviewed-by: Nathan Mulcahey <nmulcahey@google.com>
Commit-Queue: Ian Kasprzak <iankaz@google.com>
diff --git a/cmd/jiri/fetch_pkgs.go b/cmd/jiri/fetch_pkgs.go
index 7bd83a2..e9e0af9 100644
--- a/cmd/jiri/fetch_pkgs.go
+++ b/cmd/jiri/fetch_pkgs.go
@@ -11,9 +11,10 @@
 )
 
 var fetchPkgsFlags struct {
-	localManifest    bool
-	fetchPkgsTimeout uint
-	attempts         uint
+	localManifest     bool
+	fetchPkgsTimeout  uint
+	attempts          uint
+	skipLocalProjects bool
 }
 
 var cmdFetchPkgs = &cmdline.Command{
@@ -30,12 +31,16 @@
 	cmdFetchPkgs.Flags.BoolVar(&fetchPkgsFlags.localManifest, "local-manifest", false, "Use local checked out manifest.")
 	cmdFetchPkgs.Flags.UintVar(&fetchPkgsFlags.fetchPkgsTimeout, "fetch-packages-timeout", project.DefaultPackageTimeout, "Timeout in minutes for fetching prebuilt packages using cipd.")
 	cmdFetchPkgs.Flags.UintVar(&fetchPkgsFlags.attempts, "attempts", 1, "Number of attempts before failing.")
+	cmdFetchPkgs.Flags.BoolVar(&fetchPkgsFlags.skipLocalProjects, "skip-local-projects", false, "Skip checking local project state.")
 }
 
 func runFetchPkgs(jirix *jiri.X, args []string) (err error) {
-	localProjects, err := project.LocalProjects(jirix, project.FastScan)
-	if err != nil {
-		return err
+	localProjects := project.Projects{}
+	if !fetchPkgsFlags.skipLocalProjects {
+		localProjects, err = project.LocalProjects(jirix, project.FastScan)
+		if err != nil {
+			return err
+		}
 	}
 	if fetchPkgsFlags.attempts < 1 {
 		return jirix.UsageErrorf("Number of attempts should be >= 1")