本文整理汇总了Java中org.eclipse.jgit.transport.ReceivePack类的典型用法代码示例。如果您正苦于以下问题:Java ReceivePack类的具体用法?Java ReceivePack怎么用?Java ReceivePack使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ReceivePack类属于org.eclipse.jgit.transport包,在下文中一共展示了ReceivePack类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: init
import org.eclipse.jgit.transport.ReceivePack; //导入依赖的package包/类
@Override
public void init(Project.NameKey project, ReceivePack rp) {
ProjectState ps = projectCache.get(project);
if (!ps.isEnableSignedPush()) {
rp.setSignedPushConfig(null);
return;
} else if (signedPushConfig == null) {
log.error(
"receive.enableSignedPush is true for project {} but"
+ " false in gerrit.config, so signed push verification is"
+ " disabled",
project.get());
rp.setSignedPushConfig(null);
return;
}
rp.setSignedPushConfig(signedPushConfig);
List<PreReceiveHook> hooks = new ArrayList<>(3);
if (ps.isRequireSignedPush()) {
hooks.add(SignedPushPreReceiveHook.Required.INSTANCE);
}
hooks.add(hook);
hooks.add(rp.getPreReceiveHook());
rp.setPreReceiveHook(PreReceiveHookChain.newChain(hooks));
}
开发者ID:gerrit-review,项目名称:gerrit,代码行数:26,代码来源:SignedPushModule.java
示例2: create
import org.eclipse.jgit.transport.ReceivePack; //导入依赖的package包/类
@Override
public ReceivePack create(HttpServletRequest req, Repository db)
throws ServiceNotAuthorizedException {
final ProjectState state = (ProjectState) req.getAttribute(ATT_STATE);
if (!(userProvider.get().isIdentifiedUser())) {
// Anonymous users are not permitted to push.
throw new ServiceNotAuthorizedException();
}
AsyncReceiveCommits arc =
factory.create(
state, userProvider.get().asIdentifiedUser(), db, null, ImmutableSetMultimap.of());
ReceivePack rp = arc.getReceivePack();
req.setAttribute(ATT_ARC, arc);
return rp;
}
开发者ID:gerrit-review,项目名称:gerrit,代码行数:18,代码来源:GitOverHttpServlet.java
示例3: onPreReceive
import org.eclipse.jgit.transport.ReceivePack; //导入依赖的package包/类
@Override
public void onPreReceive(ReceivePack rp, Collection<ReceiveCommand> commands) {
Worker w = new Worker(commands);
try {
w.progress.waitFor(
executor.submit(scopePropagator.wrap(w)), timeoutMillis, TimeUnit.MILLISECONDS);
} catch (ExecutionException e) {
log.warn(
String.format(
"Error in ReceiveCommits while processing changes for project %s",
projectState.getName()),
e);
rp.sendError("internal error while processing changes");
// ReceiveCommits has tried its best to catch errors, so anything at this
// point is very bad.
for (ReceiveCommand c : commands) {
if (c.getResult() == Result.NOT_ATTEMPTED) {
c.setResult(Result.REJECTED_OTHER_REASON, "internal error");
}
}
} finally {
w.sendMessages();
}
}
开发者ID:gerrit-review,项目名称:gerrit,代码行数:25,代码来源:AsyncReceiveCommits.java
示例4: execute
import org.eclipse.jgit.transport.ReceivePack; //导入依赖的package包/类
@Override
protected void execute(final FileSystemUser user,
final Repository repository,
final InputStream in,
final OutputStream out,
final OutputStream err,
final JGitFileSystem fileSystem) {
try {
final ReceivePack rp = receivePackFactory.create(this,
repository);
rp.receive(in,
out,
err);
rp.setPostReceiveHook((rp1, commands) -> {
fileSystem.getGit().gc();
fileSystem.resetCommitCount();
});
} catch (final Exception ignored) {
}
}
开发者ID:kiegroup,项目名称:appformer,代码行数:21,代码来源:GitReceiveCommand.java
示例5: create
import org.eclipse.jgit.transport.ReceivePack; //导入依赖的package包/类
/**
* Puts a {@link WriteLatexPutHook} into the returned {@link ReceivePack}.
*
* The {@link WriteLatexPutHook} needs our hostname, which we get from the
* original {@link HttpServletRequest}, used to provide a postback URL to
* the {@link SnapshotApi}. We also give it the oauth2 that we injected in
* the {@link Oauth2Filter}, and the {@link Bridge}.
*
* At this point, the repository will have been synced to the latest on
* Overleaf, but it's possible that an update happens on Overleaf while our
* put hook is running. In this case, we fail, and the user tries again,
* triggering another sync, and so on.
* @param httpServletRequest the original request
* @param repository the JGit {@link Repository} provided by
* {@link WLRepositoryResolver}
* @return a correctly hooked {@link ReceivePack}
*/
@Override
public ReceivePack create(
HttpServletRequest httpServletRequest,
Repository repository
) {
Log.info(
"[{}] Creating receive-pack",
repository.getWorkTree().getName()
);
Optional<Credential> oauth2 = Optional.ofNullable(
(Credential) httpServletRequest.getAttribute(
Oauth2Filter.ATTRIBUTE_KEY));
ReceivePack receivePack = new ReceivePack(repository);
String hostname = Util.getPostbackURL();
if (hostname == null) {
hostname = httpServletRequest.getLocalName();
}
receivePack.setPreReceiveHook(
new WriteLatexPutHook(repoStore, bridge, hostname, oauth2)
);
return receivePack;
}
开发者ID:winstonli,项目名称:writelatex-git-bridge,代码行数:40,代码来源:WLReceivePackFactory.java
示例6: handleSnapshotPostException
import org.eclipse.jgit.transport.ReceivePack; //导入依赖的package包/类
private void handleSnapshotPostException(
ReceivePack receivePack,
ReceiveCommand receiveCommand,
GitUserException e
) {
String message = e.getMessage();
receivePack.sendError(message);
StringBuilder msg = new StringBuilder();
for (
Iterator<String> it = e.getDescriptionLines().iterator();
it.hasNext();
) {
String line = it.next();
msg.append("hint: ");
msg.append(line);
if (it.hasNext()) {
msg.append('\n');
}
}
receivePack.sendMessage("");
receivePack.sendMessage(msg.toString());
receiveCommand.setResult(Result.REJECTED_OTHER_REASON, message);
}
开发者ID:winstonli,项目名称:writelatex-git-bridge,代码行数:24,代码来源:WriteLatexPutHook.java
示例7: onPreReceive
import org.eclipse.jgit.transport.ReceivePack; //导入依赖的package包/类
@Override
public void onPreReceive(ReceivePack rp, Collection<ReceiveCommand> commands) {
if (rp.getPushCertificate() == null) {
rp.sendMessage("ERROR: Signed push is required");
reject(commands, "push cert error");
}
}
开发者ID:gerrit-review,项目名称:gerrit,代码行数:8,代码来源:SignedPushPreReceiveHook.java
示例8: create
import org.eclipse.jgit.transport.ReceivePack; //导入依赖的package包/类
@Override
public ReceivePack create(HttpServletRequest req, Repository db) throws ServiceNotEnabledException, ServiceNotAuthorizedException {
ReceivePack receivePack = new ReceivePack(db);
GwReceiveHook hook = new GwReceiveHook(parsePK(req).get());
GuiceListener.get().injectMembers(hook);
receivePack.setPreReceiveHook(hook);
receivePack.setPostReceiveHook(hook);
return receivePack;
}
开发者ID:kamegu,项目名称:git-webapp,代码行数:11,代码来源:GitRepositoryServlet.java
示例9: onPreReceive
import org.eclipse.jgit.transport.ReceivePack; //导入依赖的package包/类
@Override
public void onPreReceive(ReceivePack rp, Collection<ReceiveCommand> commands) {
commandsForBranch = commands.stream()
.filter(this::isBranch)
.map(Command::new)
.collect(Collectors.toList());
commandsForTag = commands.stream()
.filter(this::isTag)
.map(Command::new)
.collect(Collectors.toList());
}
开发者ID:kamegu,项目名称:git-webapp,代码行数:12,代码来源:GwReceiveHook.java
示例10: onPostReceive
import org.eclipse.jgit.transport.ReceivePack; //导入依赖的package包/类
@Override
public void onPostReceive(ReceivePack rp, Collection<ReceiveCommand> commands) {
service.onPost(repositoryPK, Lists.transform(commandsForBranch, command -> command.getRefName().substring(Constants.R_HEADS.length())));
commandsForTag.forEach(command -> {
// String tagName = command.getRefName().substring(Constants.R_TAGS.length());
});
}
开发者ID:kamegu,项目名称:git-webapp,代码行数:10,代码来源:GwReceiveHook.java
示例11: runGitCommand
import org.eclipse.jgit.transport.ReceivePack; //导入依赖的package包/类
@Override
protected int runGitCommand() {
ReceivePack receivePack = new ReceivePack(gitRepository);
receivePack.setPreReceiveHook(hook);
receivePack.setPostReceiveHook(hook);
receivePack.setRefLogIdent(new PersonIdent(username, username + "@"
+ remoteHost));
try {
receivePack.receive(getInputStream(), getOutputStream(),
getErrorStream());
} catch (IOException e) {
return -4;
}
return 0;
}
开发者ID:litesolutions,项目名称:scm-ssh-plugin,代码行数:16,代码来源:GitCommandFactory.java
示例12: AsyncReceiveCommits
import org.eclipse.jgit.transport.ReceivePack; //导入依赖的package包/类
@Inject
AsyncReceiveCommits(
ReceiveCommits.Factory factory,
PermissionBackend permissionBackend,
VisibleRefFilter.Factory refFilterFactory,
Provider<InternalChangeQuery> queryProvider,
@ReceiveCommitsExecutor ExecutorService executor,
RequestScopePropagator scopePropagator,
ReceiveConfig receiveConfig,
TransferConfig transferConfig,
Provider<LazyPostReceiveHookChain> lazyPostReceive,
ContributorAgreementsChecker contributorAgreements,
@Named(TIMEOUT_NAME) long timeoutMillis,
@Assisted ProjectState projectState,
@Assisted IdentifiedUser user,
@Assisted Repository repo,
@Assisted @Nullable MessageSender messageSender,
@Assisted SetMultimap<ReviewerStateInternal, Account.Id> extraReviewers)
throws PermissionBackendException {
this.factory = factory;
this.executor = executor;
this.scopePropagator = scopePropagator;
this.receiveConfig = receiveConfig;
this.contributorAgreements = contributorAgreements;
this.timeoutMillis = timeoutMillis;
this.projectState = projectState;
this.user = user;
this.repo = repo;
this.messageSender = messageSender;
this.extraReviewers = extraReviewers;
Project.NameKey projectName = projectState.getNameKey();
rp = new ReceivePack(repo);
rp.setAllowCreates(true);
rp.setAllowDeletes(true);
rp.setAllowNonFastForwards(true);
rp.setRefLogIdent(user.newRefLogIdent());
rp.setTimeout(transferConfig.getTimeout());
rp.setMaxObjectSizeLimit(transferConfig.getEffectiveMaxObjectSizeLimit(projectState));
rp.setCheckReceivedObjects(projectState.getConfig().getCheckReceivedObjects());
rp.setRefFilter(new ReceiveRefFilter());
rp.setAllowPushOptions(true);
rp.setPreReceiveHook(this);
rp.setPostReceiveHook(lazyPostReceive.get());
// If the user lacks READ permission, some references may be filtered and hidden from view.
// Check objects mentioned inside the incoming pack file are reachable from visible refs.
this.perm = permissionBackend.user(user).project(projectName);
try {
this.perm.check(ProjectPermission.READ);
} catch (AuthException e) {
rp.setCheckReferencedObjectsAreReachable(receiveConfig.checkReferencedObjectsAreReachable);
}
List<AdvertiseRefsHook> advHooks = new ArrayList<>(4);
allRefsWatcher = new AllRefsWatcher();
advHooks.add(allRefsWatcher);
advHooks.add(refFilterFactory.create(projectState, repo).setShowMetadata(false));
advHooks.add(new ReceiveCommitsAdvertiseRefsHook(queryProvider, projectName));
advHooks.add(new HackPushNegotiateHook());
rp.setAdvertiseRefsHook(AdvertiseRefsHookChain.newChain(advHooks));
}
开发者ID:gerrit-review,项目名称:gerrit,代码行数:63,代码来源:AsyncReceiveCommits.java
示例13: getReceivePack
import org.eclipse.jgit.transport.ReceivePack; //导入依赖的package包/类
public ReceivePack getReceivePack() {
return rp;
}
开发者ID:gerrit-review,项目名称:gerrit,代码行数:4,代码来源:AsyncReceiveCommits.java
示例14: onPostReceive
import org.eclipse.jgit.transport.ReceivePack; //导入依赖的package包/类
@Override
public void onPostReceive(ReceivePack rp, Collection<ReceiveCommand> commands) {
for (PostReceiveHook h : hooks) {
h.onPostReceive(rp, commands);
}
}
开发者ID:gerrit-review,项目名称:gerrit,代码行数:7,代码来源:LazyPostReceiveHookChain.java
示例15: create
import org.eclipse.jgit.transport.ReceivePack; //导入依赖的package包/类
ReceiveCommits create(
ProjectState projectState,
IdentifiedUser user,
ReceivePack receivePack,
AllRefsWatcher allRefsWatcher,
SetMultimap<ReviewerStateInternal, Account.Id> extraReviewers);
开发者ID:gerrit-review,项目名称:gerrit,代码行数:7,代码来源:ReceiveCommits.java
示例16: buildAndStartSSH
import org.eclipse.jgit.transport.ReceivePack; //导入依赖的package包/类
private void buildAndStartSSH() {
final ReceivePackFactory receivePackFactory = (ReceivePackFactory<BaseGitCommand>) (req, db) -> new ReceivePack(db) {{
final JGitFileSystem fs = fsManager.get(db);
final Map<String, RevCommit> oldTreeRefs = new HashMap<>();
setPreReceiveHook((rp, commands2) -> {
fs.lock();
for (final ReceiveCommand command : commands2) {
final RevCommit lastCommit = fs.getGit().getLastCommit(command.getRefName());
oldTreeRefs.put(command.getRefName(),
lastCommit);
}
});
setPostReceiveHook((rp, commands) -> {
fs.unlock();
final String userName = req.getUser().getName();
for (Map.Entry<String, RevCommit> oldTreeRef : oldTreeRefs.entrySet()) {
final List<RevCommit> commits = fs.getGit().listCommits(oldTreeRef.getValue(),
fs.getGit().getLastCommit(oldTreeRef.getKey()));
for (final RevCommit revCommit : commits) {
final RevTree parent = revCommit.getParentCount() > 0 ? revCommit.getParent(0).getTree() : null;
notifyDiffs(fs,
oldTreeRef.getKey(),
"<ssh>",
userName,
revCommit.getFullMessage(),
parent,
revCommit.getTree());
}
}
//broadcast changes
});
}};
gitSSHService = new GitSSHService();
gitSSHService.setup(config.getSshFileCertDir(),
InetSocketAddress.createUnresolved(config.getSshHostAddr(),
config.getSshPort()),
config.getSshIdleTimeout(),
config.getSshAlgorithm(),
receivePackFactory,
new RepositoryResolverImpl<>(),
executorService);
gitSSHService.start();
}
开发者ID:kiegroup,项目名称:appformer,代码行数:51,代码来源:JGitFileSystemProvider.java
示例17: runGroovy
import org.eclipse.jgit.transport.ReceivePack; //导入依赖的package包/类
/**
* Runs the specified Groovy hook scripts.
*
* @param repository
* @param user
* @param commands
* @param scripts
*/
protected void runGroovy(RepositoryModel repository, UserModel user,
Collection<ReceiveCommand> commands, ReceivePack rp, Set<String> scripts) {
if (scripts == null || scripts.size() == 0) {
// no Groovy scripts to execute
return;
}
Binding binding = new Binding();
binding.setVariable("gitblit", GitBlit.self());
binding.setVariable("repository", repository);
binding.setVariable("receivePack", rp);
binding.setVariable("user", user);
binding.setVariable("commands", commands);
binding.setVariable("url", gitblitUrl);
binding.setVariable("logger", logger);
binding.setVariable("clientLogger", new ClientLogger(rp));
for (String script : scripts) {
if (StringUtils.isEmpty(script)) {
continue;
}
// allow script to be specified without .groovy extension
// this is easier to read in the settings
File file = new File(groovyDir, script);
if (!file.exists() && !script.toLowerCase().endsWith(".groovy")) {
file = new File(groovyDir, script + ".groovy");
if (file.exists()) {
script = file.getName();
}
}
try {
Object result = gse.run(script, binding);
if (result instanceof Boolean) {
if (!((Boolean) result)) {
logger.error(MessageFormat.format(
"Groovy script {0} has failed! Hook scripts aborted.", script));
break;
}
}
} catch (Exception e) {
logger.error(
MessageFormat.format("Failed to execute Groovy script {0}", script), e);
}
}
}
开发者ID:warpfork,项目名称:gitblit,代码行数:53,代码来源:ReceiveHook.java
示例18: ClientLogger
import org.eclipse.jgit.transport.ReceivePack; //导入依赖的package包/类
public ClientLogger(ReceivePack rp) {
this.rp = rp;
}
开发者ID:warpfork,项目名称:gitblit,代码行数:4,代码来源:ClientLogger.java
示例19: init
import org.eclipse.jgit.transport.ReceivePack; //导入依赖的package包/类
/**
* ReceivePack initialization.
*
* <p>Invoked by Gerrit when a new ReceivePack instance is created and just before it is used.
* Implementors will usually call setXXX methods on the receivePack parameter in order to set
* additional properties on it.
*
* @param project project for which the ReceivePack is created
* @param receivePack the ReceivePack instance which is being initialized
*/
void init(Project.NameKey project, ReceivePack receivePack);
开发者ID:gerrit-review,项目名称:gerrit,代码行数:12,代码来源:ReceivePackInitializer.java
注:本文中的org.eclipse.jgit.transport.ReceivePack类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论