/** * Checks Git version and updates the myVersion variable. In the case of exception or unsupported * version reports the problem. Note that unsupported version is also applied - some functionality * might not work (we warn about that), but no need to disable at all. */ public void checkVersion() { final String executable = myAppSettings.getPathToGit(); try { myVersion = GitVersion.identifyVersion(executable); if (!myVersion.isSupported()) { log.info("Unsupported Git version: " + myVersion); final String SETTINGS_LINK = "settings"; final String UPDATE_LINK = "update"; String message = String.format( "The <a href='" + SETTINGS_LINK + "'>configured</a> version of Git is not supported: %s.<br/> " + "The minimal supported version is %s. Please <a href='" + UPDATE_LINK + "'>update</a>.", myVersion, GitVersion.MIN); VcsNotifier.getInstance(myProject) .notifyError( "Unsupported Git version", message, new NotificationListener.Adapter() { @Override protected void hyperlinkActivated( @NotNull Notification notification, @NotNull HyperlinkEvent e) { if (SETTINGS_LINK.equals(e.getDescription())) { ShowSettingsUtil.getInstance() .showSettingsDialog(myProject, getConfigurable().getDisplayName()); } else if (UPDATE_LINK.equals(e.getDescription())) { BrowserUtil.browse("http://git-scm.com"); } } }); } } catch (Exception e) { if (getExecutableValidator() .checkExecutableAndNotifyIfNeeded()) { // check executable before notifying error final String reason = (e.getCause() != null ? e.getCause() : e).getMessage(); String message = GitBundle.message("vcs.unable.to.run.git", executable, reason); if (!myProject.isDefault()) { showMessage(message, ConsoleViewContentType.SYSTEM_OUTPUT.getAttributes()); } VcsBalloonProblemNotifier.showOverVersionControlView(myProject, message, MessageType.ERROR); } } }
public static boolean testGitExecutable(final Project project) { final GitVcsApplicationSettings settings = GitVcsApplicationSettings.getInstance(); final String executable = settings.getPathToGit(); final GitVersion version; try { version = GitVersion.identifyVersion(executable); } catch (Exception e) { Messages.showErrorDialog( project, e.getMessage(), GitBundle.getString("find.git.error.title")); return false; } if (!version.isSupported()) { Messages.showWarningDialog( project, GitBundle.message("find.git.unsupported.message", version.toString(), GitVersion.MIN), GitBundle.getString("find.git.success.title")); return false; } return true; }
public static void assumeSupportedGitVersion(@NotNull GitVcs vcs) { GitVersion version = vcs.getVersion(); assumeTrue("Unsupported Git version: " + version, version.isSupported()); }