initial commit
[ebuildfind.git] / commands / lib / layman / overlays / git.py
blobbda2df059b5a4b27e55a6aa89538caaa540917c0
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3 #################################################################################
4 # LAYMAN GIT OVERLAY HANDLER
5 #################################################################################
6 # File: git.py
8 # Handles git overlays
10 # Copyright:
11 # (c) 2005 - 2008 Gunnar Wrobel, Stefan Schweizer
12 # Distributed under the terms of the GNU General Public License v2
14 # Author(s):
15 # Gunnar Wrobel <wrobel@gentoo.org>
16 # Stefan Schweizer <genstef@gentoo.org>
17 ''' Git overlay support.'''
19 __version__ = "$Id: git.py 146 2006-05-27 09:52:36Z wrobel $"
21 #===============================================================================
23 # Dependencies
25 #-------------------------------------------------------------------------------
27 from layman.utils import path
28 from layman.overlays.overlay import Overlay
30 #===============================================================================
32 # Class GitOverlay
34 #-------------------------------------------------------------------------------
36 class GitOverlay(Overlay):
37 ''' Handles git overlays.'''
39 type = 'Git'
41 binary_command = '/usr/bin/git'
43 def add(self, base, quiet = False):
44 '''Add overlay.'''
46 self.supported()
48 if quiet:
49 quiet_option = '-q '
50 else:
51 quiet_option = ''
53 # http:// should get trailing slash, other protocols shouldn't
54 slash = ''
55 if self.src.split(':')[0] == 'http':
56 slash = '/'
57 return self.cmd(self.binary_command + ' clone ' + quiet_option + '"' + self.src + slash
58 + '" "' + path([base, self.name]) + '"')
60 def sync(self, base, quiet = False):
61 '''Sync overlay.'''
63 self.supported()
65 if quiet:
66 quiet_option = ' -q'
67 else:
68 quiet_option = ''
70 return self.cmd('cd "' + path([base, self.name]) + '" && '
71 + self.binary_command + ' pull' + quiet_option)
73 def supported(self):
74 '''Overlay type supported?'''
76 return Overlay.supported(self, [(self.binary_command, 'git',
77 'dev-util/git'),])