Skip to content

Latest commit

 

History

History
332 lines (242 loc) · 8.6 KB

File metadata and controls

332 lines (242 loc) · 8.6 KB

🔄 Git Commit Integration Guide

Your Work Log CLI now has git-standup style integration that automatically pulls your commits when you end your work day!

✨ What's New

The script now:

  • ✅ Automatically detects git commits from your work start time
  • ✅ Pulls commit hash, message, and timestamp
  • ✅ Adds them to a dedicated "## Git Commits" section
  • ✅ Shows a beautiful Rich table with traffic light colors
  • ✅ Works with any git repository in the current directory

🚀 How It Works

1. Start Your Day

Linux:

python worklog_cli.py start

Windows 11:

python worklog_cli.py start

This captures your work start time (e.g., 09:00).

2. Work & Commit Normally

Make your commits throughout the day as usual:

Linux:

git commit -m "feat: implement OAuth token refresh (AUTH-123)"
git commit -m "fix: resolve cart calculation bug (BUG-456)"
git commit -m "docs: update API documentation"

Windows 11:

git commit -m "feat: implement OAuth token refresh (AUTH-123)"
git commit -m "fix: resolve cart calculation bug (BUG-456)"
git commit -m "docs: update API documentation"

3. End Your Day

Linux:

python worklog_cli.py end

Windows 11:

python worklog_cli.py end

The script will automatically:

  1. Calculate your total work hours
  2. 🔍 Scan the git repository for commits since your start time
  3. Extract commit hash, time, and message
  4. Add them to your daily log in a new "## Git Commits" section
  5. Show a beautiful table with your commits

📊 Example Output

╔═══════════════════════════╗
║ 🏁 Ending Work Day        ║
╚═══════════════════════════╝

🔍 Checking for git commits...

┏━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
│ Time   │ Hash    │ Message                                      │
┡━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ 09:30  │ a3f2d1b │ feat: implement OAuth token refresh (AUTH... │
│ 11:45  │ e7c8a9f │ fix: resolve cart calculation bug (BUG-456)  │
│ 14:20  │ b2d4e6c │ docs: update API documentation               │
│ 16:30  │ 9f1a3c5 │ test: add integration tests for auth flow    │
└────────┴─────────┴──────────────────────────────────────────────┘

✅ Added 4 commit(s) to work log

✅ Work day completed

🕐 Start: 09:00
🕐 End: 17:00
⏱️  Total: 8.00h

📝 In Your Daily Log

The commits are added to your markdown file:

---

## Git Commits

| Time  | Hash      | Commit Message                                    |
|-------|-----------|---------------------------------------------------|
| 09:30 | `a3f2d1b` | feat: implement OAuth token refresh (AUTH-123)    |
| 11:45 | `e7c8a9f` | fix: resolve cart calculation bug (BUG-456)       |
| 14:20 | `b2d4e6c` | docs: update API documentation                    |
| 16:30 | `9f1a3c5` | test: add integration tests for auth flow         |

---

## Tags
#work-log #sprint-14

⚙️ Configuration

Enable/Disable Git Integration

Edit the FEATURE_FLAGS in worklog_cli.py:

FEATURE_FLAGS = {
    "git_integration": True,  # Set to False to disable
    # ... other flags
}

How Commits Are Retrieved

The script runs this git command:

Linux:

git log --since="<your-work-start-time>" --pretty=format:%h|%ai|%s --no-merges

Windows 11:

git log --since="<your-work-start-time>" --pretty=format:%h|%ai|%s --no-merges

Where:

  • %h = Short commit hash (7 characters)
  • %ai = Author date in ISO 8601 format (for timestamp)
  • %s = Commit subject (message)
  • --no-merges = Excludes merge commits

Time Range

  • Start: Your work_start time from the daily log
  • End: When you run worklog end
  • Fallback: If no start time found, uses midnight (00:00)

🎯 Benefits

  1. No Manual Entry - Commits are pulled automatically
  2. Accurate Timeline - Shows exactly when you committed
  3. Task Correlation - Easy to match commits to work items (AUTH-123, etc.)
  4. Weekly Reports - Your git activity is now part of your shareable logs
  5. Performance Reviews - Clear record of code contributions

🔧 Troubleshooting

"No git commits found for today"

Possible causes:

  1. You're not in a git repository
    • Run git status to verify
    • Navigate to your project directory first
  2. No commits since your work start time
    • Linux: Check with: git log --since="09:00" --oneline
    • Windows 11: Check with: git log --since="09:00" --oneline
  3. Git not installed

Git Command Not Found

Linux:

# Check if git is installed
which git

# Install if missing
# Ubuntu/Debian:
sudo apt install git

# Fedora/RHEL:
sudo dnf install git

# Or disable the feature:
FEATURE_FLAGS["git_integration"] = False

Windows 11:

# Check if git is installed
git --version

# Install if missing
# Download from: https://git-scm.com/download/win
# Or use winget:
winget install --id Git.Git -e --source winget

# Or disable the feature:
FEATURE_FLAGS["git_integration"] = False

Wrong Commits Showing Up

The script pulls all commits from the repository since your start time, regardless of author. If you want to filter by author, modify the git command in get_git_commits_today():

cmd = [
    "git", "log",
    f"--since={since_date}",
    "--pretty=format:%h|%ai|%s",
    "--no-merges",
    f"--author={YOUR_NAME}"  # Add this line
]

🎨 Customization Ideas

Add Branch Name

Modify the format to include branch:

"--pretty=format:%h|%d|%ai|%s"

Filter by File Type

Only show commits that touched specific files:

cmd.extend(["--", "*.py"])  # Only Python files

Group by Hour

Add logic to group commits by hour ranges in the log.

🚀 Advanced: Multi-Repo Support

Want to scan multiple repositories? You could modify the script to:

  1. Define repo paths in CONFIG
  2. Loop through each repo
  3. Combine all commits into one table

Example:

CONFIG = {
    "git_repos": [
        "~/projects/frontend",
        "~/projects/backend",
        "~/projects/infrastructure"
    ],
    # ...
}

📈 Integration with Reporting

Your git commits are now part of your work log, so:

  1. Weekly summaries include them automatically
  2. Search by commit hash or message
  3. Share your complete work record with employers
  4. Track productivity - see commit frequency patterns

🎯 Best Practices

  1. Write good commit messages - They'll appear in your work log!
  2. Commit frequently - Better granularity in your timeline
  3. Use conventional commits - feat:, fix:, docs:, etc.
  4. Reference task IDs - Makes correlation easier (AUTH-123)
  5. Review before sharing - Check that commit messages are appropriate

🔗 Example Workflow

Linux:

# Morning
cd ~/projects/my-app
python ~/worklog_cli.py start

# Work and commit throughout the day
git commit -m "feat(auth): implement OAuth (AUTH-123)"
git commit -m "test(auth): add unit tests"
git commit -m "fix(cart): calculation error (BUG-456)"

# Check status anytime
python ~/worklog_cli.py status

# End of day - commits auto-added!
python ~/worklog_cli.py end

# View your log
cat ~/work-logs/26-01-2026.md

Windows 11:

# Morning
cd C:\Users\YourUsername\projects\my-app
python C:\path\to\worklog_cli.py start

# Work and commit throughout the day
git commit -m "feat(auth): implement OAuth (AUTH-123)"
git commit -m "test(auth): add unit tests"
git commit -m "fix(cart): calculation error (BUG-456)"

# Check status anytime
python C:\path\to\worklog_cli.py status

# End of day - commits auto-added!
python C:\path\to\worklog_cli.py end

# View your log
type C:\Users\YourUsername\work-logs\26-01-2026.md

🎉 That's It!

Your work logging is now fully automated with git integration. Every commit you make is automatically tracked and added to your daily log when you end your day.

No more forgetting what you worked on! 🚀