commands_{lock,locks,unlock}: allow custom --remote specification
This commit is contained in:
parent
b5605e071b
commit
fad308366f
@ -2,11 +2,22 @@ package commands
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/github/git-lfs/api"
|
"github.com/github/git-lfs/api"
|
||||||
|
"github.com/github/git-lfs/config"
|
||||||
"github.com/github/git-lfs/git"
|
"github.com/github/git-lfs/git"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
lockRemote string
|
||||||
|
lockRemoteHelp = "specify which remote to use when interacting with locks"
|
||||||
|
|
||||||
|
// TODO(taylor): consider making this (and the above flag) a property of
|
||||||
|
// some parent-command, or another similarly less ugly way of handling
|
||||||
|
// this
|
||||||
|
setLockRemoteFor = func(c *config.Configuration) {
|
||||||
|
c.CurrentRemote = lockRemote
|
||||||
|
}
|
||||||
|
|
||||||
lockCmd = &cobra.Command{
|
lockCmd = &cobra.Command{
|
||||||
Use: "lock",
|
Use: "lock",
|
||||||
Run: lockCommand,
|
Run: lockCommand,
|
||||||
@ -14,6 +25,8 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func lockCommand(cmd *cobra.Command, args []string) {
|
func lockCommand(cmd *cobra.Command, args []string) {
|
||||||
|
setLockRemoteFor(config.Config)
|
||||||
|
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
Print("Usage: git lfs lock <path>")
|
Print("Usage: git lfs lock <path>")
|
||||||
return
|
return
|
||||||
@ -45,5 +58,7 @@ func lockCommand(cmd *cobra.Command, args []string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
lockCmd.Flags().StringVarP(&lockRemote, "remote", "r", config.Config.CurrentRemote, lockRemoteHelp)
|
||||||
|
|
||||||
RootCmd.AddCommand(lockCmd)
|
RootCmd.AddCommand(lockCmd)
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package commands
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/github/git-lfs/api"
|
"github.com/github/git-lfs/api"
|
||||||
|
"github.com/github/git-lfs/config"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -14,6 +15,8 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func locksCommand(cmd *cobra.Command, args []string) {
|
func locksCommand(cmd *cobra.Command, args []string) {
|
||||||
|
setLockRemoteFor(config.Config)
|
||||||
|
|
||||||
s, resp := API.Locks.Search(&api.LockSearchRequest{
|
s, resp := API.Locks.Search(&api.LockSearchRequest{
|
||||||
Filters: locksCmdFlags.Filters(),
|
Filters: locksCmdFlags.Filters(),
|
||||||
Cursor: locksCmdFlags.Cursor,
|
Cursor: locksCmdFlags.Cursor,
|
||||||
@ -32,6 +35,8 @@ func locksCommand(cmd *cobra.Command, args []string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
locksCmd.Flags().StringVarP(&lockRemote, "remote", "r", config.Config.CurrentRemote, lockRemoteHelp)
|
||||||
|
|
||||||
locksCmd.Flags().StringVarP(&locksCmdFlags.Path, "path", "p", "", "filter locks results matching a particular path")
|
locksCmd.Flags().StringVarP(&locksCmdFlags.Path, "path", "p", "", "filter locks results matching a particular path")
|
||||||
locksCmd.Flags().StringVarP(&locksCmdFlags.Id, "id", "i", "", "filter locks results matching a particular ID")
|
locksCmd.Flags().StringVarP(&locksCmdFlags.Id, "id", "i", "", "filter locks results matching a particular ID")
|
||||||
locksCmd.Flags().StringVarP(&locksCmdFlags.Cursor, "cursor", "c", "", "cursor for last seen lock result")
|
locksCmd.Flags().StringVarP(&locksCmdFlags.Cursor, "cursor", "c", "", "cursor for last seen lock result")
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"github.com/github/git-lfs/api"
|
"github.com/github/git-lfs/api"
|
||||||
|
"github.com/github/git-lfs/config"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -25,6 +26,8 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func unlockCommand(cmd *cobra.Command, args []string) {
|
func unlockCommand(cmd *cobra.Command, args []string) {
|
||||||
|
setLockRemoteFor(config.Config)
|
||||||
|
|
||||||
var id string
|
var id string
|
||||||
if len(args) != 0 {
|
if len(args) != 0 {
|
||||||
if matchedId, err := lockIdFromPath(args[0]); err != nil {
|
if matchedId, err := lockIdFromPath(args[0]); err != nil {
|
||||||
@ -84,6 +87,8 @@ func lockIdFromPath(path string) (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
unlockCmd.Flags().StringVarP(&lockRemote, "remote", "r", config.Config.CurrentRemote, lockRemoteHelp)
|
||||||
|
|
||||||
unlockCmd.Flags().StringVarP(&unlockId, "id", "i", "", "unlock a lock by its ID")
|
unlockCmd.Flags().StringVarP(&unlockId, "id", "i", "", "unlock a lock by its ID")
|
||||||
|
|
||||||
RootCmd.AddCommand(unlockCmd)
|
RootCmd.AddCommand(unlockCmd)
|
||||||
|
Loading…
Reference in New Issue
Block a user