2014-10-21 14:21:47 +00:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/github/git-media/gitmedia"
|
|
|
|
"github.com/github/git-media/scanner"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
statusCmd = &cobra.Command{
|
|
|
|
Use: "status",
|
|
|
|
Short: "Show information about git media files that would be pushed",
|
|
|
|
Run: statusCommand,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
func statusCommand(cmd *cobra.Command, args []string) {
|
|
|
|
ref, err := gitmedia.CurrentRef()
|
|
|
|
if err != nil {
|
2014-10-21 14:24:02 +00:00
|
|
|
Panic(err, "Could not calculate status")
|
2014-10-21 14:21:47 +00:00
|
|
|
}
|
|
|
|
|
2014-10-27 15:12:14 +00:00
|
|
|
remoteRef, err := gitmedia.CurrentRemoteRef()
|
|
|
|
if err != nil {
|
|
|
|
Panic(err, "Could not calculate status")
|
|
|
|
}
|
|
|
|
|
|
|
|
pointers, err := scanner.Scan(ref, "^"+remoteRef)
|
2014-10-21 14:21:47 +00:00
|
|
|
if err != nil {
|
|
|
|
Panic(err, "Could not scan for git media files")
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, p := range pointers {
|
2014-10-23 18:42:39 +00:00
|
|
|
Print("%s %d", p.Name, p.Size)
|
2014-10-21 14:21:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
RootCmd.AddCommand(statusCmd)
|
|
|
|
}
|