github.com/btwiuse/jiri@v0.0.0-20191125065820-53353bcfef54/cmd/jiri/source_manifest.go (about)

     1  // Copyright 2017 The Fuchsia Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package main
     6  
     7  import (
     8  	"github.com/btwiuse/jiri"
     9  	"github.com/btwiuse/jiri/cmdline"
    10  	"github.com/btwiuse/jiri/project"
    11  )
    12  
    13  var cmdSourceManifest = &cmdline.Command{
    14  	Runner: jiri.RunnerFunc(runSourceManifest),
    15  	Name:   "source-manifest",
    16  	Short:  "Create a new source-manifest from current checkout",
    17  	Long: `
    18  This command captures the current project state in a source-manifest format.
    19  See https://github.com/luci/recipes-py/blob/master/recipe_engine/source_manifest.proto
    20  for its format.
    21  `,
    22  	ArgsName: "<source-manifest>",
    23  	ArgsLong: "<source-manifest> is the source-manifest file.",
    24  }
    25  
    26  func runSourceManifest(jirix *jiri.X, args []string) error {
    27  	jirix.TimerPush("create source manifest")
    28  	defer jirix.TimerPop()
    29  
    30  	if len(args) != 1 {
    31  		return jirix.UsageErrorf("unexpected number of arguments")
    32  	}
    33  
    34  	localProjects, err := project.LocalProjects(jirix, project.FullScan)
    35  	if err != nil {
    36  		return err
    37  	}
    38  
    39  	sm, mErr := project.NewSourceManifest(jirix, localProjects)
    40  	if mErr != nil {
    41  		return mErr
    42  	}
    43  	return sm.ToFile(jirix, args[0])
    44  }