def _getEmailNote(self, login_name, project_url): repo_message = "" try: remote_url = git_utils.grabLocalProject(self.config.directory) main_project_name = self.githubConnector.grabRemoteProjectByUrl( str(remote_url) ) dependency_project_name = self.githubConnector.grabRemoteProjectByUrl( str(project_url) ) if main_project_name.full_name != dependency_project_name.full_name: repo_message = ( " to " + dependency_project_name.full_name + ". We are using it at " + main_project_name.full_name ) else: repo_message = " to " + main_project_name.full_name except Exception as e: print("Cannot detect remote url of git repo", e) prefix = "@" + login_name + ": Thank you for contributing" + repo_message postfix = " Find out more about LibreSelery at https://github.com/protontypes/libreselery." inner = ( ": " + self.config.optional_email_message if self.config.optional_email_message else "" ) return prefix + inner + postfix
def gather(self): mainProjects = [] mainContributors = [] dependencyProjects = [] dependencyContributors = [] toolingProjects = [] toolingContributors = [] projectUrl = git_utils.grabLocalProject(self.config.directory) localProject = self.githubConnector.grabRemoteProjectByUrl(projectUrl) self.log("Gathering project information of '%s' at local folder '%s" % (projectUrl, self.config.directory)) print("=======================================================") if self.config.include_main_repository: # find official repositories self.log("Including contributors of root project '%s'" % localProject.full_name) self.log(" -- %s" % localProject.html_url) # print(" -- %s" % [c.author.email for c in localContributors]) # safe dependency information mainProjects.append(localProject) for p in mainProjects: # grab contributors mainContributor = self.githubConnector.grabRemoteProjectContributors( p) # filter contributors mainContributor = selery_utils.validateContributors( mainContributor, self.config.min_contributions_required_payout) # safe contributor information mainContributors.extend(mainContributor) if self.config.include_dependencies: self.log("Searching for dependencies of project '%s' " % localProject.full_name) # scan for dependencies repositories rubyScanScriptPath = os.path.join(self.seleryDir, "libreselery", "ruby_extensions", "scan.rb") process = subprocess.run( [ "ruby", rubyScanScriptPath, "--project=%s" % self.config.directory ], stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True, ) # exec and evaluate stdout if process.returncode == 0: dependencies_json = json.loads(process.stdout) else: self.logError("Could not find project manifesto") print(process.stderr) raise Exception("Aborting") # process dependency json unique_dependency_dict = selery_utils.getUniqueDependencies( dependencies_json) for platform, depList in unique_dependency_dict.items(): for dep in depList: d = dep["name"] r = dep["requirement"] print(" -- %s: %s [%s]" % (platform, d, r)) libIoProject = self.librariesIoConnector.findProject( platform, d) print(" > %s" % ("FOUND %s" % libIoProject if libIoProject else "NOT FOUND")) # gather more information for project dependency if libIoProject: libIoRepository = self.librariesIoConnector.findRepository( libIoProject) libIoDependencies = ( self.librariesIoConnector.findProjectDependencies( libIoProject)) # print(" > %s" % # [dep.project_name for dep in libIoDependencies]) # libIoProject # ) if libIoRepository: gitproject = self.githubConnector.grabRemoteProject( libIoRepository.github_id) # safe project / dependency information dependencyProjects.append(gitproject) self.log( "Gathering dependency contributor information from Github. This will take some time for larger projects." ) for p in dependencyProjects: # grab contributors depContributors = self.githubConnector.grabRemoteProjectContributors( p) # filter contributors based min contribution depContributors = selery_utils.validateContributors( depContributors, self.config.min_contributions_required_payout) # safe contributor information dependencyContributors.extend(depContributors) if self.config.include_tooling_and_runtime and self.config.tooling_path: # tooling projects will be treated as dependency projects self.log("Searching for tooling of project '%s' " % localProject.full_name) for toolurl in self.config.toolrepos["github"]: toolingProject = self.githubConnector.grabRemoteProjectByUrl( toolurl) self.log(" -- %s" % toolingProject) self.log(" -- %s" % toolingProject.html_url) # safe tooling information toolingProjects.append(toolingProject) self.log("Gathering toolchain contributor information") # scan for project contributors for p in toolingProjects: # grab contributors toolingContributor = self.githubConnector.grabRemoteProjectContributors( p) # filter contributors toolingContributor = selery_utils.validateContributors( toolingContributor, self.config.min_contributions_required_payout) # safe contributor information dependencyContributors.extend(toolingContributor) print("=======================================================") self.logNotify("Gathered valid directory: %s" % self.config.directory) self.logNotify("Gathered '%s' valid main repositories" % len(mainProjects)) self.logNotify("Gathered '%s' valid main contributors" % len(mainContributors)) self.logNotify("Gathered '%s' valid dependency repositories" % len(dependencyProjects)) self.logNotify("Gathered '%s' valid dependency contributors" % len(dependencyContributors)) return ( mainProjects, mainContributors, dependencyProjects, dependencyContributors, )