Explorar o código

Let ssh figure out port/user if not specified so we don't override .ssh/config

Modified by Jonas Borgström:
- Added CHANGES entry
- Fixed broken unit test
Brian Johnson %!s(int64=11) %!d(string=hai) anos
pai
achega
29d184dfcb
Modificáronse 4 ficheiros con 17 adicións e 5 borrados
  1. 7 0
      CHANGES
  2. 1 3
      attic/helpers.py
  3. 8 1
      attic/remote.py
  4. 1 1
      attic/testsuite/helpers.py

+ 7 - 0
CHANGES

@@ -3,6 +3,13 @@ Attic Changelog
 
 
 Here you can see the full list of changes between each Attic release.
 Here you can see the full list of changes between each Attic release.
 
 
+Version 0.9
+-----------
+
+(feature release, released on X)
+
+- Let ssh figure out port/user if not specified so we don't override .ssh/config (#9)
+
 Version 0.8.1
 Version 0.8.1
 -------------
 -------------
 
 

+ 1 - 3
attic/helpers.py

@@ -285,7 +285,7 @@ class Location:
             self.proto = m.group('proto')
             self.proto = m.group('proto')
             self.user = m.group('user')
             self.user = m.group('user')
             self.host = m.group('host')
             self.host = m.group('host')
-            self.port = m.group('port') and int(m.group('port')) or 22
+            self.port = m.group('port') and int(m.group('port')) or None
             self.path = m.group('path')
             self.path = m.group('path')
             self.archive = m.group('archive')
             self.archive = m.group('archive')
             return True
             return True
@@ -302,8 +302,6 @@ class Location:
             self.path = m.group('path')
             self.path = m.group('path')
             self.archive = m.group('archive')
             self.archive = m.group('archive')
             self.proto = self.host and 'ssh' or 'file'
             self.proto = self.host and 'ssh' or 'file'
-            if self.proto == 'ssh':
-                self.port = 22
             return True
             return True
         return False
         return False
 
 

+ 8 - 1
attic/remote.py

@@ -83,7 +83,14 @@ class RemoteRepository(object):
         if location.host == '__testsuite__':
         if location.host == '__testsuite__':
             args = [sys.executable, '-m', 'attic.archiver', 'serve']
             args = [sys.executable, '-m', 'attic.archiver', 'serve']
         else:
         else:
-            args = ['ssh', '-p', str(location.port), '%s@%s' % (location.user or getpass.getuser(), location.host), 'attic', 'serve']
+            args = ['ssh',]
+            if location.port:
+                args += ['-p', str(location.port)]
+            if location.user:
+                args.append('%s@%s' % (location.user, location.host))
+            else:
+                args.append('%s' % location.host)
+            args += ['attic', 'serve']
         self.p = Popen(args, bufsize=0, stdin=PIPE, stdout=PIPE)
         self.p = Popen(args, bufsize=0, stdin=PIPE, stdout=PIPE)
         self.stdin_fd = self.p.stdin.fileno()
         self.stdin_fd = self.p.stdin.fileno()
         self.stdout_fd = self.p.stdout.fileno()
         self.stdout_fd = self.p.stdout.fileno()

+ 1 - 1
attic/testsuite/helpers.py

@@ -16,7 +16,7 @@ class LocationTestCase(AtticTestCase):
         )
         )
         self.assert_equal(
         self.assert_equal(
             repr(Location('user@host:/some/path::archive')),
             repr(Location('user@host:/some/path::archive')),
-            "Location(proto='ssh', user='user', host='host', port=22, path='/some/path', archive='archive')"
+            "Location(proto='ssh', user='user', host='host', port=None, path='/some/path', archive='archive')"
         )
         )
         self.assert_equal(
         self.assert_equal(
             repr(Location('mybackup.attic::archive')),
             repr(Location('mybackup.attic::archive')),