22#
33# Author: Simon Schneider, 2023
44# Contact: simon.schneider@tuhh.de
5-
5+ import os
66from configparser import ConfigParser
77from datetime import datetime
88import argparse
1111import core .dfd_extraction as dfd_extraction
1212from output_generators .logger import logger
1313import tmp .tmp as tmp
14- from core .file_interaction import get_output_path , get_local_path , clone_repo
14+ from core .file_interaction import get_output_path , clone_repo
1515
1616CONFIG_SECTIONS = ["Analysis Settings" , "Repository" , "Technology Profiles" , "DFD" ]
1717COMMUNICATIONS_TECH_LIST = '[("RabbitMQ", "rmq"), ("Kafka", "kfk"), ("RestTemplate", "rst"),\
@@ -42,10 +42,10 @@ def api_invocation(path: str) -> dict:
4242 repo_path = str (path )
4343 tmp .tmp_config .set ("Repository" , "path" , repo_path )
4444
45- local_path = get_local_path ( repo_path )
45+ local_path = os . path . join ( os . getcwd (), "analysed_repositories" , * repo_path . split ( "/" )[ 1 :] )
4646 tmp .tmp_config .set ("Repository" , "local_path" , local_path )
4747
48- clone_repo (repo_path , local_path )
48+ clone_repo (repo_path , local_path ) # TODO use Pydriller
4949
5050 # Call extraction
5151 codeable_models , traceability = dfd_extraction .perform_analysis ()
@@ -69,6 +69,8 @@ def main():
6969 parser .add_argument ("--repo_path" , type = str , help = "Path to the repository as 'repository/path'" )
7070 parser .add_argument ("--development_mode" , action = 'store_true' , help = "Switch on development mode" )
7171 parser .add_argument ("--commit" , type = str , help = "Analyze repository at this commit" )
72+ # TODO add cli for url
73+ # TODO add cli for local path
7274 now = datetime .now ()
7375 start_time = now .strftime ("%H:%M:%S" )
7476
@@ -98,13 +100,13 @@ def main():
98100 tmp .tmp_config .set ("Analysis Settings" , "development_mode" , "True" )
99101
100102 repo_path = tmp .tmp_config .get ("Repository" , "path" )
101- local_path = get_local_path (repo_path )
102- clone_repo (repo_path , local_path ) # TODO use PyDriller to clone repo
103- tmp .tmp_config .set ("Repository" , "local_path" , local_path )
104- tmp .tmp_config .set ("Analysis Settings" , "output_path" , get_output_path (repo_path ))
103+ local_path = os .path .join (os .getcwd (), "analysed_repositories" )
104+ url_path = tmp .tmp_config .get ("Repository" , "url" )
105105
106- repository = Repository (path_to_repo = local_path )
107- with repository ._prep_repo (local_path ) as git_repo :
106+ os .makedirs (local_path , exist_ok = True )
107+ repository = Repository (path_to_repo = url_path , clone_repo_to = local_path )
108+ with repository ._prep_repo (url_path ) as git_repo :
109+ tmp .tmp_config .set ("Repository" , "local_path" , str (git_repo .path ))
108110 commit = head = git_repo .get_head ().hash [:7 ]
109111 if args .commit is not None :
110112 commit = args .commit [:7 ]
0 commit comments