guard against invalid remotes passed to git lfs push

This commit is contained in:
risk danger olson 2016-02-03 13:06:05 -07:00
parent 064043040e
commit dceb6611c7
3 changed files with 23 additions and 0 deletions

@ -4,6 +4,7 @@ import (
"io/ioutil"
"os"
"github.com/github/git-lfs/git"
"github.com/github/git-lfs/lfs"
"github.com/github/git-lfs/vendor/_nuts/github.com/rubyist/tracerx"
"github.com/github/git-lfs/vendor/_nuts/github.com/spf13/cobra"
@ -159,6 +160,10 @@ func pushCommand(cmd *cobra.Command, args []string) {
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]
if useStdin {

@ -538,3 +538,12 @@ begin_test "fetch --prune"
refute_local_object "$oid_commit2"
)
end_test
begin_test "fetch with invalid remote"
(
set -e
cd repo
git lfs fetch not-a-remote 2>&1 | tee fetch.log
grep "Invalid remote name" fetch.log
)
end_test

@ -410,3 +410,12 @@ begin_test "push modified files"
assert_server_object "$reponame" "$oid5"
)
end_test
begin_test "push with invalid remote"
(
set -e
cd repo
git lfs push not-a-remote 2>&1 | tee push.log
grep "Invalid remote name" push.log
)
end_test