Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Copyright (C) 2008-2009, Google Inc.
  3. * Copyright (C) 2009-2010, Robin Rosenberg <robin.rosenberg@dewire.com> and others
  4. *
  5. * This program and the accompanying materials are made available under the
  6. * terms of the Eclipse Distribution License v. 1.0 which is available at
  7. * https://www.eclipse.org/org/documents/edl-v10.php.
  8. *
  9. * SPDX-License-Identifier: BSD-3-Clause
  10. */
  11. package org.eclipse.jgit.pgm;
  12. import java.io.File;
  13. import java.io.IOException;
  14. import java.text.MessageFormat;
  15. import org.eclipse.jgit.errors.RepositoryNotFoundException;
  16. import org.eclipse.jgit.lib.RepositoryCache.FileKey;
  17. import org.eclipse.jgit.pgm.internal.CLIText;
  18. import org.eclipse.jgit.util.FS;
  19. import org.kohsuke.args4j.Argument;
  20. import org.kohsuke.args4j.Option;
  21. @Command(common = false, usage = "usage_ServerSideBackendForJgitFetch")
  22. class UploadPack extends TextBuiltin {
  23. @Option(name = "--timeout", metaVar = "metaVar_seconds", usage = "usage_abortConnectionIfNoActivity")
  24. int timeout = -1;
  25. @Argument(index = 0, required = true, metaVar = "metaVar_directory", usage = "usage_RepositoryToReadFrom")
  26. File srcGitdir;
  27. /** {@inheritDoc} */
  28. @Override
  29. protected final boolean requiresRepository() {
  30. return false;
  31. }
  32. /** {@inheritDoc} */
  33. @Override
  34. protected void run() {
  35. try {
  36. FileKey key = FileKey.lenient(srcGitdir, FS.DETECTED);
  37. db = key.open(true /* must exist */);
  38. org.eclipse.jgit.transport.UploadPack up = new org.eclipse.jgit.transport.UploadPack(
  39. db);
  40. if (0 <= timeout) {
  41. up.setTimeout(timeout);
  42. }
  43. up.upload(ins, outs, errs);
  44. } catch (RepositoryNotFoundException notFound) {
  45. throw die(MessageFormat.format(CLIText.get().notAGitRepository,
  46. srcGitdir.getPath()), notFound);
  47. } catch (IOException e) {
  48. throw die(e.getMessage(), e);
  49. }
  50. }
  51. }