コード例 #1
0
ファイル: init_repo.py プロジェクト: user-cont/release-bot
    def create_conf(self, silent):
        """
        Create the release-conf.yaml and conf.yaml
        """
        cwd = os.getcwd()
        self.release_conf["author_email"] = run_command_get_output(
            cwd, "git config user.email")[1].strip()
        self.release_conf["author_name"] = run_command_get_output(
            cwd, "git config user.name")[1].strip()
        if self.release_conf["author_email"] == "":
            print(
                "WARNING: your e-mail ID from git config is not set." +
                "\nPlease set it using 'git config user.email \"[email protected]\"'"
            )
        elif not re.match(r"[^@]+@[^@]+\.[^@]+",
                          self.release_conf["author_email"]):
            print(
                "WARNING: your e-mail ID from git config is not a valid e-mail address."
            )
        if self.release_conf["author_name"] == "":
            print("WARNING: your username from git config is not set." +
                  "\nPlease set it using 'git config user.name \"John Doe\"'")
        if not silent:
            self.conf["repository_name"] = input(
                "Please enter the repository name:")
            self.conf["repository_owner"] = input(
                "Please enter the repository owner:")
            print("""For details on how to get github token checkout
    'https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/'"""
                  )
            self.conf["github_token"] = input(
                "Please enter your valid github token:")
            refresh_interval = "dummy"
            while not (refresh_interval.isdigit() or refresh_interval == ""):
                refresh_interval = input(
                    """In how many seconds would you like the
    bot to recheck for updates (Default: don't recheck and exit):""")
            if refresh_interval > 0:
                self.conf["refresh_interval"] = int(refresh_interval)
            else:
                self.conf["refresh_interval"] = None
            is_owner_user = input("Are you the owner of the repo? (Y/n):")
            if is_owner_user.lower() == "y" or is_owner_user == "":
                self.conf["github_username"] = self.conf["repository_owner"]
            else:
                self.conf["github_username"] = input(
                    "Please enter your github usename:")
            trigger_on_issue = input(
                "Would you like to trigger release from issue? (Y/n):")
            self.release_conf["trigger_on_issue"] = bool(
                trigger_on_issue.lower() == "y" or trigger_on_issue == "")
            gitchangelog = input(
                "Would you like to use gitchangelog to generate next-gen changelogs? (Y/n):"
            )
            self.conf["gitchangelog"] = bool(gitchangelog.lower() == "y"
                                             or gitchangelog == "")

        self.create_yaml(self.conf, "conf.yaml")
        self.create_yaml(self.release_conf, "release-conf.yaml")
コード例 #2
0
 def get_log_since_last_release(self, latest_version):
     """
     Utilizes git log to get log since last release, excluding merge commits
     :param latest_version: previous version
     :return: changelog or placeholder
     """
     cmd = f'git log {latest_version}... --no-merges --format=\'* %s\''
     success, changelog = run_command_get_output(self.repo_path, cmd)
     return changelog if success and changelog else 'No changelog provided'
コード例 #3
0
 def get_log_since_last_release(self, latest_version, gitchangelog):
     """
     Utilizes [GitChangeLog](https://github.com/vaab/gitchangelog/) to get
     log since latest release according to the template provided.
     :param latest_version: previous version
     :param gitchangelog: bool, use gitchangelog
     :return: changelog or placeholder
     """
     if gitchangelog:
         cmd = f'gitchangelog ^{latest_version} HEAD'
     else:
         cmd = f'git log {latest_version}... --no-merges --format=\'* %s\''
     success, changelog = run_command_get_output(self.repo_path, cmd)
     return changelog if success and changelog else 'No changelog provided'