mirror of
https://github.com/android-password-store/Android-Password-Store
synced 2025-08-31 14:25:28 +00:00
@@ -10,7 +10,10 @@ import com.zeapo.pwdstore.R;
|
||||
|
||||
import org.eclipse.jgit.api.CommitCommand;
|
||||
import org.eclipse.jgit.api.GitCommand;
|
||||
import org.eclipse.jgit.api.PushCommand;
|
||||
import org.eclipse.jgit.api.StatusCommand;
|
||||
import org.eclipse.jgit.transport.PushResult;
|
||||
import org.eclipse.jgit.transport.RemoteRefUpdate;
|
||||
|
||||
|
||||
public class GitAsyncTask extends AsyncTask<GitCommand, Integer, String> {
|
||||
@@ -49,6 +52,29 @@ public class GitAsyncTask extends AsyncTask<GitCommand, Integer, String> {
|
||||
// the previous status will eventually be used to avoid a commit
|
||||
if (nbChanges == null || nbChanges > 0)
|
||||
command.call();
|
||||
}else if (command instanceof PushCommand) {
|
||||
for (final PushResult result : ((PushCommand) command).call()) {
|
||||
// Code imported (modified) from Gerrit PushOp, license Apache v2
|
||||
for (final RemoteRefUpdate rru : result.getRemoteUpdates()) {
|
||||
switch (rru.getStatus()) {
|
||||
case REJECTED_NONFASTFORWARD:
|
||||
return activity.getString(R.string.git_push_nff_error);
|
||||
case REJECTED_NODELETE:
|
||||
case REJECTED_REMOTE_CHANGED:
|
||||
case NON_EXISTING:
|
||||
case NOT_ATTEMPTED:
|
||||
return activity.getString(R.string.git_push_generic_error) + rru.getStatus().name();
|
||||
case REJECTED_OTHER_REASON:
|
||||
if ("non-fast-forward".equals(rru.getMessage())) {
|
||||
return activity.getString(R.string.git_push_other_error);
|
||||
} else {
|
||||
return activity.getString(R.string.git_push_generic_error) + rru.getMessage();
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
command.call();
|
||||
}
|
||||
|
@@ -213,10 +213,7 @@ public abstract class GitOperation {
|
||||
public void onTaskEnded(String result) {
|
||||
new AlertDialog.Builder(callingActivity).
|
||||
setTitle(callingActivity.getResources().getString(R.string.jgit_error_dialog_title)).
|
||||
setMessage("Error occurred during a Git operation, "
|
||||
+ callingActivity.getResources().getString(R.string.jgit_error_dialog_text)
|
||||
+ result
|
||||
+ "\nPlease check the FAQ for possible reasons why this error might occur.").
|
||||
setMessage(callingActivity.getResources().getString(R.string.jgit_error_dialog_text) + result).
|
||||
setPositiveButton(callingActivity.getResources().getString(R.string.dialog_ok), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
|
@@ -48,10 +48,7 @@ public class PushOperation extends GitOperation {
|
||||
// TODO handle the "Nothing to push" case
|
||||
new AlertDialog.Builder(callingActivity).
|
||||
setTitle(callingActivity.getResources().getString(R.string.jgit_error_dialog_title)).
|
||||
setMessage("Error occured during the push operation, "
|
||||
+ callingActivity.getResources().getString(R.string.jgit_error_dialog_text)
|
||||
+ result
|
||||
+ "\nPlease check the FAQ for possible reasons why this error might occur.").
|
||||
setMessage(callingActivity.getString(R.string.jgit_error_push_dialog_text) + result).
|
||||
setPositiveButton(callingActivity.getResources().getString(R.string.dialog_ok), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
|
@@ -204,4 +204,8 @@
|
||||
<string name="autofill_ins_1_hint">Screenshot of accessibility services</string>
|
||||
<string name="autofill_ins_2_hint">Screenshot of toggle in accessibility services</string>
|
||||
<string name="autofill_ins_3_hint">Screenshot of autofill service in action</string>
|
||||
<string name="git_push_nff_error">Push was rejected by remote, run pull before pushing again. You can use Synchronize rather than pull/push as it implements both</string>
|
||||
<string name="git_push_generic_error">Push was rejected by remote, reason:</string>
|
||||
<string name="git_push_other_error">Remote rejected non-fast-forward push. Check receive.denyNonFastForwards variable in config file of destination repository.</string>
|
||||
<string name="jgit_error_push_dialog_text">Error occurred during the push operation:</string>
|
||||
</resources>
|
||||
|
Reference in New Issue
Block a user