Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

diff-so-fancy 0.3.0 (new formula) #49040

Closed
wants to merge 10 commits into from
32 changes: 32 additions & 0 deletions Library/Formula/diff-so-fancy.rb
@@ -0,0 +1,32 @@
class DiffSoFancy < Formula
desc "builds on the good-lookin' output of diff-highlight"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the desc to "Good-lookin' diffs with diff-highlight and more" on npm and "Unfancy git-diff" on GitHub

homepage "https://github.com/stevemao/diff-so-fancy"
url "https://github.com/stevemao/diff-so-fancy/archive/v0.1.2.tar.gz"
sha256 "fa4ac51368ba6b942c6b346117e5f72cabb00ea3c29f834e3c4ca80972e19502"

depends_on "gnu-sed"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Run time or just build time?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, run time, looking at the inreplace below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, run time. The inreplace avoids need for default names install flag, and avoids issues if already installed without it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good to make a feature request to be able to use BSD sed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MikeMcQuaid Not likely to be worked on/accepted, the author (@paulirish) says in so-fancy/diff-so-fancy#25 "OS X sed is crap".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disappointing but: thanks.


def install
prefix.install Dir["*"]
inreplace "#{prefix}/diff-so-fancy", "sed", "gsed"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'll be a little cleaner to do this before you install it, and we'd prefer it to be tucked in libexec and symlinked from there ideally:

# Short explanation like: requires functionality not offered by BSD sed.
inreplace "diff-so-fancy", "sed", "gsed"
libexec.install Dir["*"]
bin.install_symlink libexec/"diff-so-fancy"

bin.install_symlink "#{prefix}/diff-so-fancy"
end

def caveats; <<-EOS.undent
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless these are Homebrew-specific we prefer not to include them. People should reference upstream for general usage.

You probably now want to configure git to fancify all your diffs. Run:
git config --global core.pager "diff-so-fancy | less --tabs=1,5 -R"

so that `git diff` will use it. You can still bypass with `git --no-pager diff`.

You may also want some fancier colours. Consider trying:
git config --global color.diff-highlight.oldNormal "red bold"
git config --global color.diff-highlight.oldHighlight "red bold 52"
git config --global color.diff-highlight.newNormal "green bold"
git config --global color.diff-highlight.newHighlight "green bold 22"
EOS
end

test do
system "diff-so-fancy"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

system bin/"diff-so-fancy"

end
end