def local_project(self): if not self._local_project: self._local_project = LocalProject( git_url=self.package_config.upstream_project_url, repo_name=self.package_config.upstream_package_name, ) if self._local_project.git_project is None: if not self.package_config.upstream_project_url: self.package_config.upstream_project_url = git_remote_url_to_https_url( self._local_project.git_url) self._local_project.git_project = self.config.get_project( url=self.package_config.upstream_project_url) # self._local_project.refresh_the_arguments() return self._local_project
def convert(self, value, param, ctx): try: branch_name = None if self.branch_param_name: if self.branch_param_name in ctx.params: branch_name = ctx.params[self.branch_param_name] else: # use the default for param in ctx.command.params: if param.name == self.branch_param_name: branch_name = param.default remote_name = ctx.params.get(self.remote_param_name, None) if os.path.isdir(value): absolute_path = os.path.abspath(value) logger.info(f"Input is a directory: {absolute_path}") local_project = LocalProject(working_dir=absolute_path, ref=branch_name, remote=remote_name) elif git_remote_url_to_https_url(value): logger.info(f"Input is a URL to a git repo: {value}") local_project = LocalProject(git_url=value, ref=branch_name, remote=remote_name) else: self.fail( "Provided input path_or_url is not a directory nor an URL of a git repo." ) if not local_project.working_dir and not local_project.git_url: self.fail( "Parameter is not an existing directory nor correct git url.", param, ctx, ) return local_project except Exception as ex: self.fail(ex, param, ctx)
def test_remote_to_https(inp, ok): assert git_remote_url_to_https_url(inp) == ok