@@ -59,7 +59,10 @@ class RepositoryService:
59
59
# this symbol is made available for testing purposes
60
60
_current = None
61
61
62
- config_options = ['type' , 'token' , 'alias' , 'fqdn' ]
62
+ config_options = [
63
+ 'type' , 'token' , 'alias' , 'fqdn' , 'remote' ,
64
+ 'port' , 'scheme' , 'insecure' ,
65
+ ]
63
66
64
67
@classmethod
65
68
def get_config_path (cls ):
@@ -89,7 +92,8 @@ def store_config(cls, config, **kwarg):
89
92
for option , value in kwarg .items ():
90
93
if option not in cls .config_options :
91
94
raise ArgumentError ('Option {} is invalid and cannot be setup.' .format (option ))
92
- config .set_value (section , option , value )
95
+ if value != None :
96
+ config .set_value (section , option , value )
93
97
94
98
@classmethod
95
99
def set_alias (cls , config ):
@@ -111,6 +115,8 @@ def get_service(cls, repository, command):
111
115
target = cls .command_map .get (command , command )
112
116
conf_section = list (filter (lambda n : 'gitrepo' in n and target in n , config .sections ()))
113
117
118
+ http_section = [config ._sections [scheme ] for scheme in ('http' , 'https' )]
119
+
114
120
# check configuration constraints
115
121
if len (conf_section ) == 0 :
116
122
if not target :
@@ -133,25 +139,15 @@ def get_service(cls, repository, command):
133
139
raise ValueError ('Service type {} does not exists.' .format (config ['type' ]))
134
140
service = cls .service_map .get (config ['type' ], cls )
135
141
136
- cls ._current = service (repository , config )
142
+ cls ._current = service (repository , config , http_section )
137
143
return cls ._current
138
144
139
145
@classmethod
140
146
def get_auth_token (cls , login , password , prompt = None ):
141
147
raise NotImplementedError
142
148
143
- def __init__ (self , r = None , c = None ):
144
- '''
145
- :param r: git-python repository instance
146
- :param c: configuration data
147
-
148
- Build a repository service instance, store configuration and parameters
149
- And launch the connection to the service
150
- '''
151
-
152
- self .repository = r
153
- self .config = c
154
-
149
+ def load_configuration (self , c , hc ):
150
+ CONFIG_TRUE = ('on' , 'true' , 'yes' , '1' )
155
151
# if there's a configuration file, update the names accordingly
156
152
if c :
157
153
name = ' ' .join (c ['__name__' ].replace ('"' , '' ).split (' ' )[1 :])
@@ -170,8 +166,32 @@ def __init__(self, r=None, c=None):
170
166
c .get ('private_token' ,
171
167
c .get ('privatekey' , None ))))
172
168
self ._alias = c .get ('alias' , self .name )
173
- self .fqdn = c .get ('fqdn' , self .fqdn )
174
- self .insecure = c .get ('insecure' , 'false' ).lower () in ('on' , 'true' , 'yes' , '1' )
169
+
170
+ self .fqdn , port = c .get ('fqdn' , self .fqdn ).split (':' )
171
+ self .port = port or None
172
+
173
+ self .default_create_private = c .get ('default-create-private' , 'false' ).lower () in CONFIG_TRUE
174
+ self .ssh_url = c .get ('ssh-url' , None ) or self .fqdn
175
+
176
+ self .session_insecure = c .get ('insecure' , 'false' ).lower () in CONFIG_TRUE
177
+ self .session_certificate = c .get ('certificate' , None )
178
+ self .session_proxy = {cf ['__name__' ]: cf ['proxy' ] for cf in hc if cf .get ('proxy' , None )}
179
+
180
+
181
+
182
+ def __init__ (self , r = None , c = None , hc = None ):
183
+ '''
184
+ :param r: git-python repository instance
185
+ :param c: configuration data
186
+
187
+ Build a repository service instance, store configuration and parameters
188
+ And launch the connection to the service
189
+ '''
190
+
191
+ self .repository = r
192
+ self .config = c
193
+
194
+ self .load_configuration (c , hc )
175
195
176
196
# if service has a repository configured, connect
177
197
if r :
0 commit comments