Skip to content

Commit fbdf01e

Browse files
authored
Merge pull request #5 from vo-ecosystem/TECH-5364
Add optional pretty output in .md format
2 parents 9a5ffe6 + f16fad3 commit fbdf01e

4 files changed

Lines changed: 245 additions & 19 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
.env
22
reports/*.json
3+
reports/*.md

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: build run clean rebuild
1+
.PHONY: build run clean rebuild pretty
22

33
build:
44
docker compose build --build-arg USER_ID=$$(id -u) --build-arg GROUP_ID=$$(id -g)
@@ -11,6 +11,10 @@ run:
1111

1212
scan: build run
1313

14+
# Run with pretty table output
15+
pretty: build
16+
UID=$$(id -u) GID=$$(id -g) docker compose run --rm github-scanner --pretty
17+
1418
clean:
1519
docker compose down
1620
rm -rf reports/

README.md

Lines changed: 56 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Dockerized tool to scan GitHub organizations for repository health metrics. Opti
66

77
- **Orphaned Branch Detection**: Identifies branches without open PRs (includes merged/closed PR branches)
88
- **Old PR Analysis**: Configurable threshold for identifying stale pull requests
9+
- **Pretty-Print Table Format**: Human-friendly table output for stale PRs and orphaned branches
910
- **Performance Optimized**: Efficient API usage for large organizations (100+ repos)
1011
- **Progress Tracking**: Real-time progress indicators during scanning
1112
- **Comprehensive Reporting**: Both console summary and detailed JSON reports
@@ -62,7 +63,8 @@ To create a GitHub Personal Access Token with minimal required permissions:
6263

6364
3. Run the scanner:
6465
```bash
65-
make scan # Build and run
66+
make scan # Build and run (JSON output)
67+
make pretty # Build and run with pretty table output
6668
make fresh # Force rebuild and run
6769
make build # Build only
6870
make clean # Clean up
@@ -75,12 +77,18 @@ By default, the scanner analyzes all repositories in an organization. You can sc
7577
### Usage Examples
7678

7779
```bash
78-
# Scan entire organization (default)
80+
# Scan entire organization (default JSON output)
7981
make fresh
8082

83+
# Scan with pretty table output
84+
make pretty
85+
8186
# Scan only a specific repository
8287
GITHUB_REPO=my-repo-name make fresh
8388

89+
# Scan specific repository with pretty output
90+
GITHUB_REPO=my-repo-name make pretty
91+
8492
# Or set it in your .env file
8593
echo "GITHUB_REPO=my-repo-name" >> .env
8694
make fresh
@@ -120,7 +128,8 @@ make fresh
120128

121129
| Command | Description |
122130
|---------|-------------|
123-
| `make scan` | Build and run scanner |
131+
| `make scan` | Build and run scanner (JSON output) |
132+
| `make pretty` | Build and run with pretty table output |
124133
| `make build` | Build Docker image |
125134
| `make rebuild` | Force rebuild (no cache) |
126135
| `make run` | Run existing image |
@@ -147,21 +156,30 @@ make fresh
147156

148157
## Output
149158

150-
### Console Output
159+
### Console Output (Default)
151160

152161
- **Progress tracking**: Real-time scanning progress
153162
- **Problem repos only**: Shows only repositories with issues
154163
- **Clean summary**: Total repos, active repos, repos with issues, total open PRs
155164
- **Issue details**: Branch counts, orphaned branches, old PR counts
156165

157-
### JSON Reports
166+
### Pretty Table Output (with `-p` or `--pretty` flag)
167+
168+
- **Human-friendly table**: Formatted table with stale PRs and orphaned branches
169+
- **Detailed information**: Repository, type (Stale PR/Orphaned Branch), item name, user/author, age, and direct link
170+
- **Easy to read**: Perfect for manual review and sharing with team members
171+
- **Includes summary**: Still shows the standard summary statistics
172+
- **Markdown report**: Saves to `./reports/scan_{org}_{timestamp}.md` with formatted tables and clickable links
173+
174+
### JSON Reports (default output)
158175

159176
- **Location**: `./reports/scan_{org}_{timestamp}.json`
160177
- **Complete data**: All repositories with full metrics
161178
- **Stale branches**: Complete list of orphaned branches (no limits)
162179
- **Structured format**: Easy to parse and analyze
180+
- **Generated when**: Running without `--pretty` flag
163181

164-
### Example Console Output
182+
### Example Console Output (Default)
165183

166184
```
167185
============================================================
@@ -186,6 +204,38 @@ SUMMARY:
186204
============================================================
187205
```
188206

207+
### Example Pretty Table Output (Console)
208+
209+
```
210+
====================================================================================================
211+
DETAILED REPORT - STALE PRs AND ORPHANED BRANCHES
212+
====================================================================================================
213+
214+
Repository | Type | Item | User/Author | Age | Link
215+
----------------------------------------------------------------------------------------------------
216+
my-backend-api | Stale PR | PR #123 | john.doe | 45 days | https://github.com/org/my-backend-api/pull/123
217+
my-backend-api | Orphaned Branch | feature/old-feature | jane.smith | - | https://github.com/org/my-backend-api/tree/feature/old-feature
218+
frontend-app | Stale PR | PR #87 | bob.jones | 62 days | https://github.com/org/frontend-app/pull/87
219+
frontend-app | Orphaned Branch | bugfix/legacy-fix | alice.williams | - | https://github.com/org/frontend-app/tree/bugfix/legacy-fix
220+
221+
Total items: 4
222+
====================================================================================================
223+
```
224+
225+
### Example Markdown Report (`.md` file)
226+
227+
The Markdown report includes:
228+
- **Header**: Organization/repo name, scan time, threshold settings
229+
- **Summary section**: Key metrics (total repos, active repos, repos with issues, total PRs)
230+
- **Stale PRs and Orphaned Branches table**: Formatted Markdown table with clickable links
231+
- **Repository Details section**: Detailed breakdown of each problematic repository
232+
233+
The Markdown file can be:
234+
- Viewed directly in GitHub with proper formatting
235+
- Shared with team members via email or chat
236+
- Converted to PDF or other formats
237+
- Included in documentation or reports
238+
189239
## Security
190240

191241
- **Docker isolation**: Runs in isolated container environment

0 commit comments

Comments
 (0)