Skip to content

Instantly share code, notes, and snippets.

@guibranco
Created May 9, 2025 14:36
Show Gist options
  • Save guibranco/463a6cec8aafc23f6379ba75f9fe38e4 to your computer and use it in GitHub Desktop.
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.
<#
.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"
@guibranco
Copy link
Author

πŸ’‘ 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 to artifacts/execution.log.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment