Skip to content

Getting started with GitProjectHealth

This page takes you from an empty Moose image to a first answer about your repositories. It takes about ten minutes, plus the import time.

  • A Moose image (see Install Moose). This documentation was checked with Moose on Pharo 13.
  • For platform importers, an access token (see below). The local importer needs no token, only a clone on disk.
  • All the code below is Pharo code, to run in a Playground (Ctrl+O, Ctrl+W): select it and Do it (Ctrl+D) or Inspect it (Ctrl+I).
  1. Install GitProjectHealth. In a Playground, run:

    Metacello new
    repository: 'github://moosetechnology/GitProjectHealth:main/src';
    baseline: 'GitLabHealth';
    onConflict: [ :ex | ex useIncoming ];
    onUpgrade: [ :ex | ex useIncoming ];
    onDowngrade: [ :ex | ex useLoaded ];
    load

    This loads the default group: the meta-model, every importer, the analyses and the visualizations. The Jira and Famix connectors are optional groups.

  2. Get an access token for your platform.

    In GitLab, open User settings → Access tokens and create a personal access token with the read_api scope (read_repository is also needed if you import files).

  3. Import. Create an empty model, configure an importer, and import.

    model := GLHModel new name: 'my-gitlab-analysis'.
    importer := GitModelImporter
    forGitlabHostOn: 'https://gitlab.com/api/v4' "or your own instance, ending with /api/v4"
    withToken: '<YOUR-GITLAB-TOKEN>'
    andModel: model.
    "Import the commits of the last 30 days (default of this constructor: 3 days)"
    importer withCommitsSince: 30 days.
    "A group is identified by its numeric ID, shown on the group page in GitLab"
    group := importer importGroup: 1234.

    Importing a large group through an API can take several minutes.

  4. Explore the model. Inspect it (Ctrl+I on model) and browse the entities by type, or open the inspector on the group (group inspect) to get the Group Quality view.

  5. Ask a first question. For instance, who committed the most during the period?

    ((model allWithType: GLHCommit)
    collect: [ :commit | commit commitCreator ifNil: [ commit author_name ] ])
    asBag sortedCounts

    sortedCounts returns the number of commits per user, highest first.