|
10 | 10 | import core.dfd_extraction as dfd_extraction |
11 | 11 | from output_generators.logger import logger |
12 | 12 | import tmp.tmp as tmp |
13 | | -from core.file_interaction import clone_repo |
14 | 13 |
|
15 | 14 | CONFIG_SECTIONS = ["Analysis Settings", "Repository", "Technology Profiles", "DFD"] |
16 | 15 | COMMUNICATIONS_TECH_LIST = '[("RabbitMQ", "rmq"), ("Kafka", "kfk"), ("RestTemplate", "rst"),\ |
|
24 | 23 | DEFAULT_CONFIG.set("Technology Profiles", "communication_techs_list", COMMUNICATIONS_TECH_LIST) |
25 | 24 |
|
26 | 25 |
|
27 | | -def api_invocation(path: str) -> dict: |
| 26 | +def api_invocation(url: str, commit: str) -> dict: |
28 | 27 | """Entry function for when tool is called via API call. |
29 | 28 | """ |
30 | 29 |
|
31 | | - print("New call for " + path) |
32 | | - response = dict() |
| 30 | + repo_path = url.split("github.com/")[1] # TODO This needs to generalize beyond GitHub |
| 31 | + print("New call for " + repo_path) |
33 | 32 |
|
34 | 33 | start_time = datetime.now() |
35 | 34 |
|
36 | 35 | logger.info("*** New execution ***") |
37 | | - logger.debug("Copying config file to tmp file") |
| 36 | + logger.debug("Initializing config to tmp file") |
| 37 | + for section in CONFIG_SECTIONS: # Copying what is needed from default to temp |
| 38 | + tmp.tmp_config.add_section(section) |
| 39 | + for entry in DEFAULT_CONFIG[section]: |
| 40 | + tmp.tmp_config.set(section, entry, DEFAULT_CONFIG[section][entry]) |
38 | 41 |
|
39 | 42 | # Overwrite repo_path from config file with the one from the API call |
40 | | - # TODO add analysis of specific commit with Flask API |
41 | | - repo_path = str(path) |
42 | 43 | tmp.tmp_config.set("Repository", "path", repo_path) |
43 | | - |
44 | | - local_path = os.path.join(os.getcwd(), "analysed_repositories", *repo_path.split("/")[1:]) |
45 | | - tmp.tmp_config.set("Repository", "local_path", local_path) |
46 | | - |
47 | | - clone_repo(repo_path, local_path) # TODO use Pydriller |
| 44 | + tmp.tmp_config.set("Repository", "local_path", |
| 45 | + os.path.join(os.getcwd(), "analysed_repositories")) |
| 46 | + if commit is not None: |
| 47 | + tmp.tmp_config.set("Analysis Settings", "commit", commit) |
48 | 48 |
|
49 | 49 | # Call extraction |
50 | 50 | codeable_models, traceability = dfd_extraction.perform_analysis() |
51 | 51 |
|
| 52 | + response = dict() |
52 | 53 | response["codeable_models_file"] = codeable_models |
53 | | - response["traceability"] = traceability |
| 54 | + response["traceability_file"] = traceability |
54 | 55 |
|
55 | 56 | # Execution time |
56 | 57 | end_time = datetime.now() |
|
0 commit comments