jesseduffield / lazygit

simple terminal UI for git commands
MIT License
47.94k stars 1.72k forks source link

Custom-Commands-Compendium should update due to api break change #3651

Open yam-liu opened 3 weeks ago

yam-liu commented 3 weeks ago

Describe the bug RefName doesn't exist anymore. But the Custom-Commands-Compendium style refer the old name. Changes in this commit: https://github.com/jesseduffield/lazygit/commit/6afcc5bda8bbe9d9976fd50740564fe201c3ea41

When running custom commands, we will get this error:

template: template:1:50: executing "template" at <.SelectedRemote.RefName>: can't evaluate field RefName in type *custom_commands.Remote

To Reproduce no need.

Expected behavior Fix the Doc.

Screenshots no need.

Version info: no need.

Additional context no need.

stefanhaller commented 3 weeks ago

Thanks for the report.

This is funny, the point of 6afcc5b was to guard against breaking changes, not to introduce one. We should probably rather fix the code than the docs.

The breaking change was introduced because I wasn't aware that niladic methods are candidates for template substitution. In 6afcc5b I only dealt with the fields of the model structs, but not the getters. This should simply be added.

That said, RefName doesn't really make sense to me as a getter for a remote's name. It was added in 7561f5aa323 in an attempt to make it possible to diff things against a remote, but that strikes me as a mistake; it doesn't work, trying to do this results in fatal: bad revision '<RemoteName>' being shown in the diff view.

OK, I changed my mind, we should fix the docs and not the code. 😄

Custom-Commands-Compendium is a Wiki page, anybody can just change it. I just did it for this case.