Exemple #1
0
def test_gitlog_parse():
    entries = gitlog.parse_gitlog({
        'pr_url_base': 'https://github.com/skyportal/skyportal/pull',
        'commit_url_base': 'https://github.com/skyportal/skyportal/commit',
        'name': 'SP',
        'log': log,
    })
    e0 = entries[0]
    e1 = entries[1]

    assert e0['name'] == 'SP'
    assert e0['time'] == '2020-10-06T19:38:32-07:00'
    assert e0['sha'] == 'f3542fa8'
    assert e0['email'] == '*****@*****.**'
    assert e0['description'] == 'Pass git log to frontend as parsed components'
    assert e0['pr_nr'] is None
    assert e0['pr_url'] == ''
    assert e0[
        'commit_url'] == "https://github.com/skyportal/skyportal/commit/f3542fa8"

    assert e1['name'] == 'SP'
    assert e1['time'] == '2020-10-05T14:06:20+03:00'
    assert e1['sha'] == 'a4052098f'
    assert e1['email'] == '*****@*****.**'
    assert e1['description'] == 'Bump emoji-dictionary from 1.0.10 to 1.0.11'
    assert e1['pr_nr'] == '1040'
    assert e1['pr_url'] == 'https://github.com/skyportal/skyportal/pull/1040'
    assert e1[
        'commit_url'] == "https://github.com/skyportal/skyportal/commit/a4052098f"
Exemple #2
0
    def get(self):
        """
        ---
        description: Retrieve system/deployment info
        tags:
          - system_info
        responses:
          200:
            content:
              application/json:
                schema:
                  allOf:
                    - $ref: '#/components/schemas/Success'
                    - type: object
                      properties:
                        data:
                          type: object
                          properties:
                            invitationsEnabled:
                              type: boolean
                              description: |
                                Boolean indicating whether new user invitation pipeline
                                is enabled in current deployment.
                            gitlog:
                                type: array
                                description: Recent git commit lines
                            cosmology:
                                type: string
                                description: Details of the cosmology used here
                            cosmoref:
                                type: string
                                description: Reference for the cosmology used.
        """
        # if another build system has written a gitlog file, use it
        gitlogs = []
        for gitlog in glob.glob(gitlog_files):
            with open(gitlog, "r") as f:
                gitlogs.append(json.load(f))
        if not gitlogs:
            gitlogs = [get_gitlog()]

        parsed_logs = [parse_gitlog(gitlog) for gitlog in gitlogs]
        parsed_log = list(itertools.chain(*parsed_logs))
        parsed_log = list(
            sorted(parsed_log, key=lambda x: x['time'], reverse=True))
        parsed_log = parsed_log[:max_log_lines]
        parsed_log = [
            entry for entry in parsed_log
            if not (entry['description'].lower().startswith(('bump', 'pin')))
        ]

        return self.success(
            data={
                "invitationsEnabled": cfg["invitations.enabled"],
                "cosmology": str(cosmo),
                "cosmoref": cosmo.__doc__,
                "gitlog": parsed_log,
            })
Exemple #3
0
    def get(self):
        """
        ---
        description: Retrieve system/deployment info
        tags:
          - system_info
        responses:
          200:
            content:
              application/json:
                schema:
                  allOf:
                    - $ref: '#/components/schemas/Success'
                    - type: object
                      properties:
                        data:
                          type: object
                          properties:
                            gitlog:
                                type: array
                                description: Recent git commit lines

        """
        # if another build system has written a gitlog file, use it
        gitlogs = []
        for gitlog in glob.glob(gitlog_files):
            with open(gitlog) as f:
                gitlogs.append(json.load(f))
        if not gitlogs:
            gitlogs = [get_gitlog()]

        parsed_logs = [parse_gitlog(gitlog) for gitlog in gitlogs]
        parsed_log = list(itertools.chain(*parsed_logs))
        parsed_log = list(
            sorted(parsed_log, key=lambda x: x['time'], reverse=True))
        parsed_log = parsed_log[:max_log_lines]
        parsed_log = [
            entry for entry in parsed_log
            if not (entry['description'].lower().startswith(('bump', 'pin')))
        ]

        return self.success(data={
            "gitlog": parsed_log,
        })
Exemple #4
0
    def get(self):
        """
        ---
        description: Retrieve system/deployment info
        responses:
          200:
            content:
              application/json:
                schema:
                  allOf:
                    - $ref: '#/components/schemas/Success'
                    - type: object
                      properties:
                        data:
                          type: object
                        properties:
                          invitationsEnabled:
                            type: boolean
                            description: |
                              Boolean indicating whether new user invitation pipeline
                              is enabled in current deployment.
                          gitlog:
                              type: array
                              description: Recent git commit lines
                          cosmology:
                              type: string
                              description: Details of the cosmology used here
                          cosmoref:
                              type: string
                              description: Reference for the cosmology used.
        """
        # if another build system has written a gitlog file, use it
        loginfo = ""
        if os.path.exists(gitlog_file):
            with open(gitlog_file, "r") as spgl:
                loginfo = spgl.read()
        if loginfo == "":
            p = subprocess.run(
                [
                    "git",
                    "--git-dir=.git",
                    "log",
                    "--no-merges",
                    "--first-parent",
                    "--pretty=format:[%cI %h %cE] %s",
                    f"-{max_log_lines * 10}",
                ],
                capture_output=True,
                universal_newlines=True,
            )
            loginfo = p.stdout

        parsed_log = gitlog.parse_gitlog(loginfo.splitlines())
        parsed_log = [
            entry for entry in parsed_log
            if not (entry['description'].lower().startswith(('bump', 'pin')))
        ]
        parsed_log = parsed_log[:max_log_lines]

        return self.success(
            data={
                "invitationsEnabled": cfg["invitations.enabled"],
                "cosmology": str(cosmo),
                "cosmoref": cosmo.__doc__,
                "gitlog": parsed_log,
            })