use of org.eclipse.jgit.lib.PersonIdent in project archi-modelrepository-plugin by archi-contribs.
the class ArchiRepository method getUserDetails.
@Override
public PersonIdent getUserDetails() throws IOException {
try (Git git = Git.open(getLocalRepositoryFolder())) {
StoredConfig config = git.getRepository().getConfig();
String name = StringUtils.safeString(config.getString(ConfigConstants.CONFIG_USER_SECTION, null, ConfigConstants.CONFIG_KEY_NAME));
String email = StringUtils.safeString(config.getString(ConfigConstants.CONFIG_USER_SECTION, null, ConfigConstants.CONFIG_KEY_EMAIL));
return new PersonIdent(name, email);
}
}
use of org.eclipse.jgit.lib.PersonIdent in project archi-modelrepository-plugin by archi-contribs.
the class ModelRepositoryPreferencePage method performDefaults.
@Override
protected void performDefaults() {
PersonIdent result = getUserDetails();
fUserNameTextField.setText(result.getName());
fUserEmailTextField.setText(result.getEmailAddress());
fUserRepoFolderTextField.setText(getPreferenceStore().getDefaultString(PREFS_REPOSITORY_FOLDER));
fStoreCredentialsButton.setSelection(getPreferenceStore().getDefaultBoolean(PREFS_STORE_REPO_CREDENTIALS));
fUseProxyButton.setSelection(getPreferenceStore().getDefaultBoolean(PREFS_PROXY_USE));
fProxyHostTextField.setText(getPreferenceStore().getDefaultString(PREFS_PROXY_HOST));
fProxyPortTextField.setText(getPreferenceStore().getDefaultString(PREFS_PROXY_PORT));
fRequiresProxyAuthenticationButton.setSelection(getPreferenceStore().getDefaultBoolean(PREFS_PROXY_REQUIRES_AUTHENTICATION));
// $NON-NLS-1$
fProxyUserNameTextField.setText("");
// $NON-NLS-1$
fProxyUserPasswordTextField.setText("");
updateProxyControls();
}
use of org.eclipse.jgit.lib.PersonIdent in project archi-modelrepository-plugin by archi-contribs.
the class UserDetailsSection method handleSelection.
@Override
protected void handleSelection(IStructuredSelection selection) {
if (selection.getFirstElement() instanceof IArchiRepository) {
fRepository = (IArchiRepository) selection.getFirstElement();
// $NON-NLS-1$ //$NON-NLS-2$
String globalName = "", globalEmail = "";
// $NON-NLS-1$ //$NON-NLS-2$
String localName = "", localEmail = "";
// Get global name, email
try {
PersonIdent global = GraficoUtils.getGitConfigUserDetails();
globalName = global.getName();
globalEmail = global.getEmailAddress();
} catch (IOException | ConfigInvalidException ex) {
ex.printStackTrace();
}
// Get local name, email
try {
PersonIdent local = fRepository.getUserDetails();
localName = local.getName();
localEmail = local.getEmailAddress();
} catch (IOException ex) {
ex.printStackTrace();
}
fTextName.setText(globalName, localName);
fTextEmail.setText(globalEmail, localEmail);
} else {
// $NON-NLS-1$
System.err.println(getClass() + " failed to get element for " + selection.getFirstElement());
}
}
use of org.eclipse.jgit.lib.PersonIdent in project MGit by maks.
the class Repo method updateLatestCommitInfo.
public void updateLatestCommitInfo() {
RevCommit commit = getLatestCommit();
ContentValues values = new ContentValues();
String email = "";
String uname = "";
String commitDateStr = "";
String msg = "";
if (commit != null) {
PersonIdent committer = commit.getCommitterIdent();
if (committer != null) {
email = committer.getEmailAddress() != null ? committer.getEmailAddress() : email;
uname = committer.getName() != null ? committer.getName() : uname;
}
msg = commit.getShortMessage() != null ? commit.getShortMessage() : msg;
long date = committer.getWhen().getTime();
commitDateStr = Long.toString(date);
}
values.put(RepoContract.RepoEntry.COLUMN_NAME_LATEST_COMMIT_DATE, commitDateStr);
values.put(RepoContract.RepoEntry.COLUMN_NAME_LATEST_COMMIT_MSG, msg);
values.put(RepoContract.RepoEntry.COLUMN_NAME_LATEST_COMMITTER_EMAIL, email);
values.put(RepoContract.RepoEntry.COLUMN_NAME_LATEST_COMMITTER_UNAME, uname);
RepoDbManager.updateRepo(getID(), values);
}
use of org.eclipse.jgit.lib.PersonIdent in project MGit by maks.
the class CommitDiffActivity method formatCommitInfo.
private String formatCommitInfo() {
PersonIdent committer, author;
committer = mCommit.getCommitterIdent();
author = mCommit.getAuthorIdent();
return "commit " + mNewCommit + "\n" + "Author: " + author.getName() + " <" + author.getEmailAddress() + ">\n" + "AuthorDate: " + author.getWhen() + "\n" + "Commit: " + committer.getName() + " <" + committer.getEmailAddress() + ">\n" + "CommitDate: " + committer.getWhen() + "\n";
}
Aggregations