@NotNull private Pair<String, String> getUserNameAndEmailFromGitConfig( @NotNull Project project, @NotNull VirtualFile root) throws VcsException { String name = GitConfigUtil.getValue(project, root, GitConfigUtil.USER_NAME); String email = GitConfigUtil.getValue(project, root, GitConfigUtil.USER_EMAIL); return Pair.create(name, email); }
@Nullable private VcsUser readCurrentUser(@NotNull Project project, @NotNull VirtualFile root) throws VcsException { String userName = GitConfigUtil.getValue(project, root, GitConfigUtil.USER_NAME); String userEmail = StringUtil.notNullize(GitConfigUtil.getValue(project, root, GitConfigUtil.USER_EMAIL)); return userName == null ? null : myFactory.createUser(userName, userEmail); }
/** * Setup remotes combobox. The default remote for the current branch is selected by default. * * @param project the project * @param root the git root * @param currentBranch the current branch * @param remoteCombobox the combobox to update * @param fetchUrl if true, the fetch url is shown for remotes, push otherwise */ public static void setupRemotes( final Project project, final VirtualFile root, final String currentBranch, final JComboBox remoteCombobox, final boolean fetchUrl) { try { List<GitDeprecatedRemote> remotes = GitDeprecatedRemote.list(project, root); String remote = null; if (currentBranch != null) { remote = GitConfigUtil.getValue(project, root, "branch." + currentBranch + ".remote"); } remoteCombobox.setRenderer( getGitRemoteListCellRenderer(remote, fetchUrl, remoteCombobox.getRenderer())); GitDeprecatedRemote toSelect = null; remoteCombobox.removeAllItems(); for (GitDeprecatedRemote r : remotes) { remoteCombobox.addItem(r); if (r.name().equals(remote)) { toSelect = r; } } if (toSelect != null) { remoteCombobox.setSelectedItem(toSelect); } } catch (VcsException e) { GitVcs.getInstance(project) .showErrors(Collections.singletonList(e), GitBundle.getString("pull.retrieving.remotes")); } }
@NotNull private static GitUpdater getDefaultUpdaterForBranch( @NotNull Project project, @NotNull Git git, @NotNull VirtualFile root, @NotNull Map<VirtualFile, GitBranchPair> trackedBranches, @NotNull ProgressIndicator progressIndicator, @NotNull UpdatedFiles updatedFiles) { try { GitLocalBranch branch = GitBranchUtil.getCurrentBranch(project, root); boolean rebase = false; if (branch != null) { String rebaseValue = GitConfigUtil.getValue(project, root, "branch." + branch.getName() + ".rebase"); rebase = rebaseValue != null && rebaseValue.equalsIgnoreCase("true"); } if (rebase) { return new GitRebaseUpdater( project, git, root, trackedBranches, progressIndicator, updatedFiles); } } catch (VcsException e) { LOG.info("getDefaultUpdaterForBranch branch", e); } return new GitMergeUpdater( project, git, root, trackedBranches, progressIndicator, updatedFiles); }