Skip to content

Commit cfaf9e3

Browse files
committed
UpdaterFrame: remove eager git executable check
Unfortunately, on macOS, trying to invoke git (which will be /usr/bin/git on a fresh system) triggers Apple's wonderful "you ran a command line tool for something that isn't installed so we're going to pop a graphical dialog in response" genius tactic, made most famous in our community previously by doing that in response to attempting to breathe on Apple Java's shared library without it being installed. Let's not make it so that every single Mac user is prompted to install the Xcode developer command line tools just to update their ImageJ2. "But Curtis!" you might ask. "What happens if git is not available on a particular system, and you are no longer checking for it up front? Does everything crash and burn?" It turns out everything is OK. What happens is: if you click "Show changes" to pop the diff dialog, then click the "Hex Diff" or "Class File Diff" button, the output pane will show many errors of the form: /Java-8/jars/imagej-updater-0.10.7.jar-20220314155634 java.lang.RuntimeException: java.io.IOException: Cannot run program "git": error=2, No such file or directory at org.scijava.util.ProcessUtils.exec(ProcessUtils.java:135) at org.scijava.util.ProcessUtils.exec(ProcessUtils.java:69) at net.imagej.updater.Diff.showDiff(Diff.java:273) at net.imagej.updater.Diff.showDiff(Diff.java:195) at net.imagej.ui.swing.updater.DiffFile$2.run(DiffFile.java:134) at net.imagej.ui.swing.updater.DiffFile$3.run(DiffFile.java:160) which IMHO is good enough to clue in savvy people that they need git. Because most people won't click on buttons with those labels. If someone complains, we can make the error handling more pleasing then.
1 parent 14958f6 commit cfaf9e3

File tree

1 file changed

+23
-34
lines changed

1 file changed

+23
-34
lines changed

src/main/java/net/imagej/ui/swing/updater/UpdaterFrame.java

Lines changed: 23 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,6 @@ public class UpdaterFrame extends JFrame implements TableModelListener,
123123
// For developers
124124
protected JButton showChanges, rebuildButton;
125125
protected boolean canUpload;
126-
protected final static String gitVersion;
127-
128-
static {
129-
String version = null;
130-
try {
131-
version = ProcessUtils.exec(null, null, null, "git", "--version");
132-
} catch (Throwable t) { /* ignore */ }
133-
gitVersion = version;
134-
}
135126

136127
public UpdaterFrame(final LogService log,
137128
final UploaderService uploaderService, final FilesCollection files)
@@ -339,32 +330,30 @@ public void actionPerformed(final ActionEvent e) {
339330
// includes button to upload to server if is a Developer using
340331
bottomPanel2.add(Box.createRigidArea(new Dimension(15, 0)));
341332

342-
if (gitVersion != null) {
343-
bottomPanel2.add(Box.createRigidArea(new Dimension(15, 0)));
344-
showChanges =
345-
SwingTools.button("Show changes",
346-
"Show the differences to the uploaded version", new ActionListener()
347-
{
348-
349-
@Override
350-
public void actionPerformed(final ActionEvent e) {
351-
new Thread() {
333+
bottomPanel2.add(Box.createRigidArea(new Dimension(15, 0)));
334+
showChanges =
335+
SwingTools.button("Show changes",
336+
"Show the differences to the uploaded version", new ActionListener()
337+
{
352338

353-
@Override
354-
public void run() {
355-
for (final FileObject file : table.getSelectedFiles()) try {
356-
final DiffFile diff = new DiffFile(files, file, Mode.LIST_FILES);
357-
diff.setLocationRelativeTo(UpdaterFrame.this);
358-
diff.setVisible(true);
359-
} catch (MalformedURLException e) {
360-
files.log.error(e);
361-
UpdaterUserInterface.get().error("There was a problem obtaining the remote version of " + file.getLocalFilename(true));
362-
}
339+
@Override
340+
public void actionPerformed(final ActionEvent e) {
341+
new Thread() {
342+
343+
@Override
344+
public void run() {
345+
for (final FileObject file : table.getSelectedFiles()) try {
346+
final DiffFile diff = new DiffFile(files, file, Mode.LIST_FILES);
347+
diff.setLocationRelativeTo(UpdaterFrame.this);
348+
diff.setVisible(true);
349+
} catch (MalformedURLException e) {
350+
files.log.error(e);
351+
UpdaterUserInterface.get().error("There was a problem obtaining the remote version of " + file.getLocalFilename(true));
363352
}
364-
}.start();
365-
}
366-
}, bottomPanel2);
367-
}
353+
}
354+
}.start();
355+
}
356+
}, bottomPanel2);
368357

369358
bottomPanel2.add(Box.createHorizontalGlue());
370359

@@ -610,7 +599,7 @@ protected void showOrHide() {
610599
else bottomPanel2.add(updateSites, 0);
611600

612601
final boolean uploadable = !easyMode && files.hasUploadableSites();
613-
if (showChanges != null) showChanges.setVisible(!easyMode && gitVersion != null);
602+
if (showChanges != null) showChanges.setVisible(!easyMode);
614603
if (rebuildButton != null) rebuildButton.setVisible(uploadable);
615604

616605
easy.setText(easyMode ? "Advanced mode" : "Easy mode");

0 commit comments

Comments
 (0)