@@ -980,6 +980,7 @@ def vcs_repo(self, environment, version):
980
980
self ,
981
981
version = version ,
982
982
environment = environment ,
983
+ token = self .clone_token ,
983
984
)
984
985
return repo
985
986
@@ -1410,6 +1411,24 @@ def get_subproject_candidates(self, user):
1410
1411
def organization (self ):
1411
1412
return self .organizations .first ()
1412
1413
1414
+ @property
1415
+ def clone_token (self ):
1416
+ """
1417
+ Return a token for HTTP Git clone access to the repository.
1418
+
1419
+ .. note::
1420
+
1421
+ Only repositories granted acces by a GitHub app installation will return a token.
1422
+ """
1423
+ service_class = self .get_git_service_class ()
1424
+ if not service_class :
1425
+ return None
1426
+ for service in service_class .for_project (self ):
1427
+ token = service .get_clone_token (self )
1428
+ if token :
1429
+ return token
1430
+ return None
1431
+
1413
1432
1414
1433
class APIProject (Project ):
1415
1434
"""
@@ -1426,12 +1445,17 @@ class APIProject(Project):
1426
1445
"""
1427
1446
1428
1447
features = []
1448
+ # This is a property in the original model, in order to
1449
+ # be able to assign it a value in the constructor, we need to re-declare it
1450
+ # as an attribute here.
1451
+ clone_token = None
1429
1452
1430
1453
class Meta :
1431
1454
proxy = True
1432
1455
1433
1456
def __init__ (self , * args , ** kwargs ):
1434
1457
self .features = kwargs .pop ("features" , [])
1458
+ self .clone_token = kwargs .pop ("clone_token" , None )
1435
1459
environment_variables = kwargs .pop ("environment_variables" , {})
1436
1460
ad_free = not kwargs .pop ("show_advertising" , True )
1437
1461
# These fields only exist on the API return, not on the model, so we'll
0 commit comments