|
|
@@ -68,7 +68,7 @@ class HttpGitProtocol implements GitInterface {
|
|
|
}
|
|
|
|
|
|
protected void ManageResponse(byte[] resp) {
|
|
|
- fResp.onResponse(resp);
|
|
|
+ fResp.OnResponse(resp);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -109,7 +109,7 @@ class HttpGitProtocol implements GitInterface {
|
|
|
}
|
|
|
catch (IOException e) {
|
|
|
log.log(Level.WARNING, e.getMessage(), e);
|
|
|
- fResp.onError(e.getClass().getSimpleName() +": " +e.getMessage(), e);
|
|
|
+ fResp.OnError(e.getClass().getSimpleName() +": " +e.getMessage(), e);
|
|
|
}
|
|
|
return 0;
|
|
|
}
|
|
|
@@ -149,7 +149,7 @@ class HttpGitProtocol implements GitInterface {
|
|
|
}
|
|
|
|
|
|
protected void ManageResponse(byte[] resp) {
|
|
|
- fResp.onResponse(resp);
|
|
|
+ fResp.OnResponse(resp);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -164,7 +164,7 @@ class HttpGitProtocol implements GitInterface {
|
|
|
if (fConfig.HasAuthentification()) {
|
|
|
httpClient.setRequestProperty("Authorization", "basic " +Base64.encodeToString("fConfig.GetUser():fConfig.GetPassword()".getBytes(), Base64.NO_WRAP));
|
|
|
}
|
|
|
- fOnReadyWrite.onResponse(httpClient.getOutputStream());
|
|
|
+ fOnReadyWrite.OnResponse(httpClient.getOutputStream());
|
|
|
InputStream in = GetInputFilter(httpClient);
|
|
|
ArrayList<byte[]> fullBuffer = new ArrayList<>();
|
|
|
int totalRead = 0;
|
|
|
@@ -194,7 +194,7 @@ class HttpGitProtocol implements GitInterface {
|
|
|
}
|
|
|
catch (IOException e) {
|
|
|
log.log(Level.WARNING, e.getMessage(), e);
|
|
|
- fResp.onError(e.getClass().getSimpleName() +": " +e.getMessage(), e);
|
|
|
+ fResp.OnError(e.getClass().getSimpleName() +": " +e.getMessage(), e);
|
|
|
}
|
|
|
return 0;
|
|
|
}
|
|
|
@@ -234,13 +234,13 @@ class HttpGitProtocol implements GitInterface {
|
|
|
super(url, config);
|
|
|
SetResultHandler(new OnResponseListener<byte[]>() {
|
|
|
@Override
|
|
|
- public void onResponse(byte[] result) {
|
|
|
- StringDownloaderTask.this.onResp.onResponse(new String(result, Charset.defaultCharset()));
|
|
|
+ public void OnResponse(byte[] result) {
|
|
|
+ StringDownloaderTask.this.onResp.OnResponse(new String(result, Charset.defaultCharset()));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onError(String msg, Throwable e) {
|
|
|
- StringDownloaderTask.this.onResp.onError(msg, e);
|
|
|
+ public void OnError(String msg, Throwable e) {
|
|
|
+ StringDownloaderTask.this.onResp.OnError(msg, e);
|
|
|
}
|
|
|
});
|
|
|
onResp = resultHandler;
|
|
|
@@ -261,14 +261,14 @@ class HttpGitProtocol implements GitInterface {
|
|
|
|
|
|
public void GetRefs(final OnResponseListener<GitRef[]> callback) {
|
|
|
if (fRefsCache != null) {
|
|
|
- callback.onResponse(fRefsCache);
|
|
|
+ callback.OnResponse(fRefsCache);
|
|
|
return;
|
|
|
}
|
|
|
try {
|
|
|
URL url = new URL(fConfig.GetUrl() + "/info/REFS");
|
|
|
protoGet(url, new OnResponseListener<String>() {
|
|
|
@Override
|
|
|
- public void onResponse(String result) {
|
|
|
+ public void OnResponse(String result) {
|
|
|
String [] refStrings = result.split("\n");
|
|
|
fRefsCache = new GitRef[refStrings.length];
|
|
|
for (int i =0; i < refStrings.length; ++i) {
|
|
|
@@ -280,29 +280,29 @@ class HttpGitProtocol implements GitInterface {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- callback.onResponse(fRefsCache);
|
|
|
+ callback.OnResponse(fRefsCache);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onError(String msg, Throwable e) {
|
|
|
- callback.onError(msg, e);
|
|
|
+ public void OnError(String msg, Throwable e) {
|
|
|
+ callback.OnError(msg, e);
|
|
|
}
|
|
|
});
|
|
|
} catch (MalformedURLException e) {
|
|
|
- callback.onError(e.getMessage(), e);
|
|
|
+ callback.OnError(e.getMessage(), e);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public void FetchCommit(final GitRef ref, final OnResponseListener<GitCommit> response) {
|
|
|
PullHash(ref.GetHash(), new OnResponseListener<byte[]>() {
|
|
|
@Override
|
|
|
- public void onResponse(byte[] result) {
|
|
|
- response.onResponse(new GitCommit(ref.GetHash(), new String(result, Charset.defaultCharset())));
|
|
|
+ public void OnResponse(byte[] result) {
|
|
|
+ response.OnResponse(new GitCommit(ref.GetHash(), new String(result, Charset.defaultCharset())));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onError(String msg, Throwable e) {
|
|
|
- response.onError(msg, e);
|
|
|
+ public void OnError(String msg, Throwable e) {
|
|
|
+ response.OnError(msg, e);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
@@ -323,22 +323,22 @@ class HttpGitProtocol implements GitInterface {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onResponse(byte[] result) {
|
|
|
+ public void OnResponse(byte[] result) {
|
|
|
FillTree(fCurrentTree, result);
|
|
|
fCurrentTree = fRoot.FindNextUninitialiazedTree();
|
|
|
if (fCurrentTree != null)
|
|
|
PullHash(fCurrentTree.Initialize().GetHash());
|
|
|
else
|
|
|
- fResponseListener.onResponse(fRoot);
|
|
|
+ fResponseListener.OnResponse(fRoot);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onError(String msg, Throwable e) {
|
|
|
- fResponseListener.onError(msg, e);
|
|
|
+ public void OnError(String msg, Throwable e) {
|
|
|
+ fResponseListener.OnError(msg, e);
|
|
|
}
|
|
|
|
|
|
private void PullHash(String hash) {
|
|
|
- fResponseListener.onMsg("Reading tree " +hash);
|
|
|
+ fResponseListener.OnMsg("Reading tree " +hash);
|
|
|
HttpGitProtocol.this.PullHash(hash, this);
|
|
|
}
|
|
|
|
|
|
@@ -389,54 +389,54 @@ class HttpGitProtocol implements GitInterface {
|
|
|
public void FetchHead(final OnStreamResponseListener<GitCommit> response) {
|
|
|
GetRefs(new OnResponseListener<GitRef[]>() {
|
|
|
@Override
|
|
|
- public void onResponse(final GitRef[] result) {
|
|
|
+ public void OnResponse(final GitRef[] result) {
|
|
|
GitRef myref = null;
|
|
|
- response.onMsg("Found refs: ");
|
|
|
+ response.OnMsg("Found refs: ");
|
|
|
for (GitRef ref: result) {
|
|
|
- response.onMsg("\t> "+ref.GetBranch());
|
|
|
+ response.OnMsg("\t> "+ref.GetBranch());
|
|
|
if (ref.GetBranch().equals(fConfig.GetBranch()))
|
|
|
myref = ref;
|
|
|
}
|
|
|
if (myref != null) {
|
|
|
- response.onMsg("Checking out branch " +myref.GetBranchName() +" revision " +myref.GetHash());
|
|
|
+ response.OnMsg("Checking out branch " +myref.GetBranchName() +" revision " +myref.GetHash());
|
|
|
FetchCommit(myref, new OnResponseListener<GitCommit>() {
|
|
|
@Override
|
|
|
- public void onResponse(final GitCommit result) {
|
|
|
- response.onMsg("Finished read commit");
|
|
|
- response.onMsg(result.GetMessage());
|
|
|
- response.onMsg("Reading tree #" +GitSha1.BytesToString(result.GetTreeHash()));
|
|
|
+ public void OnResponse(final GitCommit result) {
|
|
|
+ response.OnMsg("Finished read commit");
|
|
|
+ response.OnMsg(result.GetMessage());
|
|
|
+ response.OnMsg("Reading tree #" +GitSha1.BytesToString(result.GetTreeHash()));
|
|
|
FetchTree(result, new OnStreamResponseListener<GitObject.GitTree>() {
|
|
|
@Override
|
|
|
- public void onMsg(String message) {
|
|
|
- response.onMsg(message);
|
|
|
+ public void OnMsg(String message) {
|
|
|
+ response.OnMsg(message);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onResponse(GitObject.GitTree tree) {
|
|
|
- response.onMsg("Finished reading tree");
|
|
|
- response.onResponse(result);
|
|
|
+ public void OnResponse(GitObject.GitTree tree) {
|
|
|
+ response.OnMsg("Finished reading tree");
|
|
|
+ response.OnResponse(result);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onError(String msg, Throwable e) {
|
|
|
- response.onError(msg, e);
|
|
|
+ public void OnError(String msg, Throwable e) {
|
|
|
+ response.OnError(msg, e);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onError(String msg, Throwable e) {
|
|
|
- response.onError(msg, e);
|
|
|
+ public void OnError(String msg, Throwable e) {
|
|
|
+ response.OnError(msg, e);
|
|
|
}
|
|
|
});
|
|
|
} else {
|
|
|
- response.onError("Branch " +fConfig.GetBranch() + " not found on remote", null);
|
|
|
+ response.OnError("Branch " +fConfig.GetBranch() + " not found on remote", null);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onError(final String msg, final Throwable e) {
|
|
|
- response.onError(msg, e);
|
|
|
+ public void OnError(final String msg, final Throwable e) {
|
|
|
+ response.OnError(msg, e);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
@@ -447,7 +447,7 @@ class HttpGitProtocol implements GitInterface {
|
|
|
url = new URL(fConfig.GetUrl() + "/objects/" + hash.substring(0, 2) + "/" + hash.substring(2));
|
|
|
}
|
|
|
catch (MalformedURLException e) {
|
|
|
- response.onError(e.getClass().getName() +": " +e.getMessage(), e);
|
|
|
+ response.OnError(e.getClass().getName() +": " +e.getMessage(), e);
|
|
|
return;
|
|
|
}
|
|
|
protoInflateGet(url, response);
|
|
|
@@ -474,7 +474,7 @@ class HttpGitProtocol implements GitInterface {
|
|
|
public void PushBlobs(final GitCommit.Builder commit, final OnStreamResponseListener<Void> response) {
|
|
|
GetRefs(new OnResponseListener<GitRef[]>() {
|
|
|
@Override
|
|
|
- public void onResponse(final GitRef[] result) {
|
|
|
+ public void OnResponse(final GitRef[] result) {
|
|
|
GitRef myref = null;
|
|
|
for (GitRef ref: result) {
|
|
|
if (ref.GetBranch().equals(fConfig.GetBranch()))
|
|
|
@@ -482,59 +482,59 @@ class HttpGitProtocol implements GitInterface {
|
|
|
}
|
|
|
if (myref != null) {
|
|
|
final GitRef finalRef = myref;
|
|
|
- response.onMsg("Pushing over " +myref.GetBranch() +" revision " +myref.GetHash());
|
|
|
+ response.OnMsg("Pushing over " +myref.GetBranch() +" revision " +myref.GetHash());
|
|
|
try {
|
|
|
HashMap<String, String> headers = new HashMap<>();
|
|
|
headers.put("Content-Type", "application/x-git-receive-pack-request");
|
|
|
ProtoPost(new URL(fConfig.GetUrl() +"/git-receive-pack"), headers, new OnResponseListener<byte[]>() {
|
|
|
@Override
|
|
|
- public void onResponse(byte[] result) {
|
|
|
+ public void OnResponse(byte[] result) {
|
|
|
Logger.getAnonymousLogger().severe("git-receive-pack " +new String(result, Charset.defaultCharset()));
|
|
|
- response.onResponse(null);
|
|
|
+ response.OnResponse(null);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onError(String msg, Throwable e) {
|
|
|
+ public void OnError(String msg, Throwable e) {
|
|
|
Logger.getAnonymousLogger().severe("git-receive-pack ERROR");
|
|
|
- response.onError(msg, e);
|
|
|
+ response.OnError(msg, e);
|
|
|
}
|
|
|
}, new OnResponseListener<OutputStream>() {
|
|
|
@Override
|
|
|
- public void onResponse(OutputStream result) {
|
|
|
+ public void OnResponse(OutputStream result) {
|
|
|
byte[] msgLine = (finalRef.GetHash() + " " + GitSha1.BytesToString(GitSha1.getRawSha1OfPackable(commit.Build())) +" " +finalRef.GetBranch()).getBytes();
|
|
|
try {
|
|
|
result.write(String.format(Locale.US, "%04X", msgLine.length +4).getBytes());
|
|
|
result.write(msgLine);
|
|
|
result.write("0000".getBytes());
|
|
|
if (!makePack(commit.PreparePack(), result)) {
|
|
|
- onError("Pack error", null);
|
|
|
+ OnError("Pack error", null);
|
|
|
return;
|
|
|
}
|
|
|
result.close();
|
|
|
}
|
|
|
catch (IOException e) {
|
|
|
log.log(Level.SEVERE, "Cannot git-upload-pack: " +e.getMessage(), e);
|
|
|
- onError(e.getMessage(), e);
|
|
|
+ OnError(e.getMessage(), e);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onError(String msg, Throwable e) {
|
|
|
- response.onError(msg, e);
|
|
|
+ public void OnError(String msg, Throwable e) {
|
|
|
+ response.OnError(msg, e);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
catch (IOException e) {
|
|
|
- response.onError(e.getMessage(), e);
|
|
|
+ response.OnError(e.getMessage(), e);
|
|
|
}
|
|
|
} else {
|
|
|
- response.onError("Branch " +fConfig.GetBranch() + " not found on remote for pushing", null);
|
|
|
+ response.OnError("Branch " +fConfig.GetBranch() + " not found on remote for pushing", null);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onError(final String msg, final Throwable e) {
|
|
|
- response.onError(msg, e);
|
|
|
+ public void OnError(final String msg, final Throwable e) {
|
|
|
+ response.OnError(msg, e);
|
|
|
}
|
|
|
});
|
|
|
}
|