fcbde6ef5f35c964da5ac724e48326f608e88f13
9 default_git_remote_dir
= "./git_remote"
12 def is_ref_branch(repo
, ref
):
14 repo
.remote().refs
[ref
]
22 def is_ref_tag(repo
, ref
):
32 def is_ref_commit(repo
, ref
):
34 Repo
.rev_parse(repo
, ref
)
43 logger_format
= '%(asctime)s %(name)-12s %(levelname)-8s %(message)s'
44 logging
.basicConfig(level
=logging
.DEBUG
,
46 datefmt
='%m-%d %H:%M',
47 filename
='./debug.log',
49 # define a Handler which writes INFO messages or higher to the sys.stderr
50 console
= logging
.StreamHandler()
51 console
.setLevel(logging
.DEBUG
)
52 # set a format which is simpler for console use
53 formatter
= logging
.Formatter('%(name)-12s: %(levelname)-8s %(message)s')
54 # tell the handler to use this format
55 console
.setFormatter(formatter
)
56 # add the handler to the root logger
57 logging
.getLogger('').addHandler(console
)
63 logger_git
= logging
.getLogger('setup.git')
65 # Fetch local base repository
66 with
open("config.yaml", 'r') as stream
:
67 config
= yaml
.load(stream
)
69 # Retrieve all possibles remotes and clean url for path
71 for project
, markers
in config
.items():
74 for marker
in markers
:
76 url2path
= urllib
.parse
.quote_plus(url
)
77 path
= os
.path
.abspath(default_git_remote_dir
+ '/' + url2path
)
80 logger_git
.info('Remotes to be fetched {}'.format(remotes
))
82 if not os
.path
.isdir(default_git_remote_dir
):
83 os
.mkdir(default_git_remote_dir
)
86 for url
, path
in remotes
.items():
87 if os
.path
.exists(path
):
88 if not os
.path
.isdir(path
):
89 logger_git
.error('Remote path {} exists and is not a folder'.format(path
))
93 repo
= Repo
.clone_from(url
, path
)
95 # TODO: might be necessary to actually update the base branch, to validate
98 # Create marker definition for test runners
100 for project
, markers
in config
.items():
103 for marker
in markers
:
104 name
= marker
['marker']
111 if is_ref_branch(repo
, ref
):
112 git_object
= Repo
.rev_parse(repo
, repo
.remote().refs
[ref
].name
)
113 elif is_ref_tag(repo
, ref
):
114 git_object
= repo
.tags
[ref
].commit
115 elif is_ref_commit(repo
, ref
):
116 git_object
= repo
.commit(ref
)
118 if git_object
is None:
119 logger_git
.error('Invalid git reference for marker "{}"'.format(name
))
122 logger_git
.info('Marker:{: <30} Sha1 {: <20}'.format(name
, git_object
.hexsha
))
124 if name
in runnable_markers
:
125 logger_git
.error('Duplicate for entry for marker "{}"'.format(name
))
128 runnable_markers
[name
] = {
130 'sha1': git_object
.hexsha
,
135 with
open('run_configuration.yaml', 'w') as run_configuration
:
136 yaml
.dump(runnable_markers
, run_configuration
, default_flow_style
=False)
This page took 0.041498 seconds and 5 git commands to generate.