Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/manual.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Manual collection

on:
workflow_dispatch:
inputs:
project:
description: 'Name of the project to collect'
required: true
default: ''
repositories:
description: 'List of repositories to collect, separated by spaces'
required: false
default: ''
extras:
description: 'Extra arguments to pass (e.g. --not-incremental --add-metrics)'
required: false
default: '--not-incremental --add-metrics'

jobs:
collect:
runs-on: ubuntu-latest
timeout-minutes: 120
steps:
- uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
activate-environment: true
- name: Install dependencies
run: |
uv pip install .
- name: Collect Github Data
run: |
uv run gitmetrics collect -v -q \
-t ${{ secrets.GITHUB_TOKEN }} \
-p ${{ github.event.inputs.project }} \
-r ${{ github.event.inputs.repositories }} \
-o gdrive://${{ secrets.MANUAL_OUTPUT_FOLDER }} \
${{ github.event.inputs.extras }}
env:
PYDRIVE_CREDENTIALS: ${{ secrets.PYDRIVE_CREDENTIALS }}
6 changes: 5 additions & 1 deletion gitmetrics/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ def _collect(args, parser):
elif len(args.projects) > 1:
parser.error('If repositories are given, only one project name must be provided.')

projects = {args.projects[0]: args.repositories}
projects = {
args.projects[0]: [
f'{args.projects[0]}/{repository}' for repository in args.repositories
]
}

elif not args.projects:
projects = config_projects
Expand Down
11 changes: 9 additions & 2 deletions gitmetrics/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from gitmetrics.constants import METRICS_SHEET_NAME
from gitmetrics.drive import get_or_create_gdrive_folder
from gitmetrics.github.repository import RepositoryClient
from gitmetrics.github.repository import STARGAZERS_COLUMNS, RepositoryClient
from gitmetrics.github.repository_owner import RepositoryOwnerClient
from gitmetrics.github.traffic import TrafficClient
from gitmetrics.github.users import UsersClient
Expand Down Expand Up @@ -61,7 +61,14 @@ def _get_repository_data(token, repository, previous=None, quiet=False):
pull_requests = repo_client.get_pull_requests()
pull_requests.insert(1, 'repository', repository)

stargazers = repo_client.get_stargazers()
try:
stargazers = repo_client.get_stargazers()
except Exception:
# Stargazer information is available only for repositories that we own
# In order to continue with the flow without breaking we create an empty
# dataframe with the expected columns.
stargazers = pd.DataFrame(columns=STARGAZERS_COLUMNS)

stargazers.insert(1, 'repository', repository)

return issues, pull_requests, stargazers
Expand Down
Loading