2014-09-22 21:26:43 +00:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
2015-03-19 19:30:55 +00:00
|
|
|
"github.com/github/git-lfs/git"
|
|
|
|
"github.com/github/git-lfs/scanner"
|
2014-09-22 21:26:43 +00:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
lsFilesCmd = &cobra.Command{
|
|
|
|
Use: "ls-files",
|
2015-03-19 19:30:55 +00:00
|
|
|
Short: "Show information about Git LFS files",
|
2014-09-22 21:26:43 +00:00
|
|
|
Run: lsFilesCommand,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
func lsFilesCommand(cmd *cobra.Command, args []string) {
|
2014-10-11 14:28:46 +00:00
|
|
|
var ref string
|
|
|
|
var err error
|
2014-09-22 21:26:43 +00:00
|
|
|
|
2014-10-03 16:17:26 +00:00
|
|
|
if len(args) == 1 {
|
|
|
|
ref = args[0]
|
2014-10-11 14:28:46 +00:00
|
|
|
} else {
|
2014-10-28 19:22:38 +00:00
|
|
|
ref, err = git.CurrentRef()
|
2014-10-11 14:28:46 +00:00
|
|
|
if err != nil {
|
|
|
|
Panic(err, "Could not ls-files")
|
|
|
|
}
|
2014-10-03 16:17:26 +00:00
|
|
|
}
|
2014-09-22 21:26:43 +00:00
|
|
|
|
2014-10-20 18:49:15 +00:00
|
|
|
pointers, err := scanner.Scan(ref, "")
|
2014-10-03 16:17:26 +00:00
|
|
|
if err != nil {
|
2015-03-19 19:30:55 +00:00
|
|
|
Panic(err, "Could not scan for Git LFS files")
|
2014-10-03 16:17:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for _, p := range pointers {
|
2014-10-08 13:04:07 +00:00
|
|
|
Print(p.Name)
|
2014-10-03 16:17:26 +00:00
|
|
|
}
|
2014-09-22 21:26:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
RootCmd.AddCommand(lsFilesCmd)
|
|
|
|
}
|