@@ -229,22 +229,30 @@ def get_repo(repo, basepath):
229229 :param repo: tuple of repo link and branch(optional)
230230 :param basepath: base path where the repository has to be downloaded
231231 """
232- if not repo [1 ]:
232+ if not isinstance (repo , tuple ):
233+ repo = (repo , '' )
234+
235+ if repo [1 ] == '' :
233236 branch = "master"
234237 else :
235238 branch = repo [1 ]
236239 cmd_update = "b=%s;git reset --hard && git checkout master && git remote update && (git branch | grep -w $b && (git switch $b && git pull origin $b --rebase) || (git fetch origin && git switch -c $b origin/$b) || echo \" Error: Could not sync with origin/$b\" )" % branch
237240 repo_name = repo [0 ].split ('/' )[- 1 ].split ('.git' )[0 ]
238241 repo_path = os .path .join (basepath , repo_name )
239242 cmd_clone = "git clone %s %s" % (repo [0 ], repo_path )
240- if os .path .isdir (repo_path ):
241- cmd = "cd %s && %s" % (repo_path , cmd_update )
243+
244+ logger .info ("\t 3. Cloning/Updating the repo: %s with branch %s under %s" % (
245+ repo_name , branch , repo_path ))
246+ if not os .path .isdir (repo_path ):
247+ cmd = "%s && cd %s" % (cmd_clone , repo_path )
242248 else :
243- cmd = "%s && cd %s && %s" % (cmd_clone , repo_path , cmd_update )
244- helper .runcmd (cmd ,
245- info_str = "\t 3. Cloning/Updating the repo: %s with branch %s under %s" % (
246- repo_name , branch , repo_path ),
247- err_str = "Failed to clone/update %s repository:" % repo_name )
249+ cmd = "cd %s && [ %s = \" $(git remote get-url origin)\" ] && echo \" Repo matches\" && exit 0 \" \
250+ || echo \" Repo does not match\" && exit 1 \" " % (repo_path , repo [0 ])
251+
252+ helper .runcmd (cmd , err_str = "Failed to clone %s repository:, Please clean environment" % repo_name )
253+
254+ cmd = "cd %s && %s" % (repo_path , cmd_update )
255+ helper .runcmd (cmd , err_str = "Failed to update %s repository:" % repo_name )
248256
249257
250258def create_config (logdir ):
0 commit comments