-
Notifications
You must be signed in to change notification settings - Fork 166
Add --include-unreachable flag and related processing #141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ScottArbeit
wants to merge
14
commits into
github:master
Choose a base branch
from
ScottArbeit:Add-unreachable-objects
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 9 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
5bbde89
Adding support for contributing using Windows.
ScottArbeit 25b2390
Added compressed size and updated a few labels.
ScottArbeit ed44788
Updating CONTRIBUTING.md
ScottArbeit 469485b
Linter updates.
ScottArbeit 56839e5
More linter updates.
ScottArbeit 5d3b4ab
Linter updates.
ScottArbeit f6a16d7
Simplified Makefile.win
ScottArbeit 5b50428
Repaired tabs in makefile 🙄; added variable set in script.
ScottArbeit d9da39e
Added --include-unreachable flag and related processing and output.
ScottArbeit 470d43e
Update git/git.go
ScottArbeit 13288f3
Fixed int32-int64 error.
ScottArbeit 146a800
Merge branch 'Add-unreachable-objects' of https://github.com/ScottArb…
ScottArbeit e284089
Linter error fixes.
ScottArbeit 99ec1bf
Separated unreachable objects by type in the output.
ScottArbeit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Windows-specific Makefile for git-sizer designed for PowerShell | ||
|
||
PACKAGE := github.com/github/git-sizer | ||
GO111MODULES := 1 | ||
|
||
# Use the project's go wrapper script via the -File parameter to avoid loading your profile | ||
GOSCRIPT := $(CURDIR)/script/go.ps1 | ||
GO := pwsh.exe -NoProfile -ExecutionPolicy Bypass -File $(GOSCRIPT) | ||
|
||
# Get the build version from git using try/catch instead of "||" | ||
BUILD_VERSION := $(shell pwsh.exe -NoProfile -ExecutionPolicy Bypass -Command "try { git describe --tags --always --dirty 2>$$null } catch { Write-Output 'unknown' }") | ||
LDFLAGS := -X github.com/github/git-sizer/main.BuildVersion=$(BUILD_VERSION) | ||
GOFLAGS := -mod=readonly | ||
|
||
ifdef USE_ISATTY | ||
GOFLAGS := $(GOFLAGS) --tags isatty | ||
endif | ||
|
||
# Find all Go source files | ||
GO_SRC_FILES := $(shell powershell -NoProfile -ExecutionPolicy Bypass -Command "Get-ChildItem -Path . -Filter *.go -Recurse | Select-Object -ExpandProperty FullName") | ||
|
||
# Define common PowerShell command | ||
PWSH := @powershell -NoProfile -ExecutionPolicy Bypass -Command | ||
|
||
# Default target | ||
all: bin/git-sizer.exe | ||
|
||
# Main binary target - depend on all Go source files | ||
bin/git-sizer.exe: $(GO_SRC_FILES) | ||
$(PWSH) "if (-not (Test-Path bin)) { New-Item -ItemType Directory -Path bin | Out-Null }" | ||
$(GO) build $(GOFLAGS) -ldflags "$(LDFLAGS)" -a -o .\bin\git-sizer.exe . | ||
|
||
# Test target - explicitly run the build first to ensure binary is up to date | ||
test: | ||
@$(MAKE) -f Makefile.win bin/git-sizer.exe | ||
@$(MAKE) -f Makefile.win gotest | ||
|
||
# Run go tests | ||
gotest: | ||
$(GO) test -timeout 60s $(GOFLAGS) -ldflags "$(LDFLAGS)" ./... | ||
|
||
# Clean up builds | ||
clean: | ||
$(PWSH) "if (Test-Path bin) { Remove-Item -Recurse -Force bin }" | ||
|
||
# Help target | ||
help: | ||
$(PWSH) "Write-Host 'Windows Makefile for git-sizer' -ForegroundColor Cyan" | ||
$(PWSH) "Write-Host ''" | ||
$(PWSH) "Write-Host 'Targets:' -ForegroundColor Green" | ||
$(PWSH) "Write-Host ' all - Build git-sizer (default)'" | ||
$(PWSH) "Write-Host ' test - Run tests'" | ||
$(PWSH) "Write-Host ' clean - Clean build artifacts'" | ||
$(PWSH) "Write-Host ''" | ||
$(PWSH) "Write-Host 'Example usage:' -ForegroundColor Green" | ||
$(PWSH) "Write-Host ' make -f Makefile.win'" | ||
$(PWSH) "Write-Host ' make -f Makefile.win test'" |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env pwsh | ||
|
||
# Exit immediately if any command fails | ||
$ErrorActionPreference = "Stop" | ||
|
||
# Change directory to the parent directory of the script | ||
Set-Location -Path (Split-Path -Parent $PSCommandPath | Split-Path -Parent) | ||
|
||
# Set ROOTDIR environment variable to the current directory | ||
$env:ROOTDIR = (Get-Location).Path | ||
|
||
# Check if the operating system is macOS | ||
if ($IsMacOS) { | ||
brew bundle | ||
} | ||
|
||
# Source the ensure-go-installed.ps1 script | ||
. ./script/ensure-go-installed.ps1 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# This script is meant to be sourced with ROOTDIR set. | ||
|
||
if (-not $env:ROOTDIR) { | ||
$env:ROOTDIR = (Resolve-Path (Join-Path $scriptDir "..")).Path | ||
} | ||
|
||
# Function to check if Go is installed and at least version 1.21 | ||
function GoOk { | ||
$goVersionOutput = & go version 2>$null | ||
if ($goVersionOutput) { | ||
$goVersion = $goVersionOutput -match 'go(\d+)\.(\d+)' | Out-Null | ||
$majorVersion = [int]$Matches[1] | ||
$minorVersion = [int]$Matches[2] | ||
return ($majorVersion -eq 1 -and $minorVersion -ge 21) | ||
} | ||
return $false | ||
} | ||
|
||
# Function to set up a local Go installation if available | ||
function SetUpVendoredGo { | ||
$GO_VERSION = "go1.23.7" | ||
$VENDORED_GOROOT = Join-Path -Path $env:ROOTDIR -ChildPath "vendor/$GO_VERSION/go" | ||
if (Test-Path -Path "$VENDORED_GOROOT/bin/go") { | ||
$env:GOROOT = $VENDORED_GOROOT | ||
$env:PATH = "$env:GOROOT/bin;$env:PATH" | ||
} | ||
} | ||
|
||
# Function to check if Make is installed and install it if needed | ||
function EnsureMakeInstalled { | ||
$makeInstalled = $null -ne (Get-Command "make" -ErrorAction SilentlyContinue) | ||
if (-not $makeInstalled) { | ||
#Write-Host "Installing Make using winget..." | ||
winget install --no-upgrade --nowarn -e --id GnuWin32.Make | ||
if ($LASTEXITCODE -ne 0 -and $LASTEXITCODE -ne 0x8A150061) { | ||
Write-Error "Failed to install Make. Please install it manually. Exit code: $LASTEXITCODE" | ||
} | ||
# Refresh PATH to include the newly installed Make | ||
$env:PATH = [System.Environment]::GetEnvironmentVariable("PATH", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("PATH", "User") | ||
} | ||
|
||
# Add GnuWin32 bin directory directly to the PATH | ||
$gnuWin32Path = "C:\Program Files (x86)\GnuWin32\bin" | ||
if (Test-Path -Path $gnuWin32Path) { | ||
$env:PATH = "$gnuWin32Path;$env:PATH" | ||
} else { | ||
Write-Host "Couldn't find GnuWin32 bin directory at the expected location." | ||
# Also refresh PATH from environment variables as a fallback | ||
$env:PATH = [System.Environment]::GetEnvironmentVariable("PATH", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("PATH", "User") | ||
} | ||
} | ||
|
||
SetUpVendoredGo | ||
|
||
if (-not (GoOk)) { | ||
& ./script/install-vendored-go >$null | ||
if ($LASTEXITCODE -ne 0) { | ||
exit 1 | ||
} | ||
SetUpVendoredGo | ||
} | ||
|
||
# Ensure Make is installed | ||
EnsureMakeInstalled |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Ensure that script errors stop execution | ||
$ErrorActionPreference = "Stop" | ||
|
||
# Determine the root directory of the project. | ||
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path | ||
$ROOTDIR = (Resolve-Path (Join-Path $scriptDir "..")).Path | ||
|
||
# Source the ensure-go-installed functionality. | ||
# (This assumes you have a corresponding PowerShell version of ensure-go-installed. | ||
# If not, you could call the bash version via bash.exe if available.) | ||
$ensureScript = Join-Path $ROOTDIR "script\ensure-go-installed.ps1" | ||
if (Test-Path $ensureScript) { | ||
. $ensureScript | ||
} else { | ||
Write-Error "Unable to locate '$ensureScript'. Please provide a PowerShell version of ensure-go-installed." | ||
} | ||
|
||
# Execute the actual 'go' command with passed arguments. | ||
# This re-invokes the Go tool in PATH. | ||
$goExe = "go" | ||
& $goExe @args |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.