github.com/LGUG2Z/story@v0.4.1/cli/reset.go (about)

     1  package cli
     2  
     3  import (
     4  	"github.com/LGUG2Z/story/git"
     5  	"github.com/LGUG2Z/story/manifest"
     6  	"github.com/spf13/afero"
     7  	"github.com/urfave/cli"
     8  )
     9  
    10  func ResetCmd(fs afero.Fs) cli.Command {
    11  	return cli.Command{
    12  		Name:  "reset",
    13  		Usage: "Resets all story branches to trunk branches",
    14  		Action: func(c *cli.Context) error {
    15  			if !isStory {
    16  				return ErrNotWorkingOnAStory
    17  			}
    18  
    19  			if c.Args().Present() {
    20  				return ErrCommandTakesNoArguments
    21  			}
    22  
    23  			story, err := manifest.LoadStory(fs)
    24  			if err != nil {
    25  				return err
    26  			}
    27  
    28  			for project := range story.Projects {
    29  				output, err := git.CheckoutBranch(git.CheckoutBranchOpts{Branch: trunk, Project: project})
    30  				if err != nil {
    31  					return err
    32  				}
    33  
    34  				printGitOutput(output, project)
    35  			}
    36  
    37  			output, err := git.CheckoutBranch(git.CheckoutBranchOpts{Branch: trunk})
    38  			if err != nil {
    39  				return err
    40  			}
    41  
    42  			printGitOutput(output, metarepo)
    43  			return nil
    44  		},
    45  	}
    46  }