Skip to content

Commit

Permalink
Add get-branch command for debugging purposes
Browse files Browse the repository at this point in the history
  • Loading branch information
plorenz committed Nov 16, 2020
1 parent 0ad6c54 commit d1cf1ad
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
48 changes: 48 additions & 0 deletions cmd/get_branch_cmd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright NetFoundry, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package cmd

import (
"fmt"
"github.com/spf13/cobra"
)

type getBranchCmd struct {
BaseCommand
}

func (cmd *getBranchCmd) Execute() {
fmt.Print(cmd.GetCurrentBranch())
}

func newGetBranchCmd(root *RootCommand) *cobra.Command {
cobraCmd := &cobra.Command{
Use: "get-branch",
Short: "Print out the git branch being built",
Args: cobra.ExactArgs(0),
}

result := &getBranchCmd{
BaseCommand: BaseCommand{
RootCommand: root,
Cmd: cobraCmd,
},
}

return Finalize(result)
}
1 change: 1 addition & 0 deletions cmd/root_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ func newRootCommand() *RootCommand {
rootCobraCmd.AddCommand(newPublishToArtifactoryCmd(rootCmd))
rootCobraCmd.AddCommand(publish.NewPublishCmd())
rootCobraCmd.AddCommand(newGetVersionCmd(rootCmd))
rootCobraCmd.AddCommand(newGetBranchCmd(rootCmd))

var versionCmd = &cobra.Command{
Use: "version",
Expand Down

0 comments on commit d1cf1ad

Please sign in to comment.