validate remote name in pre-push too

This commit is contained in:
risk danger olson 2016-02-03 14:23:27 -07:00
parent dceb6611c7
commit 3f89436fd5
2 changed files with 18 additions and 0 deletions

@ -5,6 +5,7 @@ import (
"os" "os"
"strings" "strings"
"github.com/github/git-lfs/git"
"github.com/github/git-lfs/lfs" "github.com/github/git-lfs/lfs"
"github.com/github/git-lfs/vendor/_nuts/github.com/spf13/cobra" "github.com/github/git-lfs/vendor/_nuts/github.com/spf13/cobra"
) )
@ -48,6 +49,10 @@ func prePushCommand(cmd *cobra.Command, args []string) {
os.Exit(1) os.Exit(1)
} }
// Remote is first arg
if err := git.ValidateRemote(args[0]); err != nil {
Exit("Invalid remote name %q", args[0])
}
lfs.Config.CurrentRemote = args[0] lfs.Config.CurrentRemote = args[0]
// We can be passed multiple lines of refs // We can be passed multiple lines of refs

@ -367,3 +367,16 @@ begin_test "pre-push multiple branches"
) )
end_test end_test
begin_test "pre-push with bad remote"
(
set -e
cd repo
echo "refs/heads/master master refs/heads/master 0000000000000000000000000000000000000000" |
git lfs pre-push not-a-remote "$GITSERVER/$reponame" 2>&1 |
tee pre-push.log
grep "Invalid remote name" pre-push.log
)
end_test