Skip to content

Port diff_tool.py to Go#2

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/port-diff-tool-to-golang
Draft

Port diff_tool.py to Go#2
Copilot wants to merge 3 commits intomainfrom
copilot/port-diff-tool-to-golang

Conversation

Copy link

Copilot AI commented Mar 18, 2026

Reimplements diff_tool.py in Go with identical runtime behavior: reads config.json, loads a language file, prompts interactively for target repo / commit range / output path, diffs changed files, and writes a syntax-highlighted .docx report.

Library mapping

Python Go
python-docx github.com/fumiama/go-docx
pygments github.com/alecthomas/chroma/v2
difflib.SequenceMatcher github.com/sergi/go-diff/diffmatchpatch (line-mode)
pathspec github.com/sabhiram/go-gitignore
PIL stdlib image

Key implementation notes

  • Config defaults pre-populated before json.Unmarshal so absent keys behave exactly as Python's config.get(key, default).
  • Pygments → Chroma style mapping: "default" is remapped to "pygments" (chroma's equivalent).
  • Cell borders: Python's parse_xml-based border removal is replicated by setting WTableBorder{Val: "nil"} on specific sides of each WTableCellProperties.TableBorders.
  • Empty tree SHA: 4b825dc642cb6eb9a060e54bf8d69288fbee4904 used when include_first_commit=true and commit1 is the repo's root commit, so all lines appear as additions.
  • open_after_creation: cross-platform (cmd /c start / open / xdg-open).
  • xml:space="preserve" set on every <w:t> node to retain code indentation in the generated document.
Original prompt

port the diff_tool.py to golang with exactly the same behavior

The user has attached the following files from their workspace:

  • diff_tool.py

📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

Copilot AI and others added 2 commits March 18, 2026 20:21
Co-authored-by: TD99 <7207296+TD99@users.noreply.github.com>
Co-authored-by: TD99 <7207296+TD99@users.noreply.github.com>
Copilot AI changed the title [WIP] Port diff_tool.py to Go with same behavior Port diff_tool.py to Go Mar 18, 2026
Copilot AI requested a review from TD99 March 18, 2026 20:23
Copilot finished work on behalf of TD99 March 18, 2026 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants