use of me.sheimi.sgit.exception.StopTaskException in project MGit by maks.
the class ConfigAction method execute.
@Override
public void execute() {
try {
DialogRepoConfigBinding binding = DataBindingUtil.inflate(LayoutInflater.from(mActivity), R.layout.dialog_repo_config, null, false);
GitConfig gitConfig = new GitConfig(mRepo);
binding.setViewModel(gitConfig);
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
builder.setView(binding.getRoot()).setNeutralButton(R.string.label_done, null).create().show();
} catch (StopTaskException e) {
// FIXME: show error to user
Timber.e(e);
}
}
use of me.sheimi.sgit.exception.StopTaskException in project MGit by maks.
the class Repo method getRemoteOriginURL.
public String getRemoteOriginURL() {
try {
StoredConfig config = getStoredConfig();
String origin = config.getString("remote", "origin", "url");
if (origin != null && !origin.isEmpty())
return origin;
Set<String> remoteNames = config.getSubsections("remote");
if (remoteNames.size() == 0)
return "";
String url = config.getString("remote", remoteNames.iterator().next(), "url");
return url;
} catch (StopTaskException e) {
}
return "";
}
use of me.sheimi.sgit.exception.StopTaskException in project MGit by maks.
the class Repo method getBranches.
public String[] getBranches() {
try {
Set<String> branchSet = new HashSet<String>();
List<String> branchList = new ArrayList<String>();
List<Ref> localRefs = getGit().branchList().call();
for (Ref ref : localRefs) {
branchSet.add(ref.getName());
branchList.add(ref.getName());
}
List<Ref> remoteRefs = getGit().branchList().setListMode(ListBranchCommand.ListMode.REMOTE).call();
for (Ref ref : remoteRefs) {
String name = ref.getName();
String localName = convertRemoteName(name);
if (branchSet.contains(localName))
continue;
branchList.add(name);
}
return branchList.toArray(new String[0]);
} catch (GitAPIException | StopTaskException e) {
Timber.e(e);
}
return new String[0];
}
use of me.sheimi.sgit.exception.StopTaskException in project MGit by maks.
the class Repo method getRemotes.
public Set<String> getRemotes() {
if (mRemotes != null)
return mRemotes;
try {
StoredConfig config = getStoredConfig();
Set<String> remotes = config.getSubsections("remote");
mRemotes = new HashSet<String>(remotes);
return mRemotes;
} catch (StopTaskException e) {
}
return new HashSet<String>();
}
use of me.sheimi.sgit.exception.StopTaskException in project MGit by maks.
the class Repo method getCommitByRevStr.
private RevCommit getCommitByRevStr(String commitRevStr) {
try {
Repository repository = getGit().getRepository();
ObjectId id = repository.resolve(commitRevStr);
RevWalk revWalk = new RevWalk(getGit().getRepository());
return (id != null) ? revWalk.parseCommit(id) : null;
} catch (StopTaskException | IOException e) {
Timber.e(e, "error parsing commit id: %s", commitRevStr);
return null;
}
}
Aggregations