def __call__(self): cz = self.cz questions = cz.questions() answers = questionary.prompt(questions) if not answers: raise SystemExit(NO_ANSWERS) m = cz.message(answers) out.info(f"\n{m}\n") c = git.commit(m) if c.err: out.error(c.err) raise SystemExit(COMMIT_ERROR) if "nothing added" in c.out or "no changes added to commit" in c.out: out.error(c.out) elif c.err: out.error(c.err) else: out.write(c.out) out.success("Commit successful!")
def __call__(self): out.write("\n".join(registry.keys()))
def __call__(self): out.write(self.cz.schema())
def __call__(self): out.write(self.cz.example())
def __call__(self): """Steps executed to bump.""" try: current_version_instance: Version = Version(self.parameters["version"]) except TypeError: out.error("[NO_VERSION_SPECIFIED]") out.error("Check if current version is specified in config file, like:") out.error("version = 0.4.3") raise SystemExit(NO_VERSION_SPECIFIED) # Initialize values from sources (conf) current_version: str = self.config["version"] tag_format: str = self.parameters["tag_format"] bump_commit_message: str = self.parameters["bump_message"] current_tag_version: str = bump.create_tag( current_version, tag_format=tag_format ) files: list = self.parameters["files"] dry_run: bool = self.parameters["dry_run"] is_yes: bool = self.arguments["yes"] prerelease: str = self.arguments["prerelease"] increment: Optional[str] = self.arguments["increment"] is_initial = self.is_initial_tag(current_tag_version, is_yes) commits = git.get_commits(current_tag_version, from_beginning=is_initial) # No commits, there is no need to create an empty tag. # Unless we previously had a prerelease. if not commits and not current_version_instance.is_prerelease: out.error("[NO_COMMITS_FOUND]") out.error("No new commits found.") raise SystemExit(NO_COMMITS_FOUND) if increment is None: bump_pattern = self.cz.bump_pattern bump_map = self.cz.bump_map if not bump_map or not bump_pattern: out.error(f"'{self.config['name']}' rule does not support bump") raise SystemExit(NO_PATTERN_MAP) increment = bump.find_increment( commits, regex=bump_pattern, increments_map=bump_map ) # Increment is removed when current and next version # are expected to be prereleases. if prerelease and current_version_instance.is_prerelease: increment = None new_version = bump.generate_version( current_version, increment, prerelease=prerelease ) new_tag_version = bump.create_tag(new_version, tag_format=tag_format) message = bump.create_commit_message( current_version, new_version, bump_commit_message ) # Report found information out.write(message) out.write(f"tag to create: {new_tag_version}") out.write(f"increment detected: {increment}") # Do not perform operations over files or git. if dry_run: raise SystemExit() config.set_key("version", new_version.public) bump.update_version_in_files(current_version, new_version.public, files) c = git.commit(message, args="-a") if c.err: out.error(c.err) raise SystemExit(COMMIT_FAILED) c = git.tag(new_tag_version) if c.err: out.error(c.err) raise SystemExit(TAG_FAILED) out.success("Done!")