本文整理汇总了Java中org.eclipse.jgit.api.GitCommand类的典型用法代码示例。如果您正苦于以下问题:Java GitCommand类的具体用法?Java GitCommand怎么用?Java GitCommand使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GitCommand类属于org.eclipse.jgit.api包,在下文中一共展示了GitCommand类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: update
import org.eclipse.jgit.api.GitCommand; //导入依赖的package包/类
public void update(ProjectController controller) throws IllegalStateException {
if (Utils.isNetworkOnline(context) == false)
throw new IllegalStateException("Network is not available");
this.controller = controller;
File sourceRepo = new File(project.getSourcePath(context));
GitCommand<?> command;
if(sourceRepo.exists()) {
command = git.pull();
}
else {
command = Git.cloneRepository().setURI(project.getUrl())
.setDirectory(new File(project.getSourcePath(context)));
}
new GitTask(project.getName()).execute(command);
}
示例2: configureCommand
import org.eclipse.jgit.api.GitCommand; //导入依赖的package包/类
/**
* Configures the transport of the command to deal with things like SSH
*/
public static <C extends GitCommand> void configureCommand(TransportCommand<C, ?> command, CredentialsProvider credentialsProvider, final File sshPrivateKey, final File sshPublicKey) {
if (sshPrivateKey != null) {
final CredentialsProvider provider = credentialsProvider;
command.setTransportConfigCallback(new TransportConfigCallback() {
@Override
public void configure(Transport transport) {
if (transport instanceof SshTransport) {
SshTransport sshTransport = (SshTransport) transport;
SshSessionFactory sshSessionFactory = new JschConfigSessionFactory() {
@Override
protected void configure(OpenSshConfig.Host host, Session session) {
session.setConfig("StrictHostKeyChecking", "no");
UserInfo userInfo = new CredentialsProviderUserInfo(session, provider);
session.setUserInfo(userInfo);
}
@Override
protected JSch createDefaultJSch(FS fs) throws JSchException {
JSch jsch = super.createDefaultJSch(fs);
jsch.removeAllIdentity();
String absolutePath = sshPrivateKey.getAbsolutePath();
if (LOG.isDebugEnabled()) {
LOG.debug("Adding identity privateKey: " + sshPrivateKey + " publicKey: " + sshPublicKey);
}
if (sshPublicKey != null) {
jsch.addIdentity(absolutePath, sshPublicKey.getAbsolutePath(), null);
} else {
jsch.addIdentity(absolutePath);
}
return jsch;
}
};
sshTransport.setSshSessionFactory(sshSessionFactory);
}
}
});
}
}
示例3: handle
import org.eclipse.jgit.api.GitCommand; //导入依赖的package包/类
@Override
public void handle(GitCommand<Git> command, final Caller caller, final String callerWorkspaceName, final Git result) {
final VarScript plugin = caller.getService().getPlugin();
Bukkit.getScheduler().runTask(plugin, new Runnable() {
@Override
public void run() {
executor.onCommandGitCloneDone(caller, callerWorkspaceName, result, folderName);
}
});
}
示例4: doInBackground
import org.eclipse.jgit.api.GitCommand; //导入依赖的package包/类
@Override
protected Long doInBackground(GitCommand<?>... params) {
GitCommand<?> command = params[0];
Utils.announceSyncStart(context, projectName);
if(command instanceof CloneCommand) {
((CloneCommand)command).setProgressMonitor(monitor);
status = "Cloning";
} else if(command instanceof PullCommand) {
((PullCommand)command).setProgressMonitor(monitor);
status = "Pulling";
} else {
throw new IllegalArgumentException(
"Coudln't attach progressMonitor to git command");
}
publishProgress(-1);
try {
command.call();
} catch (Exception e) {
status = e.getLocalizedMessage();
publishProgress(100);
}
return 0L;
}
示例5: setupCredentials
import org.eclipse.jgit.api.GitCommand; //导入依赖的package包/类
/**
* Setups the Git credentials if specified and needed
*
* @param command The git command to configure
*/
@SuppressWarnings("rawtypes")
protected void setupCredentials(GitCommand<?> command) {
GitSettings settings = lookupSettings();
if (settings != null && command instanceof TransportCommand) {
TransportCommand cmd = (TransportCommand) command;
cmd.setCredentialsProvider(settings.getCredentials());
}
}
示例6: doInBackground
import org.eclipse.jgit.api.GitCommand; //导入依赖的package包/类
@Override
protected String doInBackground(GitCommand... commands) {
Integer nbChanges = null;
for (GitCommand command : commands) {
Log.d("doInBackground", "Executing the command <" + command.toString() + ">");
try {
if (command instanceof StatusCommand) {
// in case we have changes, we want to keep track of it
org.eclipse.jgit.api.Status status = ((StatusCommand) command).call();
nbChanges = status.getChanged().size() + status.getMissing().size();
} else if (command instanceof CommitCommand) {
// 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();
}
} catch (Exception e) {
e.printStackTrace();
return e.getMessage() + "\nCaused by:\n" + e.getCause();
}
}
return "";
}
示例7: setCommand
import org.eclipse.jgit.api.GitCommand; //导入依赖的package包/类
public void setCommand(GitCommand<T> command) {
this.command = command;
}
示例8: handle
import org.eclipse.jgit.api.GitCommand; //导入依赖的package包/类
@Override
public void handle(GitCommand<FetchResult> command, Caller caller, String callerWorkspaceName, FetchResult result) {
String message = "Fetch done. " + ChatColor.AQUA + result.getMessages();
VarScript plugin = caller.getService().getPlugin();
Bukkit.getScheduler().runTask(plugin, new MessageSender(caller, message, callerWorkspaceName,0));
}
示例9: handle
import org.eclipse.jgit.api.GitCommand; //导入依赖的package包/类
void handle(GitCommand<T> command, Caller caller, String callerWorkspaceName, T result);