def changelog(self): """ Return a Changelog object for the changelog.Debian.gz of the present .deb package. Return None if no changelog can be found. """ if self.__pkgname is None: self.__updatePkgName() for fname in [ CHANGELOG_DEBIAN % self.__pkgname, CHANGELOG_NATIVE % self.__pkgname ]: if self.data.has_file(fname): gz = gzip.GzipFile(fileobj=self.data.get_file(fname)) raw_changelog = gz.read() gz.close() return Changelog(raw_changelog) return None
def __init__(self, config_path, context, environment=None): self.config = SaasConfig(config_path, context) self.changelog = Changelog(self) if context: self.config.switch_context(context) logger.info("Current context: %s" % self.config.current()) self._default_hash_length = 6 self._services = None self._environment = None if environment and environment != "None": self._environment = environment self.load_from_config()
def generate_changelogs(pid, branch, pat): ''' Generates changelogs from MR descriptions on the given branch :param pid: The project ID of the project to work with :param branch: The name of the target branch for which we look for MRs :param pat: The personal access token to use ''' # Load the latest MR date on the branch working_branch = Branch(pid, branch) working_branch.load_latest_mr_date(str(pid)+'.txt') # Show when the merge date of the MR we processed last run last_mr_date = working_branch.get_latest_mr_date() if last_mr_date: print("Latest merge date:") last_processed_date = dateparser.parse(last_mr_date) print(" {} - {}".format(branch, last_processed_date.strftime(DATE_FORMAT))) # Fetch new MRs on the branch mrs, status_code = working_branch.fetch_new_mrs(pat) # Didn't fetch any MRs if not mrs: print("No new MRs to parse.") return print("Parsing merge requests. This may take a while...") print("--------------------") # Fun facts to track mrs_parsed = 0 cls_generated = 0 # This is stored to make sure we parse all MRs merged after # the MR most lately processed in the previous script run, # even if the MRs were merged "out of order" by issue number. initial_latest_mr_date = dateparser.parse(working_branch.get_latest_mr_date()) # Keep fetching changelogs until there are none left to parse while mrs: if status_code == 429: print("Rate limit hit for the API. Try running the script again later.") break if status_code != 200: print("Failed to fetch additional MRs! (Status code: {})".format(status_code)) break # Go through all the MRs and make changelogs for merge_request in mrs: iid = merge_request.get("iid") title = merge_request.get("title") # Check if this MR was merged later than the current most lately merged MR latest_mr_date = dateparser.parse(working_branch.get_latest_mr_date()) if merge_request.get("merged_at") is None: continue mr_merged_date = dateparser.parse(merge_request.get("merged_at")) # This can happen if someone updates the MR between the script being run # So this prevents re-processing processed MRs if mr_merged_date < initial_latest_mr_date: continue # Update the latest MR date if mr_merged_date > latest_mr_date: working_branch.set_latest_mr_date(merge_request.get("merged_at")) # Find an author for the CL (this is for fallbacks) author = merge_request.get("author") user = "******" if author: user = author.get("username") # Make the changelog print("Parsing MR #{} {}".format(iid, title)) changelog = Changelog() success = changelog.parse_changelog(merge_request.get("description")) mrs_parsed += 1 # No changelog found :( if not success: continue if not changelog.author: changelog.set_author(user) # Fallback to gitlab username as CL author # make a YAML file for the changelog file_name = "{}-merge_request-{}".format(user, merge_request.get("id")) changelog.dump_yaml(file_name) print("Generated changelog for MR #{} {}".format(iid, file_name)) cls_generated += 1 # Fetch new MRs to process mrs, status_code = working_branch.fetch_new_mrs(pat) print("--------------------") # High quality fluffprint print("Parsed {} merge request{}.".format(mrs_parsed, "" if mrs_parsed == 1 else "s")) print("{} changelog{} generated.".format(cls_generated, " was" if cls_generated == 1 else "s were")) # Save our progress on changelog generation working_branch.save_latest_mr_date(str(pid)+'.txt')
import sys from parametros import Parametros from changelog import Changelog args = sys.argv[1:] params = Parametros(args=args, address='vhs4h1809', port=30050, user='******', password='******', schema='SYN4TDF_EVOLUCAO') gerador = Changelog(params) if (params.ok): if params.getTipo() == '-i': gerador.changelogInsert(params) elif params.getTipo() == '-t': gerador.changelogTabela(params) elif params.getTipo() == '-p': gerador.changelogProcedure(params) # hanna = Hanna(address='vhs4h1809', port=30050, user='******', password='******') # hanna.conectar() # procedure = hanna.getProcedureSQL('SYN4TDF_EVOLUCAO','P_GERA_DIEF_PI') # table = hanna.getTableSQL('SYN4TDF_EVOLUCAO','DIEF_PI_REGISTRO_TIPO_50') # insert = hanna.getDadosTableCSV('SYN4TDF_EVOLUCAO','OBRIGACOES_COD_MUN_BA') # print(insert)