51 Commits

Author SHA1 Message Date
Saša Živkov
1c48a7ee1c Revert "Use javax.inject.Inject instead of com.google.inject.Inject"
This reverts commit 5db3bba3e2d85662bacedc5d2f215fff7d8d2805.

I was too fast to submit 5db3bba. Besides forgetting to submit the
referenced changes in some submodules some people reported issues
with the interception of the javax.inject.Inject in some JEE containers.

Change-Id: I931ad329d2e7be6f6ce804b8395489a021c8240b
2014-09-30 10:53:50 +02:00
Dave Borowitz
5db3bba3e2 Use javax.inject.Inject instead of com.google.inject.Inject
The Guice team is discouraging use of its specific annotation where
possible, to increase JSR330 compliance.

Leave optional injection alone for now, which needs to be manually
replaced with OptionalBinder.

Change-Id: I4f53a518ba6f36fd67af12f3540dc44cbad07ff8
2014-09-29 16:36:18 -07:00
Dave Borowitz
33e391d729 Organize ALL the imports
This was an accident; I had the wrong thing selected in Eclipse when I
pressed Ctrl-Shift-O. It was surprisingly fast and the delta is
surprisingly small so I figured I'd submit it.

Change-Id: I7069f47509c981b59c84755a5aed7945c7f0c9fc
2014-08-20 10:23:06 +09:00
David Ostrovsky
913cc07299 ReceiveCommits: Add support for approvals
Add -l option to magic branch to pass approvals through git push.

One use case is to support Work In Progress (WIP) Workflow backed by
WIP label. In this scenario new label is introduced with (-1,0) range
to mark a change as WIP. This change allows to optionally mark a new
patch set as WIP through `git push`.

With configuration of push macro in .git/config:
  git config remote.wip.url ssh://review.example.com:29418/project
  git config remote.wip.push HEAD:refs/for/master%l=wip-1

WIP patch set can be uploaded with:
  git push wip

Another use case is to do %l=Verified+1 if a change was compiled and
tested locally, e.g.:

  git config alias r '! buck build gerrit && buck test --all && \\
  git push gerrit-review HEAD:refs/for/master%l=Verified+1'

Then all these can be done in one step - compile, run tests and push to
review:

  git r

Change-Id: I52a67993952f32f8a04d9c0226f1c456a6f522b4
2014-05-08 17:08:44 -07:00
David Ostrovsky
e73ae61339 Apply "type inference for generic instance creation" Java 7 feature
Change-Id: Ia14802c903ca67b9d94dc6038d70b0e9644bc621
2014-04-26 15:27:57 +02:00
Shawn Pearce
05cb053378 Save GWT compile time by avoiding javac
GWT only needs the rebind code for CSS and ServerLinker to be
precompiled as bytecode. Save build time by passing no source
files to the java_library() used by gwt_module().

For a full draft build of ui_safari this cuts the refresh time
down from 32.015s to 26.158s on my MacBook. Saving 6s on each
UI reload adds up during development.

The common annotations need to be provided as bytecode, avoiding
spurious warnings from GWT when there is a Java syntax error.

Change-Id: I37826498650c65c05303e7d4d1177d05781c56f6
2013-11-30 11:06:50 -08:00
Shawn Pearce
72fb6cc514 Remove unused .gitignore
These were necessary only for the Maven based build.

Change-Id: Ie26669e6ccae60a52d2db1b8ad362e2fa88a26f2
2013-11-28 22:56:51 -08:00
David Ostrovsky
c53fd3ae49 Delete eclipse left-over files from the Maven poop era
Change-Id: Ie3a75e8c6a2d274cd39e362259ab20cff474eb8d
2013-11-28 22:55:09 -08:00
alex.ryazantsev
bbf93f85cf Remove unnecessary local variables
Change-Id: I20ee3f7258d7e98b9c57b49c21b1e2d1582f626f
2013-11-19 13:56:25 -08:00
David Ostrovsky
985752f232 Bump args4j version to 2.0.26
New version has features which be useful for Gerrit core and plugins:

* new hidden attribute, specifying to hide it in help message
* new depends attribute, specifying the dependent option(s)
* multiValued attribute was removed

Change-Id: Ic7e9f37231cb83940db50fe3b9efe8ad972108cf
2013-11-15 09:58:39 +01:00
Shawn Pearce
57defbb9e5 Remove jsr305 library
In d6ccccf96a238 Sasa Zivkov explained OSGI runtimes do not accept the
javax.annotation.* package to be provided by the application, as part
of the package is already included with the JRE.

Now that Gerrit has its own version of the @Nullable annotation, drop
the jsr305 library dependency.

Change-Id: I253fd74af7a73c5d5bc4a0b35755cc449957e0f2
2013-09-26 23:12:55 -07:00
Sasa Zivkov
d6ccccf96a Add our own Nullable implementation
When deploying Gerrit in an osgi container we see an issue where the
javax.annotation.Nullable annotation is not available at runtime.
As a consequence Guice injection throws an error if a (Nullable)
parameter is null.

A research on that topic reveals that this is caused by the Split
Package issue in osgi [1]. The javax.annotation.* package is split
as one part of it comes from JRE and another one from the jsr305
packaged in gerrit.war.

Since guice supports usage of any Nullable annotation type whose simple
name is "Nullable" [2], we can use own Nullable annotation type.

[1] http://wiki.osgi.org/wiki/Split_Packages
[2] https://code.google.com/p/google-guice/source/browse/core/src/com/google/inject/internal/Nullability.java

Change-Id: I63b27be6d695e73fd92940e42169d09f751d7274
2013-09-26 15:34:27 +00:00
Shawn Pearce
3918177c6b Exclude Guava Maven data and javax sources from Guice JARs
Guice 4.0-beta leaked the maven metadata files for Guava when it was
repacked to a private namespace.  This confuses Buck when creating a
combined JAR that has both Guice and Guava.

Guice also leaked the source files for javax.annotation into its
binary JAR files. Buck sometimes finds and extracts these source
files at compile time, creating duplicate versions of the classes.

Change-Id: Iea0a3394530abd8b0853d016b7cb2f5182f82a96
2013-08-06 09:39:50 -07:00
Shawn Pearce
242a604b9f Make command line option parsing ~6500% faster
Guice does not like to pass an Injector as part of an @Assisted
invocation of an object. More recent versions of Guice are logging
a warning advising a performance boost of ~6500% is possible if
the class stops accepting Injector in the constructor and instead
uses a more concrete type.

In this case Guice was very correct about the code being slow.
Every option declared required a linear scan through the entire
Injector stack looking for any candidate binding that might match
the OptionHandlerFactory signature. This scan ran on each request,
which is incredibly slow.

Build the map once in the injector and retain as a singleton.

Change-Id: Ib620e7bf1e24241bd373d2cb55c89c3fe3284645
2013-08-05 16:14:10 -07:00
David Ostrovsky
dcee57212f Delete Maven based build
The Maven build does not work since the introduction of CodeMirror.
Remove the build until to prevent people from trying to use a broken
build process.  If buck is rejected this commit will be reverted, and
we will attempt to fix the Maven build to include CodeMirror.  If buck
is accepted, we just saved time by avoiding a messy Maven change.

Change-Id: I147d8d1741d52f59de1d2ddce8e5e82583990c14
2013-05-21 20:28:56 -07:00
Shawn Pearce
fec1537a56 Fix metaVar printing in REST API help usage
The metaVar used in @Option annotations was not being respected.
Use this value before asking the handler for its default value.

Change-Id: If0193983b9ebbb646ac325f28fefcb667b4f5bec
2013-05-16 12:59:29 -07:00
Shawn Pearce
fd6bb9f6a5 Build with Buck
Implement a new build system using Buck[1], Facebook's
open source clone of Google's internal build system.

  Pros:
  - Concise build language
  - Test and build output is concise
  - Test failures and stack traces show on terminal
  - Reliable incrementals; clean is unnecessary
  - Extensible with simple blocks of Python
  - Fast
      buck: clean: 0.452s, full 1m21.083s [*], no-op:  7.145s,
      mvn:  clean: 4.596s, full 2m53.776s,     no-op: 59.108s,

      [*] full build includes downloading all dependencies,
          time can vary due to remote server performance.

  Cons:
  - No Windows support
  - No native Maven Central support (added by macros)
  - No native GWT, Prolog, or WAR support (added by macros)
  - Bootstrap of buck requires Ant

Getting started:

  git clone https://gerrit.googlesource.com/buck
  cd buck
  ant

  Mac OS X:
    PATH="`pwd`/bin:/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands:$PATH"

  Linux:
    PATH="`pwd`/bin:$PATH"

Importing into Eclipse:

  $ time buck build :eclipse
  0m48.949s

  Import existing project from `pwd`
  Import 'gerrit' (do not import other Maven based projects)
  Expand 'gerrit'
  Right click 'buck-out' > Properties
  Under Attributes check 'Derived'

  If the code doesn't currently compile but an updated classpath
  is needed, refresh the configs and obtain missing JARs:

  $ buck build :eclipse_project :download

Running JUnit tests:

  $ time buck test --all -e slow  # skip slow tests
  0m19.320s

  $ time buck test --all          # includes acceptance tests
  5m17.517s

Building WAR:

  $ buck build :gerrit
  $ java -jar buck-out/gen/gerrit.war

Building release:

  $ buck test --all && buck build :api :release
  $ java -jar buck-out/gen/release.war
  $ ls -lh buck-out/gen/{extension,plugin}-api.jar

Downloading dependencies:

  Dependencies are normally downloaded automatically, but Buck can
  inspect its graph and download missing dependencies so future
  compiles can run without the network:

  $ buck build :download

[1] http://facebook.github.io/buck/

Change-Id: I40853b108bd8e153cefa0896a5280a9a5ff81655
2013-05-09 13:40:36 +00:00
Shawn Pearce
9240c299f0 Begin 2.8
Change-Id: Ie0bc733853be435fba147dd64ef8cbc5a0027ee0
2013-05-06 19:39:10 -07:00
Shawn Pearce
d47ca8a66d Start 2.7 development
Change-Id: I08dc590bb1f62af67d88eb11313d5d4cfe2423c4
2013-03-21 12:12:47 -07:00
Shawn Pearce
69928a6d06 Add options to refs/for/ magic branch syntax
Git doesn't want to modify the network protocol to support passing
data from the git push client to the server. Work around this by
embedding option data into a new style of reference specification:

  refs/for/master%r=alice,cc=bob,cc=charlie,topic=options

is now parsed by the server as:

  - set topic to "options"
  - CC charlie and bob
  - add reviewer alice
  - for branch refs/heads/master

If % is used the "extra information" after the branch name is
parsed as options with args4j. Each option is delimited by ",".

Selecting publish vs. draft should be done with options draft or
publish, appearing anywhere in the refspec after the % marker:

  refs/for/master%draft
  refs/for/master%draft,r=alice
  refs/for/master%r=alice,draft
  refs/for/master%r=alice,publish

Change-Id: I895bd1218c2099b5b45cac943039bbd12565370c
2013-02-27 16:07:30 -08:00
David Pursehouse
f1264f4192 Suppress Eclipse warning "annotation should not be used as a superinterface"
Change-Id: I4bc6241c2b6ecb2f57907b01f04a14b7672c04ac
2012-12-02 21:01:28 +09:00
Edwin Kempin
59e1ce558d Remove unneeded @SuppressWarnings
Change-Id: Ida5e882100a8f200ec2a0f087929e43d3fc0c6b9
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
2012-11-17 08:36:30 +01:00
Shawn O. Pearce
ea6d0b5a27 Implement new /changes/{id}/action style REST API
All existing JSON APIs are converted to this new style.

/changes/{id} parses the id field from a JSON response from a prior
response and uses that to uniquely identify a change and verify the
caller can see it. If the user requests only /changes/{id}/ then the
data is returned as a single JSON object.

This commit also gives full remote control of plugins using the
/plugins/ namespace:

  PUT /plugins/{name}    (JAR as request body)
  POST /plugins/{name}   (JSON object {url:"https://..."})
  DELETE /plugins/{name}
  GET /plugins/{name}/gerrit~status
  POST /plugins/{name}/gerrit~reload
  POST /plugins/{name}/gerrit~enable
  POST /plugins/{name}/gerrit~disable

The commit provides some project admin commands:

  GET /projects/{name}/description
  PUT /projects/{name}/description

  GET /projects/{name}/parent
  PUT /projects/{name}/parent

Project dashboards have moved:

  GET /projects/{name}/dashboards
  GET /projects/{name}/dashboards/{id}
  GET /projects/{name}/dashboards/default

To access project names containing /, the name must be encoded with
URL encoding, translating / to %2F.

Change-Id: I6a38902ee473003ec637758b7c911f926a2e948a
2012-11-16 12:00:24 -08:00
Edwin Kempin
20f99685d9 Update versions in pom's to start Gerrit 2.6 development
Change-Id: I4fb8cb41250c5b640a8d9e47caf97dc4670ff428
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
2012-08-22 14:09:52 +02:00
Brad Larson
05d942c324 Add ability to parse arguments with parseOptionMap
The RestApiServlet wasn't able to handle command-line parsers which
included required arguments. These can now be specified by passing
a Set of which param names to look for and treat as arguments.

Change-Id: Ia1400c7decbb896f038ab016c063e9ee6e5991d9
Signed-off-by: Brad Larson <bklarson@gmail.com>
2012-07-17 12:29:07 -05:00
Sasa Zivkov
90119f8256 Remove timestamp from all org.eclipse.core.resources.prefs files.
Eclipse overwrites these files when we import projects using m2e.
Eclipse 3 writes a timestamp at the top of these files making the Git
working tree dirty.  Eclipse 4 (Juno) still overwrites these files but
doesn't write the timestamp.  This should help keeping the working tree
clean.  However, since the timestamp is currently present in these
files, Eclispe 4 would still make them dirty by overwriting and
effectively removing the timestamp.

This change removes the timestamp from these files. This help those
using Eclipse 4 and doesn't make it worse for those still using Eclispe
3.

Change-Id: Ic23299a12ac80f7294bcc602c8565889069a0d10
Signed-off-by: Sasa Zivkov <sasa.zivkov@sap.com>
2012-07-04 14:06:09 +02:00
Anatol Pomazau
2f12c650ec Add Intellij IDEA files to ignore list
Change-Id: Ie948a1b3c9df95e79fc09ef343d0d49ff3b267c2
2012-05-03 13:17:43 -07:00
Edwin Kempin
daf6bd9865 Update parent version in pom.xml's to 2.5-SNAPSHOT
Change-Id: I3b2f0f532fc10b98657de117c80113fe0eac3bc4
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
2012-05-03 09:49:17 +02:00
Shawn O. Pearce
c383861a25 Merge changes I6f8b9302,If538bbc8,I4052ade1,Id07b2b62,I2014a220,I577ae60e,I87e58dda,I9a72cd28,Ic72892ae
* changes:
  REST API /projects/$SUGGEST
  REST API /projects/
  REST API /accounts/self/capabilities
  Define a native REST API client
  /projects/: Support JSON output format
  Make ls-projects available on HTTP as GET /projects/
  Support alias "self" in queries
  Update GWT to 2.4.0
  Update Gson to 2.1
2012-04-23 09:14:01 -07:00
Edwin Kempin
df47d04f6a Fix several compiler warning
Fixed compiler warnings by removing unused imports, unused methods
and unneeded annotations for suppressing compiler warnings.

Change-Id: I9dfcd747e3197a01b0de29134f19e85fd78bdaa2
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
2012-04-23 09:04:44 +02:00
Shawn O. Pearce
a041898724 Make ls-projects available on HTTP as GET /projects/
The query string takes the same arguments as the command line tool,
so `ls-projects --type CODE --show-branch foo` can be written out as
`GET /projects/?type=CODE&show-branch=foo`.  Output is identical.

Using /projects/ is anonymous and does not require authentication.
/a/projects/ requires HTTP authentication using the same scheme
that is applied to Git operations over HTTP, typically using the
HTTP password that is generated for a user or SSL certificate auth.

Change-Id: I577ae60eba40cfb358fe41ed8f3cf9481662e738
2012-04-21 20:34:37 -07:00
Sasa Zivkov
17e17dd8b9 Change version in pom.xml to 2.4-SNAPSHOT
The 2.3 was released and what we have in the master branch
is targeted for 2.4.

Change-Id: Idca8a12aaef1dc5ea5f628b3640881e66f04dc9c
Signed-off-by: Sasa Zivkov <sasa.zivkov@sap.com>
2012-04-18 12:55:40 +02:00
Shawn O. Pearce
246461cf4a Support parsing command line options from a map
Given a map of String to String[], like to what an HttpServletRequest
makes available from the query string, feed the values into the parser
and update the bean with the parsed state.

This makes parsing from a query string rather trivial.

Change-Id: I41829d35e59594770c1b6512c241b92182a03afe
2012-04-05 09:18:54 -07:00
Shawn O. Pearce
96511a9ce4 Refactor display of --help/-h to be common
This code was identical in two callers, make it common.

Change-Id: Ieb95a0ed2fd1f504b92ca6a72ea3a6d1bd5ae172
2012-04-05 09:17:27 -07:00
Shawn O. Pearce
2a9ced1f9e Move parsing of --help/-h to CmdLineParser
Make the handling of --help common across all uses of CmdLineParser.
This will eventually make it easier to support more complex parsing
cases that need to span objects.

Change-Id: I38b153035cfc5cce80ca631be66c8b4d4683590d
2012-04-05 09:17:25 -07:00
Colby Ranger
b30883860d Updated to gwtorm 1.4.
Refactored the GWT client code to include only what the gerrit GWT
client. The gerrit GWT build was giving build warnings since the
getAsync() signature and implementation used types that were
not available to GWT.

Split the reviewdb into a client and server package.

Organized the imports to ease the migration.

Change-Id: I6cd6125eddcb1dd2b5c5e353edf163544248026b
2012-03-07 12:50:47 -08:00
Colby Ranger
7820803a0d Updated to Guice 3.0.
Use the new FactoryModuleBuilder everywhere, instead of FactoryProvider.

Updated the OptionHandlers to be generic, instead of ignoring the type
parameter.

Removed the GuiceHelper and refactored the HttpLog implementation to
depend on a request attribute for passing the current user.

Change-Id: Ic7d94118c7ab6c46fa784b88acefd7434bb58a44
2012-03-07 12:37:05 -08:00
Martin Fick
7f7eadff20 Update poms to Gerrit 2.3-SNAPSHOT
Change-Id: I6f54a783959c58fb75114251e07a6871bc889904
2012-02-22 17:19:32 -07:00
Mohan Zhang
3a6dbe93c3 Add entries to .gitignore for m2e settings/preference files
Change-Id: Ie70c285440b6200ad7f4dd8dea8a97317e1e62fc
2011-12-12 16:56:53 -06:00
Eric Anderson
a68b89fd53 Updating eclipse settings for 3.7 and m2e 1.0
Change-Id: Ic0f134719769e3d8b8cfb6f70703f9a61fcd2538
2011-07-29 08:29:51 -07:00
Shawn O. Pearce
4e67700dab Change version to 2.2-SNAPSHOT
Change-Id: I1d3e6c42bc678536162a81d2b13372659a1c3dec
Signed-off-by: Shawn O. Pearce <sop@google.com>
2011-05-31 10:30:57 -07:00
Shawn O. Pearce
bd8e5c1e8b Fix more rawtype warnings
Change-Id: I50e401a7a604dde7bfad63639bdadb29c2b8a4a9
Signed-off-by: Shawn O. Pearce <sop@google.com>
2011-05-19 09:58:35 -07:00
Nasser Grainawi
3755e9fd85 Remove unnecessary warning suppression
Change-Id: Iac493ad8be46d29e82ffb3007aadf25a49debfa8
2011-05-19 08:06:40 -07:00
Shawn O. Pearce
f855f399f8 Fix all of our pom.xml versions to be 2.1-SNAPSHOT
I meant to keep reusing the 2.1 version number for the entire
2.1 series during development, but botched it during the 2.1.4
development cycle and set it to 2.1.4-SNAPSHOT by mistake.  Put
it back to 2.1-SNAPSHOT since 2.1.4 is released.

Change-Id: I37e206c0609bf3fd94a5aab8ea301c98b7fb013e
Signed-off-by: Shawn O. Pearce <sop@google.com>
2010-08-12 16:24:43 -07:00
Shawn O. Pearce
faee655254 Start 2.1.4 development
Change-Id: I71719c85b0d50707333517b8ef956853b04efa14
Signed-off-by: Shawn O. Pearce <sop@google.com>
2010-06-21 17:41:54 -07:00
Shawn O. Pearce
f51d48c111 gerrit 2.1.3
Change-Id: I93386d5b71e8361219c03d95ab7476dc46e7d6b0
Signed-off-by: Shawn O. Pearce <sop@google.com>
2010-06-21 14:40:34 -07:00
Shawn O. Pearce
9ead06f525 Teach all ssh commands to stop option parsing on --
Using -- as a way to break the option parser and start doing
argument parsing is very common.  Teach all of our commands
to work that way.

Change-Id: Iaeb1be2ee443fce7f09a9eff6dd7270e1ba91509
Signed-off-by: Shawn O. Pearce <sop@google.com>
2010-01-16 14:04:45 -08:00
Shawn O. Pearce
0e060b257d Start next release development
Change-Id: I5a69e2b7a3e64664f0ca32649d153cb8cde27b27
Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-12-21 13:27:30 -08:00
Shawn O. Pearce
a02df64b0f gerrit 2.1
Change-Id: Ic864f71b0899af24334c76b8558c2757a2f79750
Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-12-21 11:19:02 -08:00
Shawn O. Pearce
3b279fa8d8 Call the next version 2.1
We've changed so much since the 2.0.24 release that I'm really not
comfortable calling it 2.0.25.

Change-Id: I9cf28b0a97e0f74838bf893b79ce3105e0a7bfdb
Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-12-12 20:17:29 -08:00