commands/command_push.go: set pushRemote
When performing `git lfs push`, use the provided arguments to set the `pushRemote` instead of the `remote`.
This commit is contained in:
parent
d263a97f38
commit
c6ee6a131f
@ -38,7 +38,7 @@ func pushCommand(cmd *cobra.Command, args []string) {
|
||||
requireGitVersion()
|
||||
|
||||
// Remote is first arg
|
||||
if err := cfg.SetValidRemote(args[0]); err != nil {
|
||||
if err := cfg.SetValidPushRemote(args[0]); err != nil {
|
||||
Exit("Invalid remote name %q: %s", args[0], err)
|
||||
}
|
||||
|
||||
|
@ -232,10 +232,22 @@ func (c *Configuration) SetValidRemote(name string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Configuration) SetValidPushRemote(name string) error {
|
||||
if err := git.ValidateRemote(name); err != nil {
|
||||
return err
|
||||
}
|
||||
c.SetPushRemote(name)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Configuration) SetRemote(name string) {
|
||||
c.currentRemote = &name
|
||||
}
|
||||
|
||||
func (c *Configuration) SetPushRemote(name string) {
|
||||
c.pushRemote = &name
|
||||
}
|
||||
|
||||
func (c *Configuration) Remotes() []string {
|
||||
c.loadGitConfig()
|
||||
return c.remotes
|
||||
|
@ -61,6 +61,27 @@ begin_test "push with bad ref"
|
||||
)
|
||||
end_test
|
||||
|
||||
begin_test "push with given remote, configured pushRemote"
|
||||
(
|
||||
set -e
|
||||
reponame="push-given-and-config"
|
||||
setup_remote_repo "$reponame"
|
||||
clone_repo "$reponame" "$reponame"
|
||||
|
||||
git config "lfs.$(repo_endpoint "$GITSERVER" "$reponame").locksverify" false
|
||||
git lfs track "*.dat"
|
||||
echo "push a" > a.dat
|
||||
git add .gitattributes a.dat
|
||||
git commit -m "add a.dat"
|
||||
|
||||
git remote add bad-remote "invalid-url"
|
||||
|
||||
git config branch.master.pushRemote bad-remote
|
||||
|
||||
git lfs push --all origin
|
||||
)
|
||||
end_test
|
||||
|
||||
begin_test "push"
|
||||
(
|
||||
set -e
|
||||
|
Loading…
Reference in New Issue
Block a user