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