Skip to content

Commit

Permalink
feat: allow interpolation of original_host in Transfer.get
Browse files Browse the repository at this point in the history
Found this useful when using connection `Group`s with remotes
configured in an SSH-config file.
  • Loading branch information
cunha committed Mar 17, 2023
1 parent 5fb2775 commit 0134917
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions fabric/transfer.py
Expand Up @@ -138,6 +138,7 @@ def get(self, remote, local=None, preserve_mode=True):
host=self.connection.host,
user=self.connection.user,
port=self.connection.port,
original_host=getattr(self.connection, "original_host", self.connection.host),
dirname=posixpath.dirname(remote),
basename=remote_filename,
)
Expand Down
4 changes: 2 additions & 2 deletions tests/transfer.py
Expand Up @@ -91,8 +91,8 @@ def remote_arg_cannot_be_empty_string(self, transfer):

class local_arg_interpolation:
def connection_params(self, transfer):
result = transfer.get("somefile", "{user}@{host}-{port}")
expected = "/local/{}@host-22".format(transfer.connection.user)
result = transfer.get("somefile", "{user}@{host}-{original_host}-{port}")
expected = "/local/{}@host-host-22".format(transfer.connection.user)
assert result.local == expected

def connection_params_as_dir(self, transfer):
Expand Down

0 comments on commit 0134917

Please sign in to comment.