786 Commits

Author SHA1 Message Date
David Pursehouse
78bbaad5f0 Merge "Support 'git-upload-archive'" 2015-05-07 04:37:04 +00:00
Martin Fick
e3f38e3cd3 Move users of Branch constants to RefNames constants.
This seems like a better place for these constants.

Change-Id: I18aa13c45902c64236ccdb239a038fe0760af0ec
2015-04-29 12:08:58 -06:00
Francois Ferrand
1e9338854c Support 'git-upload-archive'
This allows use the standard git archive command to create an archive
of the content of a repository:

  $ git archive -f tar.bz2 --prefix=foo-1.0/ \
    --remote=ssh://john@gerrit:29418/foo \
    refs/changes/73/673/1 > foo-1.0.tar.bz2

Different compression levels can be configured for zip format:

  $ git archive -f zip -9 \
    --remote=ssh://john@gerrit:29418/foo \
    refs/changes/73/673/1 > foo.zip

TEST PLAN:

  buck test --include ssh

Bug: Issue 2061
Change-Id: Ifc1a92bacef3155cf474adee883cbe587dd8759f
2015-04-23 20:45:28 +02:00
Dave Borowitz
d4ce85d26d Groups: Add create methods
Change-Id: I11a679daf9e82ddc772e8479fbd2ff996a6cc42e
2015-04-14 09:08:54 -04:00
Dave Borowitz
8344a503b9 Move GroupInfo and related classes from GroupJson to extensions
Change-Id: I299411d99ef5d635aa62f9e862049c7842aa9038
2015-04-14 09:01:38 -04:00
David Pursehouse
b7c57bbf33 Organize imports
Change-Id: I42d6e3acf14d72472d1d038836be5fa33dc31feb
2015-04-14 17:23:51 +09:00
David Pursehouse
994159eab7 Fix Checkstyle warnings related to class and member modifier order
Change the order of class and member modifiers to follow the order
defined in the Java Language Specification and the Google Java
Style guide [1].

[1] https://google-styleguide.googlecode.com/svn/trunk/javaguide.html#s4.8.7-modifiers

Change-Id: Ic7f85cb4d15f49159095aa37d3c41dbffd69c805
2015-04-14 11:34:40 +09:00
David Pursehouse
c7463ba0a4 SshDaemon: Fix Checkstyle warnings
- Declare variables on separate lines
- Declare class modifiers in Java language spec recommended order
- Replace C-style array declarations with Java-style declarations

Change-Id: I12434301cb02db5c6b4548d18f7670543bf9e0f2
2015-04-14 11:23:15 +09:00
Shawn Pearce
34a6db2d32 Merge changes I695ce026,I87868087,I79bfb06e,I97006ab1,I0516cfa1, ...
* changes:
  Merge PerformRenameGroup into PutName
  Use REST implementation from rename-group SSH command
  Remove duplicate code to add group members
  Merge PerformCreateGroup into CreateGroup
  Remove support for initial groups from PerformCreateGroup
  Use REST implementation to create groups during tests
  Use REST implementation from create-group SSH command
2015-04-12 19:54:11 +00:00
Shawn Pearce
61807cc2a8 Merge "Allow to build api with Java 8" 2015-04-10 22:17:05 +00:00
Edwin Kempin
2785e0a64d Merge PerformRenameGroup into PutName
The PutName class is the only user of the PerformRenameGroup
class. This additional indirection is not needed and the pattern of
having a Perform* class to encapsule common logic between SSH and UI
was given up in favor of having this common code in the REST API
implementation classes.

Having all the functionality in PutName avoids to do validation
checks twice and to convert exceptions.

Change-Id: I695ce026be88c7012f1cf6536f34f8c99ea7d405
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
2015-04-09 11:11:22 +02:00
Edwin Kempin
32ffb7b6eb Use REST implementation from rename-group SSH command
The rename-group SSH command should invoke the rename group
functionality in the REST API rather then reimplementing the logic.

Change-Id: I8786808776edc539536557d291162798fdc2199d
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
2015-04-09 10:40:44 +02:00
Edwin Kempin
caadc0a60e Use REST implementation from create-group SSH command
The create-group SSH command should invoke the create group
functionality in the REST API rather then reimplementing the logic.

The create group REST endpoint doesn't support adding of initial
members and included groups since there are own REST endpoints for
this. This is why the create-group SSH command must invoke these REST
endpoints as well.

Change-Id: Ic6e97c57be839bbe86d325a89d0d90deb4bee7ae
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
2015-04-09 07:44:04 +00:00
David Pursehouse
f838e8dc0b Merge branch 'stable-2.11'
* stable-2.11:
  Update 2.11 release notes
  Revert "Revert "SSH: Simplify CachingPublicKeyAuthenticator implementation""
  Update 2.11 release notes
  SshDaemon: Add implementation of InsecureBouncyCastleRandom.random()
  Fix formatting in documentation about review labels
  Remove stripping # in login redirect
  Ensure that AccountLoader sets username if requested
  Workaround Guice bug "getPathInfo not decoded"

Change-Id: I9615fe2305b47a8ff232a47982651ea00a423263
2015-04-08 11:39:46 +09:00
David Pursehouse
3d338f90ef Merge branch 'stable-2.10' into stable-2.11
* stable-2.10:
  Revert "Revert "SSH: Simplify CachingPublicKeyAuthenticator implementation""
  Remove stripping # in login redirect

Change-Id: I052e45a3220b43923e1ee414c97f1bbfe845620a
2015-04-07 19:33:36 +09:00
David Pursehouse
c7f58ccbd8 Revert "Revert "SSH: Simplify CachingPublicKeyAuthenticator implementation""
This reverts commit 48bf33b2ebf58d501d5745a64a76d7b47c85c407.

Change-Id: I145d159327796ee524e05cc2019bb355f245a94b
2015-04-07 19:23:22 +09:00
David Pursehouse
7f6a420486 SshDaemon: Add implementation of InsecureBouncyCastleRandom.random()
Copied from org.apache.sshd.common.random.BouncyCastleRandom

Change-Id: Ie12d7fd85eeeb38c380e73f2006026572128b7a9
2015-04-07 18:56:46 +09:00
David Pursehouse
efdb2461d3 Merge branch 'stable-2.11'
* stable-2.11:
  SshDaemon: Don't use deprecated IoAcceptor.dispose()
  PatchListLoader: Don't use deprecated TemporaryBuffer.LocalFile constructor
  Fix unused exception throws in EncryptedContactStore
  Remove unused imports
  Don't use deprecated PGPPublicKeyRingCollection constructor
  Print proper name for mergeability check tasks in show-queue command
  Print proper name for ListenableFutureTask in show-queue command
  Work around asciidoctor handling of nested ` and *
  Revert "Revert "Allow configuration of SSH rekey values""
  Revert "Revert "SSHD: Allow ECDSA based public key authentication""
  Revert "Revert "SSHD: Prevent double authentication for the same public key""
  Revert "Downgrade SSHD to 0.9.0-4-g5967cfd"
  Recommend --data-binary flag when testing submit rules from curl
  Change edit shortcut from 'm' to 'e'
  Fix NPE in MergeabilityCache.getIfPresent
  Fix F5 shortcut being hijacked by edit topic in Firefox
  Update 2.11 release notes
  Update version to 2.10.2
  Release notes for Gerrit 2.10.2
  Do not return 403 when clicking on Gitweb breadcrumb
  Add log messages to troubleshoot OAuth/OpenID linking
  Remove unused imports
  Convert to new AutoCloseable instances coming in JGit 4.0
  Remove unused OAuthToken in authorisation URL
  OnlineReindexer: log the success/failure numbers on exit
  Work around MyersDiff infinite loop in PatchListLoader
  Bind SecureStore and SecureStoreClassName in WebAppInitializer
  Update replication plugin
  Rework intra line diff to interrupt threads instead of killing them
  Update JGit to 3.7.0.201502260915-r.58-g65c379e
  Update replication plugin
  Workaround a RecursiveMerger bug [1], avoid online reindexing failure
  OAuth: Allow to link claimed identity to existing accounts
  OAuth: Allow to change username
  Allow PatchListLoader to use recursive merger
  Allow plugins to use self-provided licenses for used Maven Jars

Change-Id: Ie7f96abd97bd2c7e9205a708eed11f9052546187
2015-04-07 10:52:27 +09:00
David Pursehouse
744e74b90f Merge branch 'stable-2.10' into stable-2.11
* stable-2.10:
  SshDaemon: Don't use deprecated IoAcceptor.dispose()
  PatchListLoader: Don't use deprecated TemporaryBuffer.LocalFile constructor
  Fix unused exception throws in EncryptedContactStore
  Remove unused imports
  Don't use deprecated PGPPublicKeyRingCollection constructor
  Print proper name for mergeability check tasks in show-queue command
  Print proper name for ListenableFutureTask in show-queue command
  Revert "Revert "Allow configuration of SSH rekey values""
  Revert "Revert "SSHD: Allow ECDSA based public key authentication""
  Revert "Revert "SSHD: Prevent double authentication for the same public key""
  Revert "Downgrade SSHD to 0.9.0-4-g5967cfd"

Change-Id: I5d67f0a3c9686cf96b7c7eb349b73cd5ae8ffbbf
2015-04-07 10:24:02 +09:00
David Pursehouse
ce3cf6c83a SshDaemon: Don't use deprecated IoAcceptor.dispose()
Change-Id: I971a5326c19b0274bfe28f84acff7dc76a664f3f
2015-04-07 09:57:20 +09:00
David Pursehouse
97978135e0 Remove unused imports
Change-Id: I079fc5767954d9ac795de459a9174d45825fe5e5
2015-04-06 22:39:45 +09:00
David Ostrovsky
985201b5f9 Revert "Revert "Allow configuration of SSH rekey values""
This reverts commit 3435c536a6024fc2a92610be452ab4d85ae5268c.

Change-Id: I4efe2e209ff05e68d8add596025622e76646bfde
2015-04-06 12:33:06 +09:00
David Ostrovsky
c8172b20e8 Revert "Revert "SSHD: Allow ECDSA based public key authentication""
This reverts commit ef74c883e6cc07c0a55f14960dfc31b0feafc39e.

Change-Id: I365c57365b4ea7271f104b8040f951b088cf80ab
2015-04-06 12:27:03 +09:00
David Ostrovsky
f8a988f91c Revert "Revert "SSHD: Prevent double authentication for the same public key""
This reverts commit c7dedf989cf1717548b0793490d0be9506c1bc2e.

Change-Id: Ic4295ee58db8e0eb8869e526988ac4a3758370ee
2015-04-06 12:26:46 +09:00
David Ostrovsky
e2921b62f6 Revert "Downgrade SSHD to 0.9.0-4-g5967cfd"
All versions of SSHD since release 0.10 were suffering from exhaustion
of thread pool. Number of valuable features had to be reverted to
downgrade the SSHD version to 0.9. This blocking bug [1] was fixed [2]
and released in 0.14.0.

Update to the new version of SSHD and revert the downgrade.

This reverts commit bde8e9ac6f26a85c1a757ac0fa298f8b0c3c5783.

[1] https://issues.apache.org/jira/browse/SSHD-348
[2] https://git-wip-us.apache.org/repos/asf?p=mina-sshd.git;a=commitdiff;h=964e76890cf56da4491199860d0ea8276fbd26a6
Change-Id: Ib5faf1df0cb6bde2e2cd554c9311cc5e55095b04
2015-04-06 12:26:07 +09:00
Christian Aistleitner
0da441ef87 Allow to build api with Java 8
Java 8's javadoc fails hard on unknown HTML tags. Due some
documentation code snippets that contain generics and lacked a
{@code...}, the code got picked up as html, which made the target fail
like:

  [...]/extensions/registration/DynamicSet.java:64: error: unknown tag: Foo
   *   DynamicSet.setOf(binder(), new TypeLiteral<Thing<Foo>>() {});

We insert the needed {@code...} to make the build pass for Java 8.

Change-Id: I430b8eb9f2f158c2c7a2a7a8d93446eff3253529
2015-03-29 16:21:33 +02:00
David Pursehouse
7760c909b1 Merge changes from topic 'checkstyle-cleanup-2'
* changes:
  Update commit-message-length-validator plugin revision
  Fix line length warnings
2015-03-20 01:01:44 +00:00
Edwin Kempin
def131f6e9 Merge "Add "aggressive" option to ssh command "GC"" 2015-03-19 14:58:33 +00:00
Christian Halstrick
219f865fee Add "aggressive" option to ssh command "GC"
When triggering a garbage collection through ssh it can be specified
whether to run an aggressive garbage collection or not.

Change-Id: Icfecc69915870289f5957912d3d53348f21a83f7
2015-03-19 15:45:29 +01:00
David Pursehouse
410a066be7 Fix line length warnings
Update the Checkstyle configuration to only warn on lines that exceed
150 characters.

In code reviews we usually ask people to wrap lines at around 80 columns,
but there are too many existing long lines (between 80 and 150) to bother
fixing them all now.

Only wrap the ones that are egregiously long (i.e. more than 150) and add
suppressions for the ones that cannot be wrapped, for example containing
long URLs.

Change-Id: I09625efa7a0509f1d88c27ebc83dda67b6afd026
2015-03-19 18:35:04 +09:00
David Pursehouse
9319d0de88 Get rid of empty if-statements
Change-Id: Ie1a6a8e60bcb7affd4c8fe7432d6bb93ca499637
2015-03-19 12:15:44 +09:00
David Pursehouse
ad5e634302 Do not declare multiple variables on a single line
Change-Id: I6ce1cf9e542beda96222b5fbc7c891f086890586
2015-03-19 12:15:42 +09:00
David Pursehouse
8f2ced605b Order modifiers according to JLS recommendation
Change-Id: I7e70be66448234a27e0fe76a77b98df6d67417de
2015-03-19 12:15:42 +09:00
David Pursehouse
5ddffa0060 Add missing braces around if- for- and while-statements
Change-Id: Ib7d455426fa78ac803f9d5162466f52b973cf998
2015-03-19 12:15:42 +09:00
Dave Borowitz
5c8c20b28f Projects: Add convenience methods for creating projects
The old idiom:
  api.projects().name("foo").create(in);
more closely matches the REST API, but makes less sense in Java where
we don't necessarily require a hierarchical structure, and we can
infer the project name from the input.

The above becomes the simpler:
  api.projects().create(in);

Also include a method to create with just a name.

Change-Id: Ib789854bd22e1a15ceebf37c57382ca4079c4459
2015-03-16 11:29:23 -07:00
David Ostrovsky
27c286c2d9 Slave: Report sane failure message for non-bound SSH commands
When a command is not bound on slaves, non meaningful not bound message
is currently reported.  Improve the situation by binding generic SSH
command that reports "not supported in slave mode" message.

Change-Id: Ia25012486b33f98650018c0fa2d1a55eaa7a5cee
2015-03-10 20:56:52 +01:00
Dariusz Luksza
55750219ca Add set-head SSH command
Adds SSH command to change project HEAD reference.

Change-Id: I1a4cb0673eb819fae85e9babdb569ab9785662c8
Signed-off-by: Dariusz Luksza <dariusz@luksza.org>
2015-03-05 09:12:55 +01:00
Dave Borowitz
05b1ae22d5 Fix outstanding issues with conversion to NIO
NIO methods throw NoSuchFileException, not FileNotFoundException. How
nice.

Throwing from Files#getLastModifiedTime, apart from cluttering up
throws clauses, means callers have to check for FileNotFoundException,
which is verbose and error prone. Instead, implement a helper with the
old File#lastModified() semantics; this preserves old behavior, which
might not handle some error cases well, but worked well enough. (In
theory we could use FileSnapshot or something, but I don't want to
shave that particular yak until/unless I get a chance to add a
Path-compatible interface to FileSnapshot in JGit as well.)

Organize some imports.

Tested:
-Tests pass.
-Initialized a site, including downloading.
-Launched a site.
-Added and removed site headers and CSS in a running site.
-Added and removed plugins, both live and while shutdown.

Change-Id: I60dfe5280512f00dce4ec99fe3689b2f2b3c6685
2015-02-24 10:57:11 -08:00
Dave Borowitz
7e55f6bbd8 SitePaths: Convert SSH-related paths to Path
Change-Id: I7dc8fdfcf8fec2bab159e02cab23cd64186913f2
2015-02-24 09:19:54 -08:00
Dave Borowitz
a5f3a69707 Hack SshDaemon to not use SecureRandom during tests
We previously needed 8 bytes of data from a SecureRandom in order to
start an SSH daemon. Unfortunately, sometimes machines run out of
entropy, for example when running the Gerrit test suite several times
in a row.

Add an undocumented configuration option to use a different Random
factory for Apache SSHD that uses a hard-coded seed instead of
depending on SecureRandom. Unfortunately, because SshDaemon is
constructed using Daemon's injector stack, we can't easily modify its
modules to swap out the provider, so a configuration option is the
easiest solution.

Change-Id: I539b8e3d39d2da9908962fdb8d9633adf935fb4c
2015-02-20 15:32:41 -08:00
David Ostrovsky
ea2b64e1f7 Fix compilation of unit test on Java 8
Transitive dependency is missing for mina-sshd in sshd_tests rule.
The error message in Java 8 is:

gerrit-sshd/src/test/java/com/google/gerrit/sshd/commands/ProjectConfigParamParserTest.java:41:
error: cannot access org.apache.sshd.server.Command
        cmd.parsePluginConfigValues(Collections.singletonList(in));
           ^
  class file for org.apache.sshd.server.Command not found

Change-Id: I5ca948bcd04b7a5ce7588810d1db151309ed39c4
2015-02-18 06:24:30 +00:00
Martin Fick
f39eb0617e Merge "Split the ChangeHooks interface in 2" 2015-02-12 17:52:30 +00:00
David Pursehouse
6d0ebb8ccb Fix some warnings raised by CheckStyle
- Change ordering of 'static', 'final', etc modifiers according to
  the order suggested by JLS.

- Add comments in empty catch blocks for intentionally ignored
  exceptions.

- Add curly braces around if-else blocks.

- Move `catch` to same line as closing brace of preceding `try`
  blocks.

- Wrap long lines.

Note that this change does not fix all instances of the above errors
across the entire code base.

Change-Id: I24bb9649cc5013c249fa5d84e05322a5cdf2ace6
2015-02-12 19:38:30 +09:00
Martin Fick
bef6c3de3e Split the ChangeHooks interface in 2
The current ChangeHook interface supports methods for event creators and
listeners.  Since creators and listeners are unlikely to be the same
classes, it does not make sense to expose both sets of methods to each
type of user.  While this change will clean things up API wise, it also
paves the way to split out some event firing logic from the ChangeHooks
class.  By splitting this logic it provides a better path to make it
possible for other classes such as a plugins to fire events.

Change-Id: I0906c86fa6ea32aa519b452134d2caddf489df09
2015-02-12 14:24:50 +09:00
David Pursehouse
53484dd635 Register "dropped-output" as an event type
Change-Id: I7cc713809c6cb11007af762e4753b70334f1a044
2015-02-11 13:28:50 +00:00
David Ostrovsky
e9a91bb2ca Add explicit cast to fix compile error on Java 8
Change-Id: I8a35158ee2d70ec2c878621ca35c686ab9fc19f6
2015-02-05 08:19:11 +00:00
David Pursehouse
02ebd1a731 Use StringBuilder instead of concatenation in SshLog
Coverity reports a performance issue caused by using the + operator
to concatenate strings within a loop. See CID 19979 on the coverity
scan project [1].

Refactor it to use a StringBuilder instead.

[1] https://scan.coverity.com/projects/4032

Change-Id: I0db269bfb19d5f84dfc5815f8f286052e2bc6140
2015-02-04 18:36:42 +09:00
David Pursehouse
29be772d35 Use StringBuilder instead of concatenation in ReviewCommand
Coverity reports a performance issue caused by using the + operator
to concatenate strings within a loop. See CID 20069 on the coverity
scan project [1].

Refactor it to use a StringBuilder instead.

[1] https://scan.coverity.com/projects/4032

Change-Id: Ib091b3a1ac8a2404b2d68e88c17c28e31f70475c
2015-02-04 18:36:35 +09:00
David Pursehouse
83d7d3be50 Use StringBuilder instead of concatenation in SetAccountCommand
Coverity reports a performance issue caused by using the + operator
to concatenate strings within a loop. (See CID 20103) on the coverity
scan project [1].

Refactor it to use a StringBuilder instead.

[1] https://scan.coverity.com/projects/4032

Change-Id: Id071ac4d4369e47ca5bf8dcd2d13a9e6f10fd3a5
2015-02-03 16:52:09 +09:00
David Pursehouse
daf0c20030 Merge changes from topic 'events'
* changes:
  Update replication plugin revision
  Add more abstract events to the event hierarchy.
2015-01-27 00:48:59 +00:00