diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..99a1b10 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,29 @@ +--- +name: 🐛 Bug Report +about: Create a report to help us improve difi +title: "[BUG] " +labels: bug +assignees: "" +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: + +1. Go to '...' +2. Press keys '...' +3. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Environment (please complete the following information):** + +- OS: [e.g. macOS / Linux / Windows] +- Terminal Emulator: [e.g. iTerm2, Alacritty, tmux] +- Difi Version: [e.g. v0.1.0 or commit hash] + +**Screenshots** +If applicable, add screenshots to help explain your problem. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..404a36d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,16 @@ +--- +name: 🚀 Feature Request +about: Suggest an idea for this project +title: "[FEAT] " +labels: enhancement +assignees: '' +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex: I'm always frustrated when... + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..070da97 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,15 @@ +## Description +Please include a summary of the change and which issue is fixed. + +Fixes # (issue) + +## Type of change +- [ ] 🐛 Bug fix (non-breaking change which fixes an issue) +- [ ] 🚀 New feature (non-breaking change which adds functionality) +- [ ] 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected) +- [ ] 📚 Documentation update + +## Checklist: +- [ ] My code follows the style guidelines of this project (`go fmt ./...`) +- [ ] I have performed a self-review of my own code +- [ ] I have added tests that prove my fix is effective or that my feature works diff --git a/LICENSE b/LICENSE index 7890b20..fab77b9 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2026 Tommy Guo +Copyright (c) 2026 Xiyuan Guo Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 8aa2cfc..16ef86d 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@

- difi + difi_demo

## Why difi? @@ -39,6 +39,20 @@ brew install difi go install github.com/oug-t/difi/cmd/difi@latest ``` +#### AUR (Arch Linux) + +**Binary (pre-built):** + +```bash +pikaur -S difi-bin +``` + +**Build from source:** + +```bash +pikaur -S difi +``` + #### Manual (Linux / Windows) - Download the binary from Releases and add it to your `$PATH`. @@ -107,6 +121,22 @@ Get the ultimate review experience with **[difi.nvim](https://github.com/oug-t/d

(back to top)

+## Git Integration + +To use `difi` as a native git command (e.g., `git difi`), add it as an alias in your global git config: + +```bash +git config --global alias.difi '!difi' +``` + +Now you can run it directly from git: + +```bash +git difi +``` + +

(back to top)

+ ## Contributing ```bash diff --git a/cmd/difi/main.go b/cmd/difi/main.go index 4ee1af0..12e5235 100644 --- a/cmd/difi/main.go +++ b/cmd/difi/main.go @@ -32,7 +32,7 @@ func main() { os.Exit(0) } - target := "main" + target := "HEAD" if flag.NArg() > 0 { target = flag.Arg(0) } diff --git a/internal/ui/model.go b/internal/ui/model.go index 265de41..acaeed1 100644 --- a/internal/ui/model.go +++ b/internal/ui/model.go @@ -13,6 +13,7 @@ import ( "github.com/charmbracelet/bubbles/viewport" tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/lipgloss" + "github.com/charmbracelet/x/ansi" "github.com/oug-t/difi/internal/config" "github.com/oug-t/difi/internal/git" @@ -416,7 +417,7 @@ func (m *Model) updateSizes() { } m.fileList.SetSize(treeWidth, listHeight) - m.diffViewport.Width = m.width - treeWidth - 2 + m.diffViewport.Width = m.width - treeWidth - 4 // border (2) + padding (2) from tree pane m.diffViewport.Height = listHeight } @@ -469,8 +470,14 @@ func (m Model) View() string { end = len(m.diffLines) } + // 5 for line number (Width 4 + MarginRight 1), 2 for indent + maxLineWidth := m.diffViewport.Width - 7 + if maxLineWidth < 1 { + maxLineWidth = 1 + } + for i := start; i < end; i++ { - line := m.diffLines[i] + line := ansi.Truncate(m.diffLines[i], maxLineWidth, "") var numStr string mode := "relative"