-
-
Notifications
You must be signed in to change notification settings - Fork 12.6k
/
Copy pathgit.rb
217 lines (181 loc) · 7.7 KB
/
git.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
class Git < Formula
desc "Distributed revision control system"
homepage "https://git-scm.com"
url "https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.48.1.tar.xz"
sha256 "1c5d545f5dc1eb51e95d2c50d98fdf88b1a36ba1fa30e9ae5d5385c6024f82ad"
license "GPL-2.0-only"
head "https://github.com/git/git.git", branch: "master"
livecheck do
url "https://mirrors.edge.kernel.org/pub/software/scm/git/"
regex(/href=.*?git[._-]v?(\d+(?:\.\d+)+)\.t/i)
end
bottle do
sha256 arm64_sequoia: "93411cd96da6dceec87bf10ebbd97d28f175628bef0cb277ca9609c2cff37569"
sha256 arm64_sonoma: "eddc3aeee81a51722bd6e4b6474146b3ee01dea958298604abbef7082578d735"
sha256 arm64_ventura: "8e6df03005d01a9059910399c38f00f3d1e548f3bf7634ee0aae4fb59e95d349"
sha256 sonoma: "714f0ac2810a192f985ac3c56a761da485f584b46bc224b84e4d320fefbaae89"
sha256 ventura: "4adaf7973e9079c6f2a5aa5696fb8eb60f5dbe0b036db05107a0f340b9aff8bf"
sha256 x86_64_linux: "a21df5a7f11b40ff4f0600e8e7c73b9703cf23cb47ab2db52e27fe2a0e73d97b"
end
depends_on "gettext"
depends_on "pcre2"
uses_from_macos "curl", since: :catalina # macOS < 10.15.6 has broken cert path logic
uses_from_macos "expat"
uses_from_macos "zlib", since: :high_sierra
on_linux do
depends_on "openssl@3" # Uses CommonCrypto on macOS
end
resource "html" do
url "https://mirrors.edge.kernel.org/pub/software/scm/git/git-htmldocs-2.48.1.tar.xz"
sha256 "5450321b7de6702f9ec0a41108dfac3626afeb8fdd575b3d9a78febfaa96315c"
livecheck do
formula :parent
end
end
resource "man" do
url "https://mirrors.edge.kernel.org/pub/software/scm/git/git-manpages-2.48.1.tar.xz"
sha256 "4c0ede7afa4d6dbf602d2f2fd151c36ab57d3224e6b9fd17342e85f05d386886"
livecheck do
formula :parent
end
end
resource "Net::SMTP::SSL" do
url "https://cpan.metacpan.org/authors/id/R/RJ/RJBS/Net-SMTP-SSL-1.04.tar.gz"
sha256 "7b29c45add19d3d5084b751f7ba89a8e40479a446ce21cfd9cc741e558332a00"
end
def install
odie "html resource needs to be updated" if build.stable? && version != resource("html").version
odie "man resource needs to be updated" if build.stable? && version != resource("man").version
# If these things are installed, tell Git build system not to use them
ENV["NO_FINK"] = "1"
ENV["NO_DARWIN_PORTS"] = "1"
ENV["PYTHON_PATH"] = which("python3")
ENV["PERL_PATH"] = which("perl")
ENV["USE_LIBPCRE2"] = "1"
ENV["INSTALL_SYMLINKS"] = "1"
ENV["LIBPCREDIR"] = Formula["pcre2"].opt_prefix
ENV["V"] = "1" # build verbosely
perl_version = Utils.safe_popen_read("perl", "--version")[/v(\d+\.\d+)(?:\.\d+)?/, 1]
if OS.mac?
ENV["PERLLIB_EXTRA"] = %W[
#{MacOS.active_developer_dir}
/Library/Developer/CommandLineTools
/Applications/Xcode.app/Contents/Developer
].uniq.map do |p|
"#{p}/Library/Perl/#{perl_version}/darwin-thread-multi-2level"
end.join(":")
end
# The git-gui and gitk tools are installed by a separate formula (git-gui)
# to avoid a dependency on tcl-tk and to avoid using the broken system
# tcl-tk (see https://github.com/Homebrew/homebrew-core/issues/36390)
# This is done by setting the NO_TCLTK make variable.
args = %W[
prefix=#{prefix}
sysconfdir=#{etc}
CC=#{ENV.cc}
CFLAGS=#{ENV.cflags}
LDFLAGS=#{ENV.ldflags}
NO_TCLTK=1
]
args += if OS.mac?
%w[NO_OPENSSL=1 APPLE_COMMON_CRYPTO=1]
else
openssl_prefix = Formula["openssl@3"].opt_prefix
%W[NO_APPLE_COMMON_CRYPTO=1 OPENSSLDIR=#{openssl_prefix}]
end
# Make sure `git` looks in `opt_prefix` instead of the Cellar.
# Otherwise, Cellar references propagate to generated plists from `git maintenance`.
inreplace "Makefile", /(-DFALLBACK_RUNTIME_PREFIX=")[^"]+/, "\\1#{opt_prefix}"
system "make", "install", *args
git_core = libexec/"git-core"
rm git_core/"git-svn"
# Install the macOS keychain credential helper
if OS.mac?
cd "contrib/credential/osxkeychain" do
system "make", "CC=#{ENV.cc}",
"CFLAGS=#{ENV.cflags}",
"LDFLAGS=#{ENV.ldflags}"
git_core.install "git-credential-osxkeychain"
system "make", "clean"
end
end
# Generate diff-highlight perl script executable
cd "contrib/diff-highlight" do
system "make"
end
# Install the netrc credential helper
cd "contrib/credential/netrc" do
system "make", "test"
git_core.install "git-credential-netrc"
end
# Install git-subtree
cd "contrib/subtree" do
system "make", "CC=#{ENV.cc}",
"CFLAGS=#{ENV.cflags}",
"LDFLAGS=#{ENV.ldflags}"
git_core.install "git-subtree"
end
# install the completion script first because it is inside "contrib"
bash_completion.install "contrib/completion/git-completion.bash"
bash_completion.install "contrib/completion/git-prompt.sh"
zsh_completion.install "contrib/completion/git-completion.zsh" => "_git"
cp "#{bash_completion}/git-completion.bash", zsh_completion
(share/"git-core").install "contrib"
# We could build the manpages ourselves, but the build process depends
# on many other packages, and is somewhat crazy, this way is easier.
man.install resource("man")
(share/"doc/git-doc").install resource("html")
# Make html docs world-readable
chmod 0644, Dir["#{share}/doc/git-doc/**/*.{html,txt}"]
chmod 0755, Dir["#{share}/doc/git-doc/{RelNotes,howto,technical}"]
# git-send-email needs Net::SMTP::SSL or Net::SMTP >= 2.34
resource("Net::SMTP::SSL").stage do
(share/"perl5").install "lib/Net"
end
# This is only created when building against system Perl, but it isn't
# purged by Homebrew's post-install cleaner because that doesn't check
# "Library" directories. It is however pointless to keep around as it
# only contains the perllocal.pod installation file.
perl_dir = prefix/"Library/Perl"
rm_r perl_dir if perl_dir.exist?
# Set the macOS keychain credential helper by default
# (as Apple's CLT's git also does this).
if OS.mac?
(buildpath/"gitconfig").write <<~EOS
[credential]
\thelper = osxkeychain
EOS
etc.install "gitconfig"
end
end
def caveats
<<~EOS
The Tcl/Tk GUIs (e.g. gitk, git-gui) are now in the `git-gui` formula.
Subversion interoperability (git-svn) is now in the `git-svn` formula.
EOS
end
test do
system bin/"git", "init"
%w[haunted house].each { |f| touch testpath/f }
system bin/"git", "add", "haunted", "house"
system bin/"git", "config", "user.name", "'A U Thor'"
system bin/"git", "commit", "-a", "-m", "Initial Commit"
assert_equal "haunted\nhouse", shell_output("#{bin}/git ls-files").strip
# Check that our `inreplace` for the `Makefile` does not break.
# If this assertion fails, please fix the `inreplace` instead of removing this test.
# The failure of this test means that `git` will generate broken launchctl plist files.
refute_match HOMEBREW_CELLAR.to_s, shell_output("#{bin}/git --exec-path")
return unless OS.mac?
# Check Net::SMTP or Net::SMTP::SSL works for git-send-email
%w[foo bar].each { |f| touch testpath/f }
system bin/"git", "add", "foo", "bar"
system bin/"git", "commit", "-a", "-m", "Second Commit"
assert_match "Authentication Required", pipe_output(
"#{bin}/git send-email [email protected] [email protected] " \
"--smtp-server=smtp.gmail.com --smtp-server-port=587 " \
"--smtp-encryption=tls --confirm=never HEAD^ 2>&1",
)
end
end