Created
May 9, 2025 14:36
-
-
Save guibranco/463a6cec8aafc23f6379ba75f9fe38e4 to your computer and use it in GitHub Desktop.
Extracts developer contribution data from local Git repositories (excluding GitHub) using the CodersRank repo_info_extractor tool for Windows.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
Extracts developer contribution data from local Git repositories (excluding GitHub) using the CodersRank repo_info_extractor tool. | |
.DESCRIPTION | |
This script automates the discovery and processing of Git repositories that are **not hosted on GitHub**. | |
It uses the repo_info_extractor to generate JSON contribution files, which can be uploaded to CodersRank to compute your developer profile score. | |
.REQUIREMENTS | |
- The executable `repo_info_extractor_windows.exe` should be in the same directory or in your PATH. | |
- Your email must match commits you want to track. | |
- Repositories must be locally cloned. | |
.PARAMETER Email | |
Email address used to filter your commits. | |
.PARAMETER ReposPath | |
Path to the parent folder containing your local repositories. | |
#> | |
param ( | |
[string]$Email, | |
[string]$ReposPath | |
) | |
# Prompt for missing parameters | |
if (-not $Email) { | |
$Email = Read-Host "Please enter your email address (used for CodersRank commit matching)" | |
} | |
if (-not $ReposPath) { | |
$ReposPath = Read-Host "Please enter the path to your local repositories" | |
} | |
# Ensure path exists | |
if (-not (Test-Path $ReposPath)) { | |
Write-Host "β The provided path '$ReposPath' does not exist." -ForegroundColor Red | |
exit 1 | |
} | |
$outputDir = "./artifacts" | |
$logFile = Join-Path $outputDir "execution.log" | |
$processedCount = 0 | |
$skippedCount = 0 | |
# Setup output and log directory | |
New-Item -Path $outputDir -ItemType Directory -Force | Out-Null | |
New-Item -Path $logFile -ItemType File -Force | Out-Null | |
function Log { | |
param ( | |
[string]$Message, | |
[string]$Color = "Gray" | |
) | |
Write-Host $Message -ForegroundColor $Color | |
Add-Content -Path $logFile -Value "$(Get-Date -Format 'yyyy-MM-dd HH:mm:ss') - $Message" | |
} | |
Log "π Starting CodersRank repo data extraction..." "Cyan" | |
Log "π Scanning '$ReposPath' for non-GitHub Git repositories..." "DarkCyan" | |
$repos = Get-ChildItem -Path $ReposPath -Directory -Recurse | | |
Where-Object { Test-Path "$($_.FullName)\.git" } | |
foreach ($repo in $repos) { | |
$remoteUrl = git -C $repo.FullName remote get-url origin 2>$null | |
if ($remoteUrl -and $remoteUrl -notmatch "github\.com") { | |
$repoName = Split-Path $repo.FullName -Leaf | |
$outputFile = Join-Path $outputDir "$repoName.json" | |
Log "β Processing $repoName ($remoteUrl)..." "Green" | |
try { | |
./repo_info_extractor_windows.exe --skip_upload --emails $Email local --repo_path $repo.FullName --output_path $outputDir | |
Log "π Output saved to $outputFile" "DarkGray" | |
$processedCount++ | |
} | |
catch { | |
Log "β Error processing $repoName. Error: $_" "Red" | |
} | |
} | |
else { | |
Log "βοΈ Skipping '$($repo.FullName)' - GitHub repository detected." "Yellow" | |
$skippedCount++ | |
} | |
} | |
Log "π Extraction complete. $processedCount processed, $skippedCount skipped." "Cyan" | |
Log "π See full log at '$logFile'" "DarkGray" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
π‘ PowerShell script to extract CodersRank contribution data from local Git repositories excluding GitHub repos.
It auto-discovers repos, filters commits by email, runs
repo_info_extractor
, and logs results toartifacts/execution.log
.