GitChapter icon indicating copy to clipboard operation
GitChapter copied to clipboard

Add option to render part of the diff (without the header)

Open EncodePanda opened this issue 6 years ago • 4 comments

When

{{ gitDiff package.yaml }}

Now:

diff --git a/package.yaml b/package.yaml
index 2d9a1e9..37b4b54 100644
--- a/package.yaml
+++ b/package.yaml
@@ -14,6 +14,7 @@ description:         Please see the README on GitHub at 

 dependencies:
 - base >= 4.7 && < 5
+- aeson
 
 library:
   source-dirs: src

What I hope to have

 dependencies:
 - base >= 4.7 && < 5
+- aeson
 
 library:
   source-dirs: src

This could be some sort of option that you have to turn on so that the project stays backward compatible.

Happy to help, please point me to places :)

EncodePanda avatar Dec 28 '19 22:12 EncodePanda

Ha! Something that annoyed me as well - in fact https://stackoverflow.com/questions/47496283/how-do-i-exclude-the-patch-header-with-git-diff!

In terms of actually "fixing" this though, I'm wondering if it's not better to somehow configure a "diff tool" for git using something like git config --global diff.external ... - whether perhaps we can pass this as a parameter or point the user to configure this?

If you want to work around this quickly for now though you could maybe use {{{{ shellOutput ./gitDiffCustom.sh filepath/xyz.txt }}}?

chrissound avatar Dec 30 '19 19:12 chrissound

I have

{{{{ shellOutput git diff HEAD^ HEAD src/EncodePanda/Lens2.hs | sed -e '1,6d' | sed '/^@/d' | sed '/\[-- end snippet\]/d' }}}}

but that only worked till I add next commit is there some way to reference the beginning and end tag?

EncodePanda avatar Dec 15 '20 07:12 EncodePanda

I've managed to make it work with gch-end-2 gch-begin-3 but I'm thinking of it a temp solution. Would love to contribute to the project adding this as an option to diff

EncodePanda avatar Dec 15 '20 07:12 EncodePanda

I think your concern with using the gch-end-*/ghc-begin-* is the hardcoded chapter numbers - if it's something different let me know. In which case possibly a solution would be to reference the current chapter number (this is yet to be implemented) via a shell variable.

For example: ghc-begin-$CHAPTER_INDEX

chrissound avatar Dec 15 '20 09:12 chrissound