mirror of
https://github.com/initialcommit-com/git-sim.git
synced 2026-04-27 03:25:53 +03:00
[PR #98] [MERGED] Support font files as well as font names for the --font flag. #96
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/git-sim#96
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/initialcommit-com/git-sim/pull/98
Author: @ehmatthes
Created: 7/16/2023
Status: ✅ Merged
Merged: 7/17/2023
Merged by: @initialcommit-io
Base:
dev← Head:support_font_files📝 Commits (6)
645c20cSupport local font files for --font flag.6ab291bHandles both font names and font files.9b2545cUses contextlib.nullcontext instead of if block.c6b47a9Tests use local font file; regenerated reference files.588477aFixed message showing full test command.6533685Formatted using Black.📊 Changes
23 files changed (+34 additions, -6 deletions)
View changed files
📝
src/git_sim/__main__.py(+20 -1)📝
src/git_sim/commands.py(+2 -1)📝
src/git_sim/settings.py(+1 -0)➕
tests/e2e_tests/ProggyClean.ttf(+0 -0)📝
tests/e2e_tests/reference_files/git-sim-add.png(+0 -0)📝
tests/e2e_tests/reference_files/git-sim-branch.png(+0 -0)📝
tests/e2e_tests/reference_files/git-sim-checkout.png(+0 -0)📝
tests/e2e_tests/reference_files/git-sim-cherry_pick.png(+0 -0)📝
tests/e2e_tests/reference_files/git-sim-clean.png(+0 -0)📝
tests/e2e_tests/reference_files/git-sim-commit.png(+0 -0)📝
tests/e2e_tests/reference_files/git-sim-log.png(+0 -0)📝
tests/e2e_tests/reference_files/git-sim-merge.png(+0 -0)📝
tests/e2e_tests/reference_files/git-sim-mv.png(+0 -0)📝
tests/e2e_tests/reference_files/git-sim-rebase.png(+0 -0)📝
tests/e2e_tests/reference_files/git-sim-reset.png(+0 -0)📝
tests/e2e_tests/reference_files/git-sim-restore.png(+0 -0)📝
tests/e2e_tests/reference_files/git-sim-revert.png(+0 -0)📝
tests/e2e_tests/reference_files/git-sim-rm.png(+0 -0)📝
tests/e2e_tests/reference_files/git-sim-stash.png(+0 -0)📝
tests/e2e_tests/reference_files/git-sim-status.png(+0 -0)...and 3 more files
📄 Description
This PR adds support for font files as well as named fonts. Now both of these commands work:
The motivation for this is to address cross-platform testing inconsistencies. There are likely very few end users who would want to run git-sim against a local font file, although as I write that out I start to see use cases. git-sim is quite scriptable, so I could see someone writing a script to generate a series of images or animations, and bundling a font file in order to generate consistent output across different systems.
There are some things to consider before merging this:
fonttoolspackage, used in __main__.py to pull the name of the font from the font file. I did not add this requirement to pyproject.toml.get_font_name(). It's currently in __main__.py.fontis used. It can be a path, it can be a named font, it can be a kind of font. I didn't want to mess with any existing usage, so I made a new setting calledfont_context. This is set in __main__.py as either a call tom.register_font(), or as a null context. This makes a nice clean change to commands.py, where the call to_handle_animations()is either run in a context that has access to the local font file, or a null context where all behavior is as it was before this PR. There's no need to change any of the individual command files. I was not sure exactly what type to assign tofont_context; I choseboolbecause I don't thinkregister_font()returns anything. It works, but maybe there's a more precise type for it?get_cmd_parts()in e2e_tests/utils.py needed a bit of reworking, becausegit-simis now in the command itself and in the path to the font file. I added a diagnostic print call to show the full test command. You can copy this command, cd to the sample repo, and run this command to see all the output a user would see when running the command. This is really helpful when troubleshooting the test suite itself, and failed tests.compare_images(), and it wouldn't do anything to address cross-platform issues caused by different fonts.I doubt this is ready to merge as is, although the remaining work should be a matter of refinement. I think it's worth making the test output consistent if you want the test suite to be useful.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.