Merge "FreeIPA as ldap backend"
diff --git a/.bazelproject b/.bazelproject
index bb2a1a6..41bb27f 100644
--- a/.bazelproject
+++ b/.bazelproject
@@ -11,10 +11,6 @@
-./.metadata
-./.settings
-./.apt_generated
- # BUCK excludes; Remove after we have entirely switched to Bazel
- -./.buckd
- -bucklets
- -buck-out
targets:
//...:all
diff --git a/.buckconfig b/.buckconfig
deleted file mode 100644
index 11cfe37..0000000
--- a/.buckconfig
+++ /dev/null
@@ -1,37 +0,0 @@
-[alias]
- api = //:api
- chrome = //:chrome
- docs = //Documentation:searchfree
- firefox = //:firefox
- gerrit = //:gerrit
- gwtgerrit = //:gwtgerrit
- headless = //:headless
- polygerrit = //:polygerrit
- release = //:release
- releasenotes = //ReleaseNotes:html
- safari = //:safari
- soyc = //gerrit-gwtui:ui_soyc
- soyc_r = //gerrit-gwtui:ui_soyc_r
- withdocs = //:withdocs
-
-[buildfile]
- includes = //tools/default.defs
-
-[java]
- jar_spool_mode = direct_to_jar
- safe_annotation_processors = com.google.auto.value.processor.AutoAnnotationProcessor,com.google.auto.value.processor.AutoValueProcessor
- src_roots = java, resources, src
- source_level = 8
- target_level = 8
-
-[project]
- allow_symlinks = allow
- ignore = .git, eclipse-out, bazel-gerrit, bin
- parallel_parsing = true
-
-[cache]
- mode = dir
- dir = ~/.gerritcodereview/buck-cache/locally-built-artifacts
-
-[test]
- excluded_labels = manual
diff --git a/.buckversion b/.buckversion
deleted file mode 100644
index 7eb591f..0000000
--- a/.buckversion
+++ /dev/null
@@ -1 +0,0 @@
-e27df656657f93f8d57a7aaac69a5ae0e298a292
diff --git a/.gitignore b/.gitignore
index 4ce6ab2..f6cd978 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,16 +12,11 @@
*.eml
*.sublime-*
/gerrit-package-plugins
-/.buckconfig.local
-/.buckjavaargs
-/.buckd
/bazel-bin
/bazel-genfiles
/bazel-gerrit
/bazel-out
/bazel-testlogs
-/buck-cache
-/buck-out
/eclipse-out
/extras
/infer-out
diff --git a/.watchmanconfig b/.watchmanconfig
deleted file mode 100644
index 4467aec..0000000
--- a/.watchmanconfig
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "ignore_dirs": [
- "buck-out",
- "eclipse-out"
- ],
- "ignore_vcs": [
- ".git"
- ]
-}
diff --git a/BUCK b/BUCK
deleted file mode 100644
index 9657ff3..0000000
--- a/BUCK
+++ /dev/null
@@ -1,31 +0,0 @@
-include_defs('//tools/build.defs')
-
-gerrit_war(name = 'gerrit')
-gerrit_war(name = 'gwtgerrit', ui = 'ui_dbg')
-gerrit_war(name = 'headless', ui = None)
-gerrit_war(name = 'chrome', ui = 'ui_chrome')
-gerrit_war(name = 'firefox', ui = 'ui_firefox')
-gerrit_war(name = 'safari', ui = 'ui_safari')
-gerrit_war(name = 'polygerrit', ui = 'polygerrit')
-gerrit_war(name = 'withdocs', docs = True)
-gerrit_war(name = 'release', ui = 'ui_optdbg_r', docs = True, context = ['//plugins:core'], visibility = ['//tools/maven:'])
-
-API_DEPS = [
- '//gerrit-acceptance-framework:acceptance-framework',
- '//gerrit-acceptance-framework:acceptance-framework-src',
- '//gerrit-acceptance-framework:acceptance-framework-javadoc',
- '//gerrit-extension-api:extension-api',
- '//gerrit-extension-api:extension-api-src',
- '//gerrit-extension-api:extension-api-javadoc',
- '//gerrit-plugin-api:plugin-api',
- '//gerrit-plugin-api:plugin-api-src',
- '//gerrit-plugin-api:plugin-api-javadoc',
- '//gerrit-plugin-gwtui:gwtui-api',
- '//gerrit-plugin-gwtui:gwtui-api-src',
- '//gerrit-plugin-gwtui:gwtui-api-javadoc',
-]
-
-zip_file(
- name = 'api',
- srcs = API_DEPS,
-)
diff --git a/Documentation/BUCK b/Documentation/BUCK
deleted file mode 100644
index 48ca579..0000000
--- a/Documentation/BUCK
+++ /dev/null
@@ -1,80 +0,0 @@
-include_defs('//Documentation/asciidoc.defs')
-include_defs('//Documentation/config.defs')
-include_defs('//Documentation/license.defs')
-include_defs('//tools/git.defs')
-
-DOC_DIR = 'Documentation'
-
-JSUI_JAVA_DEPS = ['//gerrit-gwtui:ui_module']
-JSUI_NON_JAVA_DEPS = ['//polygerrit-ui/app:polygerrit_ui']
-MAIN_JAVA_DEPS = ['//gerrit-pgm:pgm']
-SRCS = glob(['*.txt'], excludes = ['licenses.txt'])
-
-
-genasciidoc(
- name = 'html',
- out = 'html.zip',
- directory = DOC_DIR,
- srcs = SRCS + [':licenses.txt'],
- attributes = documentation_attributes(git_describe()),
- backend = 'html5',
- visibility = ['PUBLIC'],
-)
-
-genasciidoc(
- name = 'searchfree',
- out = 'searchfree.zip',
- directory = DOC_DIR,
- srcs = SRCS + [':licenses.txt'],
- attributes = documentation_attributes(git_describe()),
- backend = 'html5',
- searchbox = False,
- visibility = ['PUBLIC'],
-)
-
-genlicenses(
- name = 'licenses.txt',
- opts = ['--asciidoc'],
- java_deps = JSUI_JAVA_DEPS + MAIN_JAVA_DEPS,
- non_java_deps = JSUI_NON_JAVA_DEPS,
- out = 'licenses.txt',
-)
-
-# Required by Google for gerrit-review.
-genlicenses(
- name = 'js_licenses.txt',
- opts = ['--partial'],
- java_deps = JSUI_JAVA_DEPS,
- non_java_deps = JSUI_NON_JAVA_DEPS,
- out = 'js_licenses.txt',
-)
-
-python_binary(
- name = 'gen_licenses',
- main = 'gen_licenses.py',
-)
-
-python_binary(
- name = 'replace_macros',
- main = 'replace_macros.py',
- visibility = ['//ReleaseNotes:'],
-)
-
-genrule(
- name = 'index',
- cmd = '$(exe //lib/asciidoctor:doc_indexer) ' +
- '-o $OUT ' +
- '--prefix "%s/" ' % DOC_DIR +
- '--in-ext ".txt" ' +
- '--out-ext ".html" ' +
- '$SRCS ' +
- '$(location :licenses.txt)',
- srcs = SRCS,
- out = 'index.jar',
-)
-
-prebuilt_jar(
- name = 'index_lib',
- binary_jar = ':index',
- visibility = ['PUBLIC'],
-)
diff --git a/Documentation/asciidoc.defs b/Documentation/asciidoc.defs
deleted file mode 100644
index 4b17071..0000000
--- a/Documentation/asciidoc.defs
+++ /dev/null
@@ -1,113 +0,0 @@
-# Copyright (C) 2013 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-def genasciidoc_htmlonly(
- name,
- out,
- srcs = [],
- attributes = [],
- backend = None,
- searchbox = True,
- visibility = []):
- EXPN = '.' + name + '_expn'
-
- asciidoc = [
- '$(exe //lib/asciidoctor:asciidoc)',
- '-z', '$OUT',
- '--base-dir', '$SRCDIR',
- '--tmp', '$TMP',
- '--in-ext', '".txt%s"' % EXPN,
- '--out-ext', '".html"',
- ]
- if backend:
- asciidoc.extend(['-b', backend])
- for attribute in attributes:
- asciidoc.extend(['-a', attribute])
- asciidoc.append('$SRCS')
- newsrcs = []
- for src in srcs:
- fn = src
- # We have two cases: regular source files and generated files.
- # Generated files are passed as targets ':foo', and ':' is removed.
- # 1. regular files: cmd = '-s foo', srcs = ['foo']
- # 2. generated files: cmd = '-s $(location :foo)', srcs = []
- srcs = [src]
- passed_src = fn
- if fn.startswith(':') :
- fn = src[1:]
- srcs = []
- passed_src = '$(location :%s)' % fn
- ex = fn + EXPN
-
- genrule(
- name = ex,
- cmd = '$(exe //Documentation:replace_macros) --suffix="%s"' % EXPN +
- ' -s ' + passed_src + ' -o $OUT' +
- (' --searchbox' if searchbox else ' --no-searchbox'),
- srcs = srcs,
- out = ex,
- )
-
- newsrcs.append(':%s' % ex)
-
- genrule(
- name = name,
- cmd = ' '.join(asciidoc),
- srcs = newsrcs,
- out = out,
- visibility = visibility,
- )
-
-def genasciidoc(
- name,
- out,
- directory,
- srcs = [],
- attributes = [],
- backend = None,
- searchbox = True,
- resources = True,
- visibility = []):
- SUFFIX = '_htmlonly'
-
- genasciidoc_htmlonly(
- name = name + SUFFIX if resources else name,
- srcs = srcs,
- attributes = attributes,
- backend = backend,
- searchbox = searchbox,
- out = (name + SUFFIX + '.zip') if resources else (name + '.zip'),
- )
-
- if resources:
- genrule(
- name = name,
- cmd = 'cd $TMP;' +
- 'mkdir -p %s/images;' % directory +
- 'unzip -q $(location %s) -d %s/;'
- % (':' + name + SUFFIX, directory) +
- 'for s in $SRCS;do ln -s $s %s/;done;' % directory +
- 'mv %s/*.{jpg,png} %s/images;' % (directory, directory) +
- 'cp $(location %s) LICENSES.txt;' % ':licenses.txt' +
- 'zip -qr $OUT *',
- srcs = glob([
- 'images/*.jpg',
- 'images/*.png',
- ]) + [
- '//gerrit-prettify:prettify.min.css',
- '//gerrit-prettify:prettify.min.js',
- ],
- out = out,
- visibility = visibility,
- )
diff --git a/Documentation/config-auto-site-initialization.txt b/Documentation/config-auto-site-initialization.txt
index abd8d8f..e55d93f 100644
--- a/Documentation/config-auto-site-initialization.txt
+++ b/Documentation/config-auto-site-initialization.txt
@@ -8,20 +8,20 @@
plugins will be installed when Gerrit is deployed in a servlet container
and the location of the Gerrit distribution can be determined at
runtime. It is also possible to install only a subset of packaged
-plugins or not install any plugin.
+plugins or not install any plugins.
This feature may be useful for such setups where Gerrit administrators
don't have direct access to the database and the file system of the
server where Gerrit should be deployed and, therefore, cannot perform
the init from their local machine prior to deploying Gerrit on such a
server. It may also make deployment and testing in a local servlet
-container faster to setup as the init step could be skipped.
+container faster to set up as the init step could be skipped.
== Gerrit Configuration
The site initialization will be performed only if the `gerrit.init`
-system property exists (the value of the property is not used, only the
-existence of the property matters).
+system property exists. The value of the property is not used; only the
+existence of the property matters.
If the `gerrit.site_path` system property is defined then the init is
run for that site. The database connectivity, in that case, is defined
@@ -44,17 +44,17 @@
Defining the `jdbc/ReviewDb` JNDI property for an H2 database under the
path defined by either `gerrit.site_path` or `gerrit.init_path` will
cause an incomplete auto initialization and Gerrit will fail to start.
-Opening a connection to such database will create a subfolder under the
+Opening a connection to such a database will create a subfolder under the
site path folder (in order to create the H2 database) and Gerrit will
-not any more consider that site path to be new and, because of that,
+no longer consider that site path to be new and, because of that,
skip some required initialization steps (for example, Lucene index
creation). In order to auto initialize Gerrit with an embedded H2
database use the `gerrit.site_path` to define the location of the review
site and don't define a JNDI resource with a URL under that path.
-If the 'gerrit.install_plugins' property is not defined then all packaged
+If the `gerrit.install_plugins` property is not defined then all packaged
plugins will be installed. If it is defined then it is parsed as a
-comma separated list of plugin names to install. If the value is an
+comma-separated list of plugin names to install. If the value is an
empty string then no plugin will be installed.
=== Example 1
diff --git a/Documentation/config.defs b/Documentation/config.defs
deleted file mode 100644
index 7f814d3..0000000
--- a/Documentation/config.defs
+++ /dev/null
@@ -1,22 +0,0 @@
-DOCUMENTATION_DEPS = {
- "install-quick.txt": ["config-login-register.txt"],
- "install.txt": ["database-setup.txt"],
-}
-
-def documentation_attributes(revision):
- return [
- 'toc',
- 'newline="\\n"',
- 'asterisk="*"',
- 'plus="+"',
- 'caret="^"',
- 'startsb="["',
- 'endsb="]"',
- 'tilde="~"',
- 'last-update-label!',
- 'source-highlighter=prettify',
- 'stylesheet=DEFAULT',
- 'linkcss=true',
- 'prettifydir=.',
- 'revnumber="%s"' % revision,
- ]
diff --git a/Documentation/dev-bazel.txt b/Documentation/dev-bazel.txt
index e88697c..39a8d13 100644
--- a/Documentation/dev-bazel.txt
+++ b/Documentation/dev-bazel.txt
@@ -32,6 +32,10 @@
bazel build gerrit
----
+[NOTE]
+PolyGerrit UI may require additional tools (such as npm). Please read
+the polygerrit-ui/README.md for more info.
+
The output executable WAR will be placed in:
----
@@ -86,13 +90,13 @@
Install {extension,plugin,gwt}-api to the local maven repository:
----
- tools/maven/api.sh install bazel
+ tools/maven/api.sh install
----
Install gerrit.war to the local maven repository:
----
- tools/maven/api.sh war_install bazel
+ tools/maven/api.sh war_install
----
=== Plugins
@@ -145,7 +149,7 @@
Create the Eclipse project:
----
- tools/eclipse/project_bzl.py
+ tools/eclipse/project.py
----
and then follow the link:dev-eclipse.html#setup[setup instructions].
@@ -154,7 +158,7 @@
If an updated classpath is needed, the Eclipse project can be
refreshed and missing dependency JARs can be downloaded by running
-`project_bzl.py` again. For IntelliJ, you need to click the `Sync Project
+`project.py` again. For IntelliJ, you need to click the `Sync Project
with BUILD Files` button of link:https://ij.bazel.io[IntelliJ plugin].
[[documentation]]
diff --git a/Documentation/dev-buck.txt b/Documentation/dev-buck.txt
deleted file mode 100644
index a74f837..0000000
--- a/Documentation/dev-buck.txt
+++ /dev/null
@@ -1,735 +0,0 @@
-= Gerrit Code Review - Building with Buck
-
-
-== Installation
-
-You need to use Java 8 and Node.js for building gerrit.
-
-There is currently no binary distribution of Buck, so it has to be manually
-built and installed. Apache Ant and gcc are required. Currently only Linux
-and Mac OS are supported.
-
-Clone the git and build it:
-
-----
- git clone https://github.com/facebook/buck
- cd buck
- git checkout $(cat ../gerrit/.buckversion)
- ant
-----
-
-If you don't have a `bin/` directory in your home directory, create one:
-
-----
- mkdir ~/bin
-----
-
-Add the `~/bin` folder to the path:
-
-----
- PATH=~/bin:$PATH
-----
-
-Note that the buck executable needs to be available in all shell sessions,
-so also make sure it is appended to the path globally.
-
-Add a symbolic link in `~/bin` to the buck and buckd executables:
-
-----
- ln -s `pwd`/bin/buck ~/bin/
- ln -s `pwd`/bin/buckd ~/bin/
-----
-
-Verify that `buck` is accessible:
-
-----
- which buck
-----
-
-To enable autocompletion of buck commands, install the autocompletion
-script from `./scripts/buck-completion.bash` in the buck project. Refer
-to the script's header comments for installation instructions.
-
-== Prerequisites
-
-Buck requires Python version 2.7 to be installed. The Maven download toolchain
-requires `curl` to be installed.
-
-[[eclipse]]
-== Eclipse Integration
-
-
-=== Generating the Eclipse Project
-
-Create the Eclipse project:
-
-----
- tools/eclipse/project.py
-----
-
-and then follow the link:dev-eclipse.html#setup[setup instructions].
-
-=== Refreshing the Classpath
-
-If an updated classpath is needed, the Eclipse project can be
-refreshed and missing dependency JARs can be downloaded:
-
-----
- tools/eclipse/project.py
-----
-
-
-=== Attaching Sources
-
-Source JARs are downloaded by default. This allows Eclipse to show
-documentation or dive into the implementation of a library JAR.
-
-To save time and bandwidth, download of source JARs can be restricted
-to only those that are necessary to compile Java source into JavaScript
-using the GWT compiler:
-
-----
- tools/eclipse/project.py --no-src
-----
-
-
-[[build]]
-== Building on the Command Line
-
-
-=== Gerrit Development WAR File
-
-To build the Gerrit web application that includes GWT UI and PolyGerrit UI:
-
-----
- buck build gerrit
-----
-
-[NOTE]
-PolyGerrit UI may require additional tools (such as npm). Please read
-the polygerrit-ui/README.md for more info.
-
-The output executable WAR will be placed in:
-
-----
- buck-out/gen/gerrit/gerrit.war
-----
-
-To build the Gerrit web application that includes only GWT UI:
-
-----
- buck build gwtgerrit
-----
-
-The output executable WAR will be placed in:
-
-----
- buck-out/gen/gwtgerrit/gwtgerrit.war
-----
-
-
-=== Headless Mode
-
-To build Gerrit in headless mode, i.e. without the GWT Web UI:
-
-----
- buck build headless
-----
-
-The output executable WAR will be placed in:
-
-----
- buck-out/gen/headless/headless.war
-----
-
-=== Extension and Plugin API JAR Files
-
-To build the extension, plugin and GWT API JAR files:
-
-----
- buck build api
-----
-
-Java binaries, Java sources and Java docs are generated into corresponding
-project directories in `buck-out/gen`, here as example for plugin API:
-
-----
- buck-out/gen/gerrit-plugin-api/plugin-api.jar
- buck-out/gen/gerrit-plugin-api/plugin-api-javadoc/plugin-api-javadoc.jar
- buck-out/gen/gerrit-plugin-api/plugin-api-src.jar
-----
-
-Install {extension,plugin,gwt}-api to the local maven repository:
-
-----
- tools/maven/api.sh install
-----
-
-Install gerrit.war to the local maven repository:
-
-----
- tools/maven/api.sh war_install
-----
-
-=== Plugins
-
-To build all core plugins:
-
-----
- buck build plugins:core
-----
-
-The output JAR files for individual plugins will be placed in:
-
-----
- buck-out/gen/plugins/<name>/<name>.jar
-----
-
-The JAR files will also be packaged in:
-
-----
- buck-out/gen/plugins/core/core.zip
-----
-
-To build a specific plugin:
-
-----
- buck build plugins/<name>:<name>
-----
-
-The output JAR file will be be placed in:
-
-----
- buck-out/gen/plugins/<name>/<name>.jar
-----
-
-Note that when building an individual plugin, the `core.zip` package
-is not regenerated.
-
-Additional plugins with BUCK files can be added to the build
-environment by cloning the source repository into the plugins
-subdirectory:
-
-----
- git clone https://gerrit.googlesource.com/plugins/<name> plugins/<name>
- echo /plugins/<name> >>.git/info/exclude
-----
-
-Additional plugin sources will be automatically added to Eclipse the
-next time project.py is run:
-
-----
- tools/eclipse/project.py
-----
-
-
-[[documentation]]
-=== Documentation
-
-To build only the documentation for testing or static hosting:
-
-----
- buck build docs
-----
-
-The generated html files will NOT come with the search box, and will be
-placed in:
-
-----
- buck-out/gen/Documentation/searchfree__tmp/Documentation
-----
-
-The html files will also be bundled into `searchfree.zip` in this location:
-
-----
- buck-out/gen/Documentation/searchfree/searchfree.zip
-----
-
-To build the executable WAR with the documentation included:
-
-----
- buck build withdocs
-----
-
-The WAR file will be placed in:
-
-----
- buck-out/gen/withdocs/withdocs.war
-----
-
-[[soyc]]
-=== GWT Compile Report
-
-The GWT compiler can output a compile report (or "story of your compile"),
-describing the size of the JavaScript and which source classes contributed
-to the overall download size.
-
-----
- buck build soyc
-----
-
-The report will be written as an HTML page to the extras directory, and
-can be opened and viewed in any web browser:
-
-----
- extras/gerrit_ui/soycReport/compile-report/index.html
-----
-
-Only the "Split Point Report" is created, "Compiler Metrics" are not output.
-
-[[release]]
-=== Gerrit Release WAR File
-
-To build the release of the Gerrit web application, including documentation and
-all core plugins:
-
-----
- buck build release
-----
-
-The output release WAR will be placed in:
-
-----
- buck-out/gen/release/release.war
-----
-
-[[tests]]
-== Running Unit Tests
-
-To run all tests including acceptance tests (but not flaky tests):
-
-----
- buck test --exclude flaky
-----
-
-To exclude flaky and slow tests:
-
-----
- buck test --exclude flaky slow
-----
-
-To run only a specific group of acceptance tests:
-
-----
- buck test --include api
-----
-
-The following groups of tests are currently supported:
-
-* acceptance
-* api
-* edit
-* flaky
-* git
-* pgm
-* rest
-* server
-* ssh
-* slow
-
-To run a specific test group, e.g. the rest-account test group:
-
-----
- buck test //gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/account:rest-account
-----
-
-To create test coverage report:
-
-----
- buck test --code-coverage --code-coverage-format html --no-results-cache
-----
-
-The HTML report is created in `buck-out/gen/jacoco/code-coverage/index.html`.
-
-To run the tests against NoteDb backend:
-
-----
- GERRIT_NOTEDB=READ_WRITE buck test
-----
-
-To run only tests that do not use SSH:
-
-----
- GERRIT_USE_SSH=NO buck test
-----
-
-== Dependencies
-
-Dependency JARs are normally downloaded automatically, but Buck can inspect
-its graph and download any missing JAR files. This is useful to enable
-subsequent builds to run without network access:
-
-----
- tools/download_all.py
-----
-
-When downloading from behind a proxy (which is common in some corporate
-environments), it might be necessary to explicitly specify the proxy that
-is then used by `curl`:
-
-----
- export http_proxy=http://<proxy_user_id>:<proxy_password>@<proxy_server>:<proxy_port>
-----
-
-Redirection to local mirrors of Maven Central and the Gerrit storage
-bucket is supported by defining specific properties in
-`local.properties`, a file that is not tracked by Git:
-
-----
- echo download.GERRIT = http://nexus.my-company.com/ >>local.properties
- echo download.MAVEN_CENTRAL = http://nexus.my-company.com/ >>local.properties
-----
-
-The `local.properties` file may be placed in the root of the gerrit repository
-being built, or in `~/.gerritcodereview/`. The file in the root of the gerrit
-repository has precedence.
-
-== Building against unpublished Maven JARs
-
-To build against unpublished Maven JARs, like gwtorm or PrologCafe, the custom
-JARs must be installed in the local Maven repository (`mvn clean install`) and
-`maven_jar()` must be updated to point to the `MAVEN_LOCAL` Maven repository for
-that artifact:
-
-[source,python]
-----
- maven_jar(
- name = 'gwtorm',
- id = 'gwtorm:gwtorm:42',
- license = 'Apache2.0',
- repository = MAVEN_LOCAL,
- )
-----
-
-== Building against artifacts from custom Maven repositories
-
-To build against custom Maven repositories, two modes of operations are
-supported: with rewrite in local.properties and without.
-
-Without rewrite the URL of custom Maven repository can be directly passed
-to the maven_jar() function:
-
-[source,python]
-----
- GERRIT_FORGE = 'http://gerritforge.com/snapshot'
-
- maven_jar(
- name = 'gitblit',
- id = 'com.gitblit:gitblit:1.4.0',
- sha1 = '1b130dbf5578ace37507430a4a523f6594bf34fa',
- license = 'Apache2.0',
- repository = GERRIT_FORGE,
- )
-----
-
-When the custom URL has to be rewritten, then the same logic as with Gerrit
-known Maven repository is used: Repo name must be defined that matches an entry
-in local.properties file:
-
-----
- download.GERRIT_FORGE = http://my.company.mirror/gerrit-forge
-----
-
-And corresponding BUCK excerpt:
-
-[source,python]
-----
- GERRIT_FORGE = 'GERRIT_FORGE:'
-
- maven_jar(
- name = 'gitblit',
- id = 'com.gitblit:gitblit:1.4.0',
- sha1 = '1b130dbf5578ace37507430a4a523f6594bf34fa',
- license = 'Apache2.0',
- repository = GERRIT_FORGE,
- )
-----
-
-=== Caching Build Results
-
-Build results can be locally cached, saving rebuild time when
-switching between Git branches. Buck's documentation covers
-caching in link:http://facebook.github.io/buck/concept/buckconfig.html[buckconfig].
-The trivial case using a local directory is:
-
-----
- cat >.buckconfig.local <<EOF
- [cache]
- mode = dir
- dir = buck-cache
- EOF
-----
-
-[[clean-cache]]
-=== Cleaning The Buck Cache
-
-The cache for the Gerrit Code Review project is located in
-`~/.gerritcodereview/buck-cache/locally-built-artifacts`.
-
-The Buck cache should never need to be manually deleted. If you find yourself
-deleting the Buck cache regularly, then it is likely that there is something
-wrong with your environment or your workflow.
-
-If you really do need to clean the cache manually, then:
-
-----
- rm -rf ~/.gerritcodereview/buck-cache/locally-built-artifacts
-----
-
-Note that the root `buck-cache` folder should not be deleted as it also contains
-the `downloaded-artifacts` directory, which holds the artifacts that got
-downloaded (not built locally).
-
-[[buck-daemon]]
-=== Using Buck daemon
-
-Buck ships with a daemon command `buckd`, which uses the
-link:https://github.com/martylamb/nailgun[Nailgun] protocol for running
-Java programs from the command line without incurring the JVM startup
-overhead.
-
-Using a Buck daemon can save significant amounts of time as it avoids the
-overhead of starting a Java virtual machine, loading the buck class files
-and parsing the build files for each command.
-
-It is safe to run several buck daemons started from different project
-directories and they will not interfere with each other. Buck's documentation
-covers daemon in http://facebook.github.io/buck/command/buckd.html[buckd].
-
-To use `buckd` the additional
-link:https://facebook.github.io/watchman[watchman] program must be installed.
-
-To disable `buckd`, the environment variable `NO_BUCKD` must be set. It's not
-recommended to put it in the shell config, as it can be forgotten about it and
-then assumed Buck was working as it should when it should be using buckd.
-Prepend the variable to Buck invocation instead:
-
-----
- NO_BUCKD=1 buck build gerrit
-----
-
-[[watchman]]
-=== Installing watchman
-
-Watchman is used internally by Buck to monitor directory trees and is needed
-for buck daemon to work properly. Because buckd is activated by default in the
-latest version of Buck, it searches for the watchman executable in the
-path and issues a warning when it is not found and kills buckd.
-
-To prepare watchman installation on Linux:
-
-----
- git clone https://github.com/facebook/watchman.git
- cd watchman
- ./autogen.sh
-----
-
-To install it in user home directory (without root privileges):
-
-----
- ./configure --prefix $HOME/watchman
- make install
-----
-
-To install it system wide:
-
-----
- ./configure
- make
- sudo make install
-----
-
-Put $HOME/watchman/bin/watchman in path or link to $HOME/bin/watchman.
-
-To install watchman on OS X:
-
-----
- brew install --HEAD watchman
-----
-
-See the original documentation for more information:
-link:https://facebook.github.io/watchman/docs/install.html[Watchman
-installation].
-
-=== Override Buck's settings
-
-Additional JVM args for Buck can be set in `.buckjavaargs` in the
-project root directory. For example to override Buck's default 1GB
-heap size:
-
-----
- cat > .buckjavaargs <<EOF
- -Xms8000m -Xmx16000m
- EOF
-----
-
-== Rerun unit tests
-
-Test execution results are cached by Buck. If a test that was already run
-needs to be repeated, the unit test cache for that test must be removed first:
-
-----
- rm -rf buck-out/bin/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/account/.rest-account/
-----
-
-After clearing the cache, the test can be run again:
-
-----
- buck test //gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/account:rest-account
- [-] TESTING...FINISHED 12,3s (12 PASS/0 FAIL)
- RESULTS FOR //gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/account:rest-account
- PASS 970ms 2 Passed 0 Skipped 0 Failed com.google.gerrit.acceptance.rest.account.CapabilitiesIT
- PASS 999ms 1 Passed 0 Skipped 0 Failed com.google.gerrit.acceptance.rest.account.EditPreferencesIT
- PASS 1,2s 1 Passed 0 Skipped 0 Failed com.google.gerrit.acceptance.rest.account.GetAccountDetailIT
- PASS 951ms 2 Passed 0 Skipped 0 Failed com.google.gerrit.acceptance.rest.account.GetAccountIT
- PASS 6,4s 2 Passed 0 Skipped 0 Failed com.google.gerrit.acceptance.rest.account.GetDiffPreferencesIT
- PASS 1,2s 4 Passed 0 Skipped 0 Failed com.google.gerrit.acceptance.rest.account.PutUsernameIT
- TESTS PASSED
-----
-
-An alternative approach is to use Buck's `--filters` (`-f`) option:
-
-----
- buck test -f 'com.google.gerrit.acceptance.rest.account.CapabilitiesIT'
- Using buckd.
- [-] PROCESSING BUCK FILES...FINISHED 1,0s [100%]
- [-] BUILDING...FINISHED 2,8s [100%] (334/701 JOBS, 110 UPDATED, 5,1% CACHE MISS)
- [-] TESTING...FINISHED 9,2s (6 PASS/0 FAIL)
- RESULTS FOR SELECTED TESTS
- PASS 8,0s 2 Passed 0 Skipped 0 Failed com.google.gerrit.acceptance.rest.account.CapabilitiesIT
- PASS <100ms 4 Passed 0 Skipped 0 Failed //tools:util_test
- TESTS PASSED
-----
-
-When this option is used, the cache is disabled per design and doesn't need to
-be explicitly deleted. Note, that this is a known issue, that python tests are
-always executed.
-
-Note that when this option is used, the whole unit test cache is dropped, so
-repeating the
-
-----
-buck test
-----
-
-causes all tests to be executed again.
-
-To run tests without using cached results at all, use the `--no-results-cache`
-option:
-
-----
-buck test --no-results-cache
-----
-
-== Cross-compiling Java8 to Java7
-
-After switching to Java8, we should take care to not end up
-with Java8 code in stable branches. We assume that we don't
-really want to switch java versions locally every time we switch
-branches.
-
-Given that source level on 'stable-2.13' is 7, source level incompatibility
-will be already correctly detected, so that Java8 compiler would refuse
-to compile lambdas with -source 7 argument. However, unless bootclasspath
-is adjusted to point to Java7 runtime, it's possible to end up with broken
-code, that would compile with Java8 but will not run on Java7 runtime.
-
-To prevent this, add this line to your '.buckconfig.local' in the Gerrit
-source root directory when working on stable branches:
-
-----
-[java]
- extra_arguments = -Xbootclasspath/p:/usr/lib64/jvm/java-1.7.0-openjdk-1.7.0/jre/lib/rt.jar
-----
-
-With this in place, methods that were added only in Java8 in runtime library,
-would be correctly refused to compile by Java8:
-
-----
-$ java -version
-openjdk version "1.8.0_101"
-
-$ buck build gerrit-server:server
-/home/davido/projects/gerrit/gerrit-server/src/main/java/com/google/gerrit/server/project/ProjectCacheImpl.java:218: error: cannot find symbol
- return Collections.emptySortedSet();
- ^
- symbol: method emptySortedSet()
- location: class java.util.Collections
-----
-
-== Upgrading Buck
-
-The following tests should be executed, when Buck version is upgraded:
-
-* buck build release
-* tools/maven/api.sh install
-* buck test
-* buck build gerrit, change some sources in gerrit-server project,
- repeat buck build gerrit and verify that gerrit.war was updated
-* install and verify new gerrit site
-* upgrade and verify existing gerrit site
-* reindex existing gerrit site
-* verify that tools/eclipse/project.py produces sane Eclipse project
-* verify that tools/eclipse/project.py --src generates sources as well
-* verify that unit test execution from Eclipse works
-* verify that daemon started from Eclipse works
-* verify that GWT SDM debug session started from Eclipse works
-
-== Known issues and bugs
-
-=== Symbolic links and `watchman`
-
-`Buck` with activated `Watchman` has currently a
-[known bug](https://github.com/facebook/buck/issues/341) related to
-symbolic links. The symbolic links are used very often with external
-plugins, that are linked per symbolic link to the plugins directory.
-With this use case Buck is failing to rebuild the plugin artifact
-after it was built. All attempts to convince Buck to rebuild will fail.
-The only known way to recover is to weep out `buck-out` directory. The
-better workaround is to avoid using Watchman in this specific use case.
-Watchman can either be de-installed or disabled. See
-link:#buck-daemon[Using Buck daemon] section above how to temporarily
-disable `buckd`.
-
-== Error Prone integration
-
-link:http://errorprone.info[Error Prone] is a static analysis tool for
-Java that catches common programming mistakes at compile-time. It can
-be permanenty or instantly activated. For permanent activation, add these
-lines to your `.buckconfig.local` file in gerrit tree:
-
-```
- [sanitizers]
- error_prone = 1
-```
-
-For instant activation, pass this config option to the `build` or `test`
-commands:
-
-```
- buck build --config sanitizers.error_prone=1 gerrit
-```
-
-== Troubleshooting Buck
-
-In some cases problems with Buck itself need to be investigated. See for example
-link:https://gerrit-review.googlesource.com/62411[this attempt to upgrade Buck]
-and link:https://github.com/facebook/buck/pull/227[the fix that was needed] to
-make the update possible.
-
-To build Gerrit with a custom version of Buck, the following steps are necessary:
-
-1. In the Buck git apply any necessary changes from pull requests
-2. Compile Buck with `ant`
-3. In the root of the Gerrit project create a `.nobuckcheck` file to prevent Buck
-from updating itself
-4. Replace the sha1 in Gerrit's `.buckversion` file with the required version from
-the custom Buck build
-5. Build Gerrit as usual
-
-GERRIT
-------
-Part of link:index.html[Gerrit Code Review]
-
-SEARCHBOX
----------
diff --git a/Documentation/dev-build-plugins.txt b/Documentation/dev-build-plugins.txt
index 13071df..c777327 100644
--- a/Documentation/dev-build-plugins.txt
+++ b/Documentation/dev-build-plugins.txt
@@ -4,15 +4,15 @@
From build process perspective there are three types of plugins:
* Maven driven
-* Buck in tree driven
-* Buck standalone driven
+* Bazel tree driven
+* Bazel standalone
These types can be combined: if both files in plugin's root directory exist:
-* `BUCK`
+* `BUILD`
* `pom.xml`
-the plugin can be built with both Buck and Maven.
+the plugin can be built with both Bazel and Maven.
== Maven driven build
@@ -52,35 +52,56 @@
Repeat step 1. above.
-== Buck in tree driven
+== Bazel in tree driven
-The fact that plugin contains `BUCK` file doesn't mean that building this
-plugin from the plugin directory works. For now it doesn't. Buck in tree driven
-means it can only be built from within Gerrit tree. Clone or link the plugin
-into gerrit/plugins directory:
+The fact that plugin contains `BUILD` file doesn't mean that building this
+plugin from the plugin directory works.
+
+Bazel in tree driven means it can only be built from within Gerrit tree. Clone
+or link the plugin into gerrit/plugins directory:
----
cd gerrit
-buck build plugins/<plugin-name>:<plugin-name>
+bazel build plugins/<plugin-name>:<plugin-name>
----
The output can be normally found in the following directory:
----
-buck-out/gen/plugins/<plugin-name>/<plugin-name>.jar
+bazel-genfiles/plugins/<plugin-name>/<plugin-name>.jar
----
Some plugins describe their build process in `src/main/resources/Documentation/build.md`
file. It may worth checking.
-== Buck standalone driven
+=== Plugins with external dependencies ===
+
+If the plugin has external dependencies, then they must be included from Gerrit's
+own WORKSPACE file. This can be achieved by including them in `external_plugin_deps.bzl`.
+During the build in Gerrit tree, this file must be copied over the dummy one in
+`plugins` directory.
+
+Example for content of `external_plugin_deps.bzl` file:
+
+----
+load("//tools/bzl:maven_jar.bzl", "maven_jar")
+
+def external_plugin_deps():
+ maven_jar(
+ name = 'org_apache_tika_tika_core',
+ artifact = 'org.apache.tika:tika-core:1.12',
+ sha1 = '5ab95580d22fe1dee79cffbcd98bb509a32da09b',
+ )
+----
+
+== Bazel standalone driven
Only few plugins support that mode for now:
----
cd reviewers
-buck build plugin
+bazel build reviewers
----
GERRIT
diff --git a/Documentation/dev-eclipse.txt b/Documentation/dev-eclipse.txt
index 4fa542d..5ada1e2 100644
--- a/Documentation/dev-eclipse.txt
+++ b/Documentation/dev-eclipse.txt
@@ -33,7 +33,7 @@
In Eclipse, choose 'Import existing project' and select the `gerrit` project
from the current working directory.
-Expand the `gerrit` project, right-click on the `buck-out` folder, select
+Expand the `gerrit` project, right-click on the `eclipse-out` folder, select
'Properties', and then under 'Attributes' check 'Derived'.
Note that if you make any changes in the project configuration
@@ -55,7 +55,7 @@
== Site Initialization
Build once on the command line with
-link:dev-buck.html#build[Buck] and then follow
+link:dev-bazel.html#build[Bazel] and then follow
link:dev-readme.html#init[Site Initialization] in the
Developer Setup guide to configure a local site for testing.
diff --git a/Documentation/dev-plugins.txt b/Documentation/dev-plugins.txt
index c1a4fca..4f3de9c 100644
--- a/Documentation/dev-plugins.txt
+++ b/Documentation/dev-plugins.txt
@@ -132,7 +132,7 @@
</manifestEntries>
----
-For Buck driven plugins, the following line must be included in the BUCK
+For Bazel driven plugins, the following line must be included in the BUILD
configuration file:
[source,python]
@@ -1347,7 +1347,7 @@
</manifestEntries>
----
-or in the `BUCK` configuration file for Buck driven plugins:
+or in the `BUILD` configuration file for Bazel driven plugins:
[source,python]
----
@@ -1412,7 +1412,7 @@
</manifestEntries>
----
-or in the `BUCK` configuration file for Buck driven plugins
+or in the `BUILD` configuration file for Bazel driven plugins
[source,python]
----
diff --git a/Documentation/dev-readme.txt b/Documentation/dev-readme.txt
index 383c709..873b9ac 100644
--- a/Documentation/dev-readme.txt
+++ b/Documentation/dev-readme.txt
@@ -1,6 +1,6 @@
= Gerrit Code Review - Developer Setup
-Bazel or Facebook Buck is needed to compile the code, and an SQL database to
+Google Bazel is needed to compile the code, and an SQL database to
house the review metadata. H2 is recommended for development
databases, as it requires no external server process.
@@ -21,9 +21,7 @@
[[compile_project]]
== Compiling
-Please refer to either <<dev-buck#,Building with Buck>> or
-<<dev-bazel#,Building with Bazel>>.
-
+Please refer to <<dev-bazel#,Building with Bazel>>.
== Switching between branches
@@ -50,32 +48,12 @@
To use the Eclipse IDE for development, please see
link:dev-eclipse.html[Eclipse Setup].
-For details on how to configure the Eclipse workspace with Buck,
-refer to: link:dev-buck.html#eclipse[Eclipse integration with Buck].
+For details on how to configure the Eclipse workspace with Bazel,
+refer to: link:dev-bazel.html#eclipse[Eclipse integration with Bazel].
== Configuring IntelliJ IDEA
-=== Build based on Buck
-
-To use IntelliJ IDEA for development, the easiest way is to follow
-Eclipse integration and then open it as Eclipse project in IDEA.
-You need the Eclipse plugin activated in IntelliJ IDEA.
-
-Once you start compiling using both buck and your Gerrit project in
-IDEA, you will likely need to mark the below directories as generated
-sources roots. You can do so using the IDEA "Project" view. In the
-context menu of each one of these, use "Mark Directory As" to mark
-them as "Generated Sources Root":
-
-----
- __auto_value_tests_gen__
- __httpd_gen__
- __server_gen__
-----
-
-=== Build based on Bazel
-
Please refer to <<dev-intellij#,IntelliJ Setup>> for detailed
instructions.
@@ -97,12 +75,6 @@
After compiling <<compile_project,(above)>>, run Gerrit's 'init' command to
create a testing site for development use:
-.Build based on Buck
-----
- java -jar buck-out/gen/gerrit/gerrit.war init -d ../gerrit_testsite
-----
-
-.Build based on Bazel
----
$(bazel info output_base)/external/local_jdk/bin/java \
-jar bazel-bin/gerrit.war init -d ../gerrit_testsite
@@ -169,10 +141,8 @@
started on that site. When the test has finished the Gerrit daemon is
shutdown.
-For instructions on running the integration tests with Buck,
-please refer to:
-link:dev-buck.html#tests[Running integration tests with Buck].
-For Bazel, please refer to <<dev-bazel#tests,Running Unit Tests with Bazel>>.
+For instructions on running the integration tests with Bazel,
+please refer to: <<dev-bazel#tests,Running Unit Tests with Bazel>>.
[[run_daemon]]
=== Running the Daemon
@@ -180,14 +150,6 @@
The daemon can be directly launched from the build area, without
copying to the test site:
-.Build based on Buck
-----
- java -jar buck-out/gen/gerrit/gerrit.war daemon -d \
- ../gerrit_testsite --console-log
-
-----
-
-.Build based on Bazel
----
$(bazel info output_base)/external/local_jdk/bin/java \
-jar bazel-bin/gerrit.war daemon -d ../gerrit_testsite \
@@ -213,12 +175,6 @@
Gerrit Inspect can be started by adding '-s' option to the
command used to launch the daemon:
-.Build based on Buck
-----
- java -jar buck-out/gen/gerrit/gerrit.war daemon -d ../gerrit_testsite -s
-----
-
-.Build based on Bazel
----
$(bazel info output_base)/external/local_jdk/bin/java \
-jar bazel-bin/gerrit.war daemon -d ../gerrit_testsite -s
@@ -250,12 +206,6 @@
The embedded H2 database can be queried and updated from the
command line. If the daemon is not currently running:
-.Build based on Buck
-----
- java -jar buck-out/gen/gerrit/gerrit.war gsql -d ../gerrit_testsite
-----
-
-.Build based on Bazel
----
$(bazel info output_base)/external/local_jdk/bin/java \
-jar bazel-bin/gerrit.war gsql -d ../gerrit_testsite -s
diff --git a/Documentation/dev-release.txt b/Documentation/dev-release.txt
index 91a8af4..2a857b2 100644
--- a/Documentation/dev-release.txt
+++ b/Documentation/dev-release.txt
@@ -111,8 +111,8 @@
* link:dev-release-subproject.html#prepare-release[Prepare the Release]
* link:dev-release-subproject.html#publish-release[Publish the Release]
-* Update the `id`, `bin_sha1`, and `src_sha1` values in the `maven_jar`
-for the Subproject in `/lib/BUCK` to the released version.
+* Update the `artifact`, `sha1`, and `src_sha1` values in the `maven_jar`
+for the Subproject in `WORKSPACE` to the released version.
[[update-versions]]
=== Update Versions and Create Release Tag
@@ -147,9 +147,8 @@
* Build the Gerrit WAR, API JARs and documentation
+
----
- buck clean
- buck build --no-cache release docs
- ./tools/maven/api.sh install <buck|bazel>
+ bazel build release Documentation:searchfree
+ ./tools/maven/api.sh install
----
* Sanity check WAR
@@ -157,11 +156,10 @@
* Verify plugin versions
+
-Sometimes `buck` doesn't rebuild plugins after they are tagged, and the
-versions don't reflect the tag. Verify the versions:
+Verify the versions:
+
----
- java -jar ./buck-out/gen/release/release.war init --list-plugins
+ java -jar bazel-bin/release.war init --list-plugins
----
[[publish-gerrit]]
@@ -174,30 +172,24 @@
link:dev-release-deploy-config.html#deploy-configuration-setting-maven-central[
configuration] for deploying to Maven Central
-* Make sure that the version is updated in the `VERSION` file and in
+* Make sure that the version is updated in the `version.bzl` file and in
the `pom.xml` files as described in the link:#update-versions[Update
Versions and Create Release Tag] section.
* Push the WAR to Maven Central:
+
----
- ./tools/maven/api.sh war_deploy <buck|bazel>
+ ./tools/maven/api.sh war_deploy
----
* Push the plugin artifacts to Maven Central:
+
----
- ./tools/maven/api.sh deploy <buck|bazel>
-----
-+
-If no artifacts are uploaded, clean the `buck-out` folder and retry:
-+
-----
- buck clean ; rm -rf buck-out
+ ./tools/maven/api.sh deploy
----
* To where the artifacts are uploaded depends on the `GERRIT_VERSION` in
-the `VERSION` file:
+the `version.bzl` file:
** SNAPSHOT versions are directly uploaded into the Sonatype snapshots
repository and no further action is needed:
@@ -318,7 +310,7 @@
==== Upload the Documentation
* Extract the documentation files from the zip file generated from
-`buck build docs`: `buck-out/gen/Documentation/searchfree/searchfree.zip`.
+`bazel build searchfree`: `bazel-bin/Documentation/searchfree.zip`.
* Upload the files manually via web browser to the appropriate folder
in the
@@ -368,7 +360,7 @@
+
The SHA1 and MD5 can be taken from the artifact page on Sonatype. The
SHA256 can be generated with
-`openssl sha -sha256 buck-out/gen/release/release.war` or an equivalent
+`openssl sha -sha256 bazel-bin/release.war` or an equivalent
command.
* Update the new discussion group announcement to be sticky
@@ -388,8 +380,7 @@
next Gerrit release. The Gerrit version should be set to the snapshot version
for the next release.
-Use the `version` tool to set the version in the `VERSION` file:
-:
+Use the `version` tool to set the version in the `version.bzl` file:
----
./tools/version.py 2.11-SNAPSHOT
diff --git a/Documentation/gen_licenses.py b/Documentation/gen_licenses.py
deleted file mode 100755
index 15f470c..0000000
--- a/Documentation/gen_licenses.py
+++ /dev/null
@@ -1,178 +0,0 @@
-#!/usr/bin/env python
-# Copyright (C) 2013 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# TODO(sop): Be more detailed: version, link to Maven Central
-
-from __future__ import print_function
-
-import argparse
-from collections import defaultdict, deque
-import json
-from os import chdir, path
-from shutil import copyfileobj
-from subprocess import Popen, PIPE
-from sys import stdout, stderr
-
-parser = argparse.ArgumentParser()
-parser.add_argument('--asciidoc', action='store_true')
-parser.add_argument('--partial', action='store_true')
-parser.add_argument('targets', nargs='+')
-args = parser.parse_args()
-
-KNOWN_PROVIDED_DEPS = [
- '//lib/bouncycastle:bcpg',
- '//lib/bouncycastle:bcpkix',
- '//lib/bouncycastle:bcprov',
-]
-
-for target in args.targets:
- if not target.startswith('//'):
- print('Target must be absolute: %s' % target, file=stderr)
-
-def parse_graph():
- graph = defaultdict(list)
- while not path.isfile('.buckconfig'):
- chdir('..')
- query = ' + '.join('deps(%s)' % t for t in args.targets)
- p = Popen([
- 'buck', 'query', query,
- '--output-attributes=buck.direct_dependencies'], stdout=PIPE)
- obj = json.load(p.stdout)
- for target, attrs in obj.iteritems():
- for dep in attrs['buck.direct_dependencies']:
-
- if target in KNOWN_PROVIDED_DEPS:
- continue
-
- if (args.partial
- and dep == '//gerrit-gwtexpui:CSS'
- and target == '//gerrit-gwtui:ui_module'):
- continue
-
- graph[target].append(dep)
- r = p.wait()
- if r != 0:
- exit(r)
- return graph
-
-graph = parse_graph()
-licenses = defaultdict(set)
-
-do_not_distribute = False
-queue = deque(args.targets)
-while queue:
- target = queue.popleft()
- for dep in graph[target]:
- if not dep.startswith('//lib:LICENSE-'):
- continue
- if 'DO_NOT_DISTRIBUTE' in dep:
- do_not_distribute = True
- licenses[dep].add(target)
- queue.extend(graph[target])
-
-if do_not_distribute:
- print('DO_NOT_DISTRIBUTE license found', file=stderr)
- for target in args.targets:
- print('...via %s:' % target)
- Popen(['buck', 'query',
- 'allpaths(%s, //lib:LICENSE-DO_NOT_DISTRIBUTE)' % target],
- stdout=stderr).communicate()
- exit(1)
-
-used = sorted(licenses.keys())
-
-if args.asciidoc:
- print("""\
-= Gerrit Code Review - Licenses
-
-Gerrit open source software is licensed under the <<Apache2_0,Apache
-License 2.0>>. Executable distributions also include other software
-components that are provided under additional licenses.
-
-[[cryptography]]
-== Cryptography Notice
-
-This distribution includes cryptographic software. The country
-in which you currently reside may have restrictions on the import,
-possession, use, and/or re-export to another country, of encryption
-software. BEFORE using any encryption software, please check
-your country's laws, regulations and policies concerning the
-import, possession, or use, and re-export of encryption software,
-to see if this is permitted. See the
-link:http://www.wassenaar.org/[Wassenaar Arrangement]
-for more information.
-
-The U.S. Government Department of Commerce, Bureau of Industry
-and Security (BIS), has classified this software as Export
-Commodity Control Number (ECCN) 5D002.C.1, which includes
-information security software using or performing cryptographic
-functions with asymmetric algorithms. The form and manner of
-this distribution makes it eligible for export under the License
-Exception ENC Technology Software Unrestricted (TSU) exception
-(see the BIS Export Administration Regulations, Section 740.13)
-for both object code and source code.
-
-Gerrit includes an SSH daemon (Apache SSHD), to support authenticated
-uploads of changes directly from `git push` command line clients.
-
-Gerrit includes an SSH client (JSch), to support authenticated
-replication of changes to remote systems, such as for automatic
-updates of mirror servers, or realtime backups.
-
-For either feature to function, Gerrit requires the
-link:http://java.sun.com/javase/technologies/security/[Java Cryptography extensions]
-and/or the
-link:http://www.bouncycastle.org/java.html[Bouncy Castle Crypto API]
-to be installed by the end-user.
-
-== Licenses
-""")
-
-for n in used:
- libs = sorted(licenses[n])
- name = n[len('//lib:LICENSE-'):]
- if args.asciidoc:
- print()
- print('[[%s]]' % name.replace('.', '_'))
- print("=== " + name)
- print()
- else:
- print()
- print(name)
- print()
- print('----')
- for d in libs:
- if d.startswith('//lib:') or d.startswith('//lib/'):
- p = d[len('//lib:'):]
- else:
- p = d[d.index(':')+1:].lower()
- if '__' in p:
- p = p[:p.index('__')]
- print('* ' + p)
- if args.asciidoc:
- print()
- print('[[%s_license]]' % name.replace('.', '_'))
- print('----')
- with open(n[2:].replace(':', '/')) as fd:
- copyfileobj(fd, stdout)
- print()
- print('----')
-
-if args.asciidoc:
- print("""
-GERRIT
-------
-Part of link:index.html[Gerrit Code Review]
-""")
diff --git a/Documentation/index.txt b/Documentation/index.txt
index c913aef..0471ed8 100644
--- a/Documentation/index.txt
+++ b/Documentation/index.txt
@@ -61,7 +61,6 @@
== Developer
. Getting Started
.. link:dev-readme.html[Developer Setup]
-.. link:dev-buck.html[Building with Buck]
.. link:dev-bazel.html[Building with Bazel]
.. link:dev-eclipse.html[Eclipse Setup]
.. link:dev-intellij.html[IntelliJ Setup]
diff --git a/Documentation/intro-project-owner.txt b/Documentation/intro-project-owner.txt
index 03eeeb7..6056e57 100644
--- a/Documentation/intro-project-owner.txt
+++ b/Documentation/intro-project-owner.txt
@@ -596,7 +596,7 @@
+
----
[plugin "project-download-commands"]
- Build = git fetch ${url} ${ref} && git checkout FETCH_HEAD && buck build ${project}
+ Build = git fetch ${url} ${ref} && git checkout FETCH_HEAD && bazel build ${project}
Update = git fetch ${url} ${ref} && git checkout FETCH_HEAD && git submodule update
----
+
diff --git a/Documentation/license.defs b/Documentation/license.defs
deleted file mode 100644
index 42dd3eb..0000000
--- a/Documentation/license.defs
+++ /dev/null
@@ -1,29 +0,0 @@
-def genlicenses(
- name,
- out,
- opts = [],
- java_deps = [],
- non_java_deps = [],
- visibility = []):
- cmd = ['$(exe :gen_licenses)']
- cmd.extend(opts)
- cmd.append('>$OUT')
- cmd.extend(java_deps)
- cmd.extend(non_java_deps)
-
- # Must use $(classpath) for Java deps, since transitive dependencies are not
- # first-order dependencies of the output jar, so changes would not cause
- # invalidation of the build cache key for the genrule.
- cmd.extend('; true $(classpath %s)' % d for d in java_deps)
-
- # Must use $(location) for non-Java deps, since $(classpath) will fail with an
- # error. This is ok, because transitive dependencies are included in the
- # output artifacts for everything _except_ Java libraries.
- cmd.extend('; true $(location %s)' % d for d in non_java_deps)
-
- genrule(
- name = name,
- out = out,
- cmd = ' '.join(cmd),
- visibility = visibility,
- )
diff --git a/Documentation/rest-api-documentation.txt b/Documentation/rest-api-documentation.txt
index 4c9db2b..0a7ff16 100644
--- a/Documentation/rest-api-documentation.txt
+++ b/Documentation/rest-api-documentation.txt
@@ -6,9 +6,9 @@
Please note that this feature is only usable with documentation built-in.
You'll need to
-`buck build withdocs`
+`bazel build withdocs`
or
-`buck build release`
+`bazel build release`
to test this feature.
[[documentation-endpoints]]
diff --git a/README.md b/README.md
index e0ffd53..78c8477 100644
--- a/README.md
+++ b/README.md
@@ -50,10 +50,10 @@
## Build
-Install [Buck](http://facebook.github.io/buck/setup/install.html) and run the following:
+Install [Bazel](https://bazel.build/versions/master/docs/install.html) and run the following:
git clone --recursive https://gerrit.googlesource.com/gerrit
- cd gerrit && buck build release
+ cd gerrit && bazel build release
## Install binary packages (Deb/Rpm)
diff --git a/ReleaseNotes/BUCK b/ReleaseNotes/BUCK
deleted file mode 100644
index 0f47808..0000000
--- a/ReleaseNotes/BUCK
+++ /dev/null
@@ -1,19 +0,0 @@
-include_defs('//Documentation/asciidoc.defs')
-include_defs('//ReleaseNotes/config.defs')
-
-DIR = 'ReleaseNotes'
-
-SRCS = glob(['*.txt'])
-
-
-genasciidoc(
- name = 'html',
- out = 'html.zip',
- directory = DIR,
- srcs = SRCS,
- attributes = release_notes_attributes(),
- backend = 'html5',
- searchbox = False,
- resources = False,
- visibility = ['PUBLIC'],
-)
diff --git a/ReleaseNotes/config.defs b/ReleaseNotes/config.defs
deleted file mode 100644
index 86b7603..0000000
--- a/ReleaseNotes/config.defs
+++ /dev/null
@@ -1,14 +0,0 @@
-def release_notes_attributes():
- return [
- 'toc',
- 'newline="\\n"',
- 'asterisk="*"',
- 'plus="+"',
- 'caret="^"',
- 'startsb="["',
- 'endsb="]"',
- 'tilde="~"',
- 'last-update-label!',
- 'stylesheet=DEFAULT',
- 'linkcss=true',
- ]
diff --git a/WORKSPACE b/WORKSPACE
index 3329460..5233b0d 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -2,6 +2,7 @@
load("//tools/bzl:maven_jar.bzl", "maven_jar", "GERRIT", "MAVEN_LOCAL")
load("//lib/codemirror:cm.bzl", "CM_VERSION", "DIFF_MATCH_PATCH_VERSION")
+load("//plugins:external_plugin_deps.bzl", "external_plugin_deps")
ANTLR_VERS = "3.5.2"
@@ -1104,3 +1105,4 @@
load("//lib/js:bower_archives.bzl", "load_bower_archives")
load_bower_archives()
+external_plugin_deps()
diff --git a/bucklets/gerrit_plugin.bucklet b/bucklets/gerrit_plugin.bucklet
deleted file mode 100644
index 367fe71..0000000
--- a/bucklets/gerrit_plugin.bucklet
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# Dummy to make the co-existence of core and standalone plugins possible.
-# Intentionaly left empty as this doesn't suppose to have any side effects
-# in tree build, i. e.:
-#
-# cookbook-plugin/BUCK include this line:
-# include_defs('//bucklets/gerrit_plugin.bucklet')
-#
-# When executing from the Gerrit tree:
-# buck build plugins/cookbook-plugin
-#
-# this line has no effect.
-#
-# When compiling from standalone cookbook-plugin, bucklets directory points
-# to cloned bucklets library that includes real gerrit_plugin.bucklet code.
-
-GERRIT_GWT_API = ['//gerrit-plugin-gwtui:gwtui-api']
-GERRIT_PLUGIN_API = ['//gerrit-plugin-api:lib']
-GERRIT_TESTS = ['//gerrit-acceptance-framework:lib']
-
-STANDALONE_MODE = False
diff --git a/bucklets/java_doc.bucklet b/bucklets/java_doc.bucklet
deleted file mode 120000
index cc8b6db..0000000
--- a/bucklets/java_doc.bucklet
+++ /dev/null
@@ -1 +0,0 @@
-../tools/java_doc.defs
\ No newline at end of file
diff --git a/bucklets/java_sources.bucklet b/bucklets/java_sources.bucklet
deleted file mode 120000
index 8a1a5dd..0000000
--- a/bucklets/java_sources.bucklet
+++ /dev/null
@@ -1 +0,0 @@
-../tools/java_sources.defs
\ No newline at end of file
diff --git a/bucklets/maven_jar.bucklet b/bucklets/maven_jar.bucklet
deleted file mode 120000
index 130a747..0000000
--- a/bucklets/maven_jar.bucklet
+++ /dev/null
@@ -1 +0,0 @@
-../lib/maven.defs
\ No newline at end of file
diff --git a/bucklets/maven_package.bucklet b/bucklets/maven_package.bucklet
deleted file mode 120000
index b5f5ea8..0000000
--- a/bucklets/maven_package.bucklet
+++ /dev/null
@@ -1 +0,0 @@
-../tools/maven/package.defs
\ No newline at end of file
diff --git a/contrib/build-consistency.go b/contrib/build-consistency.go
deleted file mode 100644
index db63a27..0000000
--- a/contrib/build-consistency.go
+++ /dev/null
@@ -1,108 +0,0 @@
-// Copyright (C) 2016 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package main
-
-import (
- "fmt"
- "io/ioutil"
- "log"
- "os"
- "path/filepath"
- "regexp"
- "strings"
-)
-
-var (
- // Define regex to find a comment in the build files
- commentRE = regexp.MustCompile("#.*")
- // Define regexes to extract the lib name and sha1
- mvnRE = regexp.MustCompile("maven_jar([^)]*)")
- sha1RE = regexp.MustCompile("sha1=[\"'](?P<SHA1>[^,]*)[\"']")
- bSha1RE = regexp.MustCompile("bin_sha1=[\"'](?P<SHA1>[^,]*)[\"']")
- libNameRE = regexp.MustCompile("name=[\"'](?P<NAME>[^,]*)[\"']")
-)
-
-func sanitize(s string) string {
- // Strip out comments
- s = commentRE.ReplaceAllString(s, "")
- // Remove newlines and blanks
- s = strings.Replace(s, "\n", "", -1)
- s = strings.Replace(s, " ", "", -1)
- // WORKSPACE syntax disallows the dash char in artifact name and we use an underscore
- // So we make this a consistent underscore in all files
- s = strings.Replace(s, "-", "_", -1)
- return s
-}
-
-func main() {
- // Load bazel WORKSPACE file
- bzlDat, err := ioutil.ReadFile("WORKSPACE")
- if err != nil {
- log.Fatal(err)
- }
- bzlStr := sanitize(string(bzlDat))
-
- // Walk all files nested under lib. Find, load and sanitize BUCK files
- bckStrs := []string{}
- err = filepath.Walk("lib/", func(path string, f os.FileInfo, err error) error {
- bckFile := filepath.Join(path, "BUCK")
- if _, err := os.Stat(bckFile); err == nil {
- bckDat, err := ioutil.ReadFile(bckFile)
- if err != nil {
- return err
- }
- bckStrs = append(bckStrs, sanitize(string(bckDat)))
- }
- return nil
- })
- if err != nil {
- log.Fatal(err)
- }
- bckStr := strings.Join(bckStrs, "")
-
- // Find all bazel dependencies
- // bzlVersions maps from a lib name to the referenced sha1
- bzlVersions := make(map[string]string)
- for _, mvn := range mvnRE.FindAllString(bzlStr, -1) {
- sha1s := sha1RE.FindStringSubmatch(mvn)
- names := libNameRE.FindStringSubmatch(mvn)
- if len(sha1s) > 1 && len(names) > 1 {
- bzlVersions[names[1]] = sha1RE.FindStringSubmatch(mvn)[1]
- } else {
- fmt.Printf("Can't parse lib sha1/name of target %s\n", mvn)
- }
- }
-
- // Find all buck dependencies and check if we have the correct bazel dependency on file
- for _, mvn := range mvnRE.FindAllString(bckStr, -1) {
- sha1s := bSha1RE.FindStringSubmatch(mvn)
- if len(sha1s) < 2 {
- // Buck knows two dep version representations: just a SHA1 or a bin_sha1 and src_sha1
- // We try to extract the bin_sha1 first. If that fails, we use the sha1
- sha1s = sha1RE.FindStringSubmatch(mvn)
- }
- names := libNameRE.FindStringSubmatch(mvn)
- if len(sha1s) > 1 && len(names) > 1 {
- if _, ok := bzlVersions[names[1]]; !ok {
- // TODO(hiesel) This produces too many false positives.
- //fmt.Printf("Don't have lib %s in bazel\n", names[1])
- } else if bzlVersions[names[1]] != sha1s[1] {
- fmt.Printf("SHA1 of lib %s does not match: buck has %s while bazel has %s\n", names[1], sha1s[1], bzlVersions[names[1]])
- }
- } else {
- fmt.Printf("Can't parse lib sha1/name on target %s\n", mvn)
- }
- }
-}
diff --git a/contrib/convertkey/BUCK b/contrib/convertkey/BUCK
deleted file mode 100644
index 40ad9c4..0000000
--- a/contrib/convertkey/BUCK
+++ /dev/null
@@ -1,50 +0,0 @@
-include_defs('//lib/maven.defs')
-
-genrule(
- name = 'bcprov__unsign',
- cmd = ' && '.join([
- 'unzip -qd $TMP $(location //lib/bouncycastle:bcprov)',
- 'cd $TMP',
- 'zip -Drq $OUT . -x META-INF/\*.RSA META-INF/\*.DSA META-INF/\*.SF META-INF/\*.LIST',
- ]),
- out = 'bcprov-unsigned.jar',
-)
-
-prebuilt_jar(
- name = 'bcprov',
- binary_jar = ':bcprov__unsign',
-)
-
-genrule(
- name = 'bcpkix__unsign',
- cmd = ' && '.join([
- 'unzip -qd $TMP $(location //lib/bouncycastle:bcpkix)',
- 'cd $TMP',
- 'zip -Drq $OUT . -x META-INF/\*.RSA META-INF/\*.DSA META-INF/\*.SF META-INF/\*.LIST',
- ]),
- out = 'bcpkix-unsigned.jar',
-)
-
-prebuilt_jar(
- name = 'bcpkix',
- binary_jar = ':bcpkix__unsign',
-)
-
-java_library(
- name = 'convertkey__lib',
- srcs = glob(['src/main/java/**/*.java']),
- deps = [
- ':bcprov',
- ':bcpkix',
- '//lib:jsch',
- '//lib/log:nop',
- '//lib/mina:sshd',
- ],
-)
-
-java_binary(
- name = 'convertkey',
- deps = [':convertkey__lib'],
- main_class = 'com.googlesource.gerrit.convertkey.ConvertKey',
-)
-
diff --git a/gerrit-acceptance-framework/BUCK b/gerrit-acceptance-framework/BUCK
deleted file mode 100644
index dca71e6..0000000
--- a/gerrit-acceptance-framework/BUCK
+++ /dev/null
@@ -1,92 +0,0 @@
-SRCS = glob(['src/test/java/com/google/gerrit/acceptance/*.java'])
-
-PROVIDED = [
- '//gerrit-common:annotations',
- '//gerrit-common:server',
- '//gerrit-extension-api:api',
- '//gerrit-httpd:httpd',
- '//gerrit-lucene:lucene',
- '//gerrit-pgm:init',
- '//gerrit-reviewdb:server',
- '//gerrit-server:server',
- '//lib:gson',
- '//lib:jsch',
- '//lib/jgit/org.eclipse.jgit:jgit',
- '//lib/mina:sshd',
- '//lib:servlet-api-3_1',
-]
-
-java_binary(
- name = 'acceptance-framework',
- merge_manifests = False,
- manifest_file = ':manifest',
- deps = [':lib'],
- visibility = ['PUBLIC'],
-)
-
-genrule(
- name = 'manifest',
- cmd = 'echo "Manifest-Version: 1.0" >$OUT;' +
- 'echo "Implementation-Title: Gerrit Acceptance Test Framework" >>$OUT;' +
- 'echo "Implementation-Vendor: Gerrit Code Review Project" >>$OUT',
- out = 'manifest.txt',
-)
-
-java_library(
- name = 'lib',
- srcs = SRCS,
- exported_deps = [
- '//gerrit-antlr:query_exception',
- '//gerrit-gpg:gpg',
- '//gerrit-launcher:launcher',
- '//gerrit-openid:openid',
- '//gerrit-pgm:daemon',
- '//gerrit-pgm:http-jetty',
- '//gerrit-pgm:util-nodep',
- '//gerrit-server/src/main/prolog:common',
- '//gerrit-server:testutil',
- '//lib/auto:auto-value',
- '//lib/httpcomponents:fluent-hc',
- '//lib/httpcomponents:httpclient',
- '//lib/httpcomponents:httpcore',
- '//lib/jetty:servlet',
- '//lib/jgit/org.eclipse.jgit.junit:junit',
- '//lib/log:impl_log4j',
- '//lib/log:log4j',
- '//lib:truth',
- ],
- provided_deps = PROVIDED + [
- '//lib/greenmail:greenmail',
- '//lib:gwtorm',
- '//lib/guice:guice',
- '//lib/guice:guice-assistedinject',
- '//lib/guice:guice-servlet',
- '//lib/mail:mail',
- ],
- visibility = ['PUBLIC'],
-)
-
-java_sources(
- name = 'acceptance-framework-src',
- srcs = SRCS,
- visibility = ['PUBLIC'],
-)
-
-java_doc(
- name = 'acceptance-framework-javadoc',
- title = 'Gerrit Acceptance Test Framework Documentation',
- pkgs = [' com.google.gerrit.acceptance'],
- source_jar = ':acceptance-framework-src',
- srcs = SRCS,
- deps = PROVIDED + [
- ':lib',
- '//lib:guava',
- '//lib/guice:guice-assistedinject',
- '//lib/guice:guice_library',
- '//lib/guice:guice-servlet',
- '//lib/guice:javax-inject',
- '//lib:gwtorm_client',
- '//lib:junit',
- ],
- visibility = ['PUBLIC'],
-)
diff --git a/gerrit-acceptance-framework/src/test/java/com/google/gerrit/acceptance/AbstractDaemonTest.java b/gerrit-acceptance-framework/src/test/java/com/google/gerrit/acceptance/AbstractDaemonTest.java
index 40bd81a..2974c96 100644
--- a/gerrit-acceptance-framework/src/test/java/com/google/gerrit/acceptance/AbstractDaemonTest.java
+++ b/gerrit-acceptance-framework/src/test/java/com/google/gerrit/acceptance/AbstractDaemonTest.java
@@ -699,9 +699,12 @@
return gApi.changes().id(id).get();
}
- protected EditInfo getEdit(String id)
+ protected Optional<EditInfo> getEdit(String id)
throws RestApiException {
- return gApi.changes().id(id).getEdit();
+ return gApi.changes()
+ .id(id)
+ .edit()
+ .get();
}
protected ChangeInfo get(String id, ListChangesOption... options)
diff --git a/gerrit-acceptance-tests/BUCK b/gerrit-acceptance-tests/BUCK
deleted file mode 100644
index 82d268d..0000000
--- a/gerrit-acceptance-tests/BUCK
+++ /dev/null
@@ -1,48 +0,0 @@
-java_library(
- name = 'lib',
- srcs = glob(['src/test/java/com/google/gerrit/acceptance/*.java']),
- exported_deps = [
- '//gerrit-acceptance-framework:lib',
- '//gerrit-common:annotations',
- '//gerrit-common:server',
- '//gerrit-extension-api:api',
- '//gerrit-gpg:testutil',
- '//gerrit-launcher:launcher',
- '//gerrit-lucene:lucene',
- '//gerrit-httpd:httpd',
- '//gerrit-pgm:init',
- '//gerrit-pgm:pgm',
- '//gerrit-pgm:util',
- '//gerrit-reviewdb:server',
- '//gerrit-server:server',
- '//gerrit-server:testutil',
- '//gerrit-server/src/main/prolog:common',
- '//gerrit-sshd:sshd',
- '//gerrit-test-util:test_util',
-
- '//lib:args4j',
- '//lib:gson',
- '//lib:gwtjsonrpc',
- '//lib:gwtorm',
- '//lib:h2',
- '//lib:jsch',
- '//lib:servlet-api-3_1',
-
- '//lib/bouncycastle:bcpg',
- '//lib/bouncycastle:bcprov',
- '//lib/commons:compress',
- '//lib/greenmail:greenmail',
- '//lib/guice:guice',
- '//lib/guice:guice-assistedinject',
- '//lib/guice:guice-servlet',
- '//lib/log:api',
- '//lib/jgit/org.eclipse.jgit:jgit',
- '//lib/mail:mail',
- '//lib/mina:sshd',
- ],
- visibility = [
- '//gerrit-plugin-api/...',
- '//tools/eclipse:classpath',
- '//gerrit-acceptance-tests/...',
- ],
-)
diff --git a/gerrit-acceptance-tests/BUILD b/gerrit-acceptance-tests/BUILD
index c7e4a11..769baeb 100644
--- a/gerrit-acceptance-tests/BUILD
+++ b/gerrit-acceptance-tests/BUILD
@@ -24,6 +24,7 @@
"//gerrit-test-util:test_util",
"//lib:args4j",
"//lib:gson",
+ "//lib:guava-retrying",
"//lib:gwtjsonrpc",
"//lib:gwtorm",
"//lib:h2",
diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/accounts/BUCK b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/accounts/BUCK
deleted file mode 100644
index 4e3c880..0000000
--- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/accounts/BUCK
+++ /dev/null
@@ -1,7 +0,0 @@
-include_defs('//gerrit-acceptance-tests/tests.defs')
-
-acceptance_tests(
- group = 'api_account',
- srcs = glob(['*IT.java']),
- labels = ['api'],
-)
diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/change/BUCK b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/change/BUCK
deleted file mode 100644
index e8963be..0000000
--- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/change/BUCK
+++ /dev/null
@@ -1,7 +0,0 @@
-include_defs('//gerrit-acceptance-tests/tests.defs')
-
-acceptance_tests(
- group = 'api_change',
- srcs = glob(['*IT.java']),
- labels = ['api'],
-)
diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/change/MergeListIT.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/change/MergeListIT.java
index 481df31..2f9b4aa 100644
--- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/change/MergeListIT.java
+++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/change/MergeListIT.java
@@ -14,7 +14,6 @@
package com.google.gerrit.acceptance.api.change;
-import static com.google.common.collect.Iterables.getOnlyElement;
import static com.google.common.truth.Truth.assertThat;
import static com.google.gerrit.reviewdb.client.Patch.MERGE_LIST;
import static java.nio.charset.StandardCharsets.UTF_8;
@@ -30,13 +29,8 @@
import com.google.gerrit.extensions.common.CommitInfo;
import com.google.gerrit.extensions.common.DiffInfo;
import com.google.gerrit.extensions.restapi.BinaryResult;
-import com.google.gerrit.server.edit.ChangeEditModifier;
-import com.google.gerrit.server.edit.ChangeEditUtil;
-import com.google.gerrit.server.project.InvalidChangeOperationException;
-import com.google.gerrit.server.query.change.ChangeData;
-import com.google.inject.Inject;
+import com.google.gerrit.extensions.restapi.ResourceConflictException;
-import org.eclipse.jgit.dircache.InvalidPathException;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.revwalk.RevCommit;
import org.junit.Before;
@@ -56,12 +50,6 @@
private RevCommit parent2;
private RevCommit grandParent2;
- @Inject
- private ChangeEditModifier modifier;
-
- @Inject
- private ChangeEditUtil editUtil;
-
@Before
public void setup() throws Exception {
ObjectId initial = repo().exactRef(HEAD).getLeaf().getObjectId();
@@ -153,23 +141,32 @@
@Test
public void editMergeList() throws Exception {
- ChangeData cd = getOnlyElement(queryProvider.get().byKeyPrefix(changeId));
- modifier.createEdit(cd.change(), cd.currentPatchSet());
+ gApi.changes()
+ .id(changeId)
+ .edit()
+ .create();
- exception.expect(InvalidPathException.class);
+ exception.expect(ResourceConflictException.class);
exception.expectMessage("Invalid path: " + MERGE_LIST);
- modifier.modifyFile(editUtil.byChange(cd.change()).get(), MERGE_LIST,
- RawInputUtil.create("new content"));
+ gApi.changes()
+ .id(changeId)
+ .edit()
+ .modifyFile(MERGE_LIST, RawInputUtil.create("new content"));
}
@Test
public void deleteMergeList() throws Exception {
- ChangeData cd = getOnlyElement(queryProvider.get().byKeyPrefix(changeId));
- modifier.createEdit(cd.change(), cd.currentPatchSet());
+ gApi.changes()
+ .id(changeId)
+ .edit()
+ .create();
- exception.expect(InvalidChangeOperationException.class);
+ exception.expect(ResourceConflictException.class);
exception.expectMessage("no changes were made");
- modifier.deleteFile(editUtil.byChange(cd.change()).get(), MERGE_LIST);
+ gApi.changes()
+ .id(changeId)
+ .edit()
+ .deleteFile(MERGE_LIST);
}
private String getMergeListContent(RevCommit... commits) {
diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/config/BUCK b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/config/BUCK
deleted file mode 100644
index 3b3d362..0000000
--- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/config/BUCK
+++ /dev/null
@@ -1,7 +0,0 @@
-include_defs('//gerrit-acceptance-tests/tests.defs')
-
-acceptance_tests(
- group = 'api_config',
- srcs = glob(['*IT.java']),
- labels = ['api'],
-)
diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/group/BUCK b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/group/BUCK
deleted file mode 100644
index cea23dd..0000000
--- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/group/BUCK
+++ /dev/null
@@ -1,23 +0,0 @@
-include_defs('//gerrit-acceptance-tests/tests.defs')
-
-acceptance_tests(
- group = 'api_group',
- srcs = glob(['*IT.java']),
- deps = [
- ':util',
- '//gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/account:util',
- ],
- labels = ['api'],
-)
-
-java_library(
- name = 'util',
- srcs = ['GroupAssert.java'],
- deps = [
- '//gerrit-extension-api:api',
- '//gerrit-reviewdb:server',
- '//gerrit-server:server',
- '//lib:gwtorm',
- '//lib:truth',
- ],
-)
diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/project/BUCK b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/project/BUCK
deleted file mode 100644
index 0b293f3..0000000
--- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/project/BUCK
+++ /dev/null
@@ -1,7 +0,0 @@
-include_defs('//gerrit-acceptance-tests/tests.defs')
-
-acceptance_tests(
- group = 'api_project',
- srcs = glob(['*IT.java']),
- labels = ['api'],
-)
diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/revision/BUCK b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/revision/BUCK
deleted file mode 100644
index 76ae637..0000000
--- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/revision/BUCK
+++ /dev/null
@@ -1,7 +0,0 @@
-include_defs('//gerrit-acceptance-tests/tests.defs')
-
-acceptance_tests(
- group = 'api_revision',
- srcs = glob(['*IT.java']),
- labels = ['api'],
-)
diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/edit/BUCK b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/edit/BUCK
deleted file mode 100644
index 313144a..0000000
--- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/edit/BUCK
+++ /dev/null
@@ -1,10 +0,0 @@
-include_defs('//gerrit-acceptance-tests/tests.defs')
-
-acceptance_tests(
- group = 'edit',
- srcs = ['ChangeEditIT.java'],
- deps = [
- '//lib/joda:joda-time',
- ],
- labels = ['edit'],
-)
diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/edit/ChangeEditIT.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/edit/ChangeEditIT.java
index de60a8a..d4939e0 100644
--- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/edit/ChangeEditIT.java
+++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/edit/ChangeEditIT.java
@@ -16,14 +16,14 @@
import static com.google.common.collect.Iterables.getOnlyElement;
import static com.google.common.truth.Truth.assertThat;
+import static com.google.gerrit.extensions.common.EditInfoSubject.assertThat;
+import static com.google.gerrit.extensions.restapi.BinaryResultSubject.assertThat;
import static com.google.gerrit.server.group.SystemGroupBackend.REGISTERED_USERS;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.concurrent.TimeUnit.SECONDS;
import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Lists;
import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.acceptance.PushOneCommit;
import com.google.gerrit.acceptance.RestResponse;
@@ -39,26 +39,20 @@
import com.google.gerrit.extensions.client.ListChangesOption;
import com.google.gerrit.extensions.common.ApprovalInfo;
import com.google.gerrit.extensions.common.ChangeInfo;
-import com.google.gerrit.extensions.common.ChangeMessageInfo;
import com.google.gerrit.extensions.common.DiffInfo;
import com.google.gerrit.extensions.common.EditInfo;
import com.google.gerrit.extensions.common.FileInfo;
+import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.extensions.restapi.BinaryResult;
-import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
-import com.google.gerrit.reviewdb.client.Change;
+import com.google.gerrit.extensions.restapi.ResourceConflictException;
+import com.google.gerrit.reviewdb.client.Patch;
import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.change.ChangeEdits.EditMessage;
import com.google.gerrit.server.change.ChangeEdits.Post;
import com.google.gerrit.server.change.ChangeEdits.Put;
-import com.google.gerrit.server.change.FileContentUtil;
-import com.google.gerrit.server.edit.ChangeEdit;
-import com.google.gerrit.server.edit.ChangeEditModifier;
-import com.google.gerrit.server.edit.ChangeEditUtil;
-import com.google.gerrit.server.edit.UnchangedCommitMessageException;
import com.google.gerrit.server.git.ProjectConfig;
-import com.google.gerrit.server.project.InvalidChangeOperationException;
import com.google.gerrit.server.project.Util;
import com.google.gerrit.testutil.TestTimeUtil;
import com.google.gson.reflect.TypeToken;
@@ -70,7 +64,6 @@
import org.eclipse.jgit.junit.TestRepository;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.PersonIdent;
-import org.eclipse.jgit.lib.RefUpdate;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevWalk;
@@ -80,13 +73,12 @@
import org.junit.BeforeClass;
import org.junit.Test;
-import java.io.ByteArrayOutputStream;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.Iterator;
+import java.io.IOException;
+import java.sql.Timestamp;
import java.util.List;
import java.util.Map;
import java.util.Optional;
+import java.util.stream.Collectors;
public class ChangeEditIT extends AbstractDaemonTest {
@@ -101,21 +93,9 @@
@Inject
private SchemaFactory<ReviewDb> reviewDbProvider;
- @Inject
- private ChangeEditUtil editUtil;
-
- @Inject
- private ChangeEditModifier modifier;
-
- @Inject
- private FileContentUtil fileUtil;
-
- private Change change;
private String changeId;
- private Change change2;
private String changeId2;
private PatchSet ps;
- private PatchSet ps2;
@BeforeClass
public static void setTimeForTesting() {
@@ -132,14 +112,9 @@
db = reviewDbProvider.open();
changeId = newChange(admin.getIdent());
ps = getCurrentPatchSet(changeId);
- amendChange(admin.getIdent(), changeId);
- change = getChange(changeId);
assertThat(ps).isNotNull();
+ amendChange(admin.getIdent(), changeId);
changeId2 = newChange2(admin.getIdent());
- change2 = getChange(changeId2);
- assertThat(change2).isNotNull();
- ps2 = getCurrentPatchSet(changeId2);
- assertThat(ps2).isNotNull();
}
@After
@@ -149,38 +124,50 @@
@Test
public void parseEditRevision() throws Exception {
- assertThat(modifier.createEdit(change, ps)).isEqualTo(RefUpdate.Result.NEW);
+ createArbitraryEditFor(changeId);
// check that '0' is parsed as edit revision
- gApi.changes().id(change.getChangeId()).revision(0).comments();
+ gApi.changes().id(changeId).revision(0).comments();
// check that 'edit' is parsed as edit revision
- gApi.changes().id(change.getChangeId()).revision("edit").comments();
+ gApi.changes().id(changeId).revision("edit").comments();
}
@Test
- public void deleteEdit() throws Exception {
- assertThat(modifier.createEdit(change, ps)).isEqualTo(RefUpdate.Result.NEW);
- assertThat(
- modifier.modifyFile(editUtil.byChange(change).get(), FILE_NAME,
- RawInputUtil.create(CONTENT_NEW))).isEqualTo(RefUpdate.Result.FORCED);
- editUtil.delete(editUtil.byChange(change).get());
- assertThat(editUtil.byChange(change).isPresent()).isFalse();
+ public void deleteEditOfCurrentPatchSet() throws Exception {
+ createArbitraryEditFor(changeId);
+ gApi.changes()
+ .id(changeId)
+ .edit()
+ .delete();
+ assertThat(getEdit(changeId)).isAbsent();
+ }
+
+ @Test
+ public void deleteEditOfOlderPatchSet() throws Exception {
+ createArbitraryEditFor(changeId2);
+ amendChange(admin.getIdent(), changeId2);
+
+ gApi.changes()
+ .id(changeId2)
+ .edit()
+ .delete();
+ assertThat(getEdit(changeId2)).isAbsent();
}
@Test
public void publishEdit() throws Exception {
- assertThat(modifier.createEdit(change, getCurrentPatchSet(changeId)))
- .isEqualTo(RefUpdate.Result.NEW);
- assertThat(
- modifier.modifyFile(editUtil.byChange(change).get(), FILE_NAME,
- RawInputUtil.create(CONTENT_NEW2)))
- .isEqualTo(RefUpdate.Result.FORCED);
- editUtil.publish(editUtil.byChange(change).get(), NotifyHandling.NONE,
- ImmutableListMultimap.of());
- Optional<ChangeEdit> edit = editUtil.byChange(change);
- assertThat(edit.isPresent()).isFalse();
- assertChangeMessages(change,
+ createArbitraryEditFor(changeId);
+
+ PublishChangeEditInput publishInput = new PublishChangeEditInput();
+ publishInput.notify = NotifyHandling.NONE;
+ gApi.changes()
+ .id(changeId)
+ .edit()
+ .publish(publishInput);
+
+ assertThat(getEdit(changeId)).isAbsent();
+ assertChangeMessages(changeId,
ImmutableList.of("Uploaded patch set 1.",
"Uploaded patch set 2.",
"Patch Set 3: Published edit on patch set 2."));
@@ -189,18 +176,14 @@
@Test
public void publishEditRest() throws Exception {
PatchSet oldCurrentPatchSet = getCurrentPatchSet(changeId);
- assertThat(modifier.createEdit(change, oldCurrentPatchSet)).isEqualTo(
- RefUpdate.Result.NEW);
- assertThat(
- modifier.modifyFile(editUtil.byChange(change).get(), FILE_NAME,
- RawInputUtil.create(CONTENT_NEW))).isEqualTo(RefUpdate.Result.FORCED);
- Optional<ChangeEdit> edit = editUtil.byChange(change);
- adminRestSession.post(urlPublish()).assertNoContent();
- edit = editUtil.byChange(change);
- assertThat(edit.isPresent()).isFalse();
+ createArbitraryEditFor(changeId);
+
+ adminRestSession.post(urlPublish(changeId)).assertNoContent();
+ assertThat(getEdit(changeId)).isAbsent();
PatchSet newCurrentPatchSet = getCurrentPatchSet(changeId);
- assertThat(newCurrentPatchSet.getId()).isNotEqualTo(oldCurrentPatchSet.getId());
- assertChangeMessages(change,
+ assertThat(newCurrentPatchSet.getId())
+ .isNotEqualTo(oldCurrentPatchSet.getId());
+ assertChangeMessages(changeId,
ImmutableList.of("Uploaded patch set 1.",
"Uploaded patch set 2.",
"Patch Set 3: Published edit on patch set 2."));
@@ -210,121 +193,136 @@
public void publishEditNotifyRest() throws Exception {
AddReviewerInput in = new AddReviewerInput();
in.reviewer = user.email;
- gApi.changes().id(change.getChangeId()).addReviewer(in);
+ gApi.changes().id(changeId).addReviewer(in);
- modifier.createEdit(change, getCurrentPatchSet(changeId));
- assertThat(
- modifier.modifyFile(editUtil.byChange(change).get(), FILE_NAME,
- RawInputUtil.create(CONTENT_NEW))).isEqualTo(RefUpdate.Result.FORCED);
+ createArbitraryEditFor(changeId);
sender.clear();
PublishChangeEditInput input = new PublishChangeEditInput();
input.notify = NotifyHandling.NONE;
- adminRestSession.post(urlPublish(), input).assertNoContent();
+ adminRestSession.post(urlPublish(changeId), input).assertNoContent();
assertThat(sender.getMessages()).hasSize(0);
}
@Test
+ public void publishEditWithDefaultNotify() throws Exception {
+ AddReviewerInput in = new AddReviewerInput();
+ in.reviewer = user.email;
+ gApi.changes()
+ .id(changeId)
+ .addReviewer(in);
+
+ createArbitraryEditFor(changeId);
+
+ sender.clear();
+ gApi.changes()
+ .id(changeId)
+ .edit()
+ .publish();
+ assertThat(sender.getMessages()).isNotEmpty();
+ }
+
+ @Test
public void deleteEditRest() throws Exception {
- assertThat(modifier.createEdit(change, ps)).isEqualTo(RefUpdate.Result.NEW);
- assertThat(
- modifier.modifyFile(editUtil.byChange(change).get(), FILE_NAME,
- RawInputUtil.create(CONTENT_NEW))).isEqualTo(RefUpdate.Result.FORCED);
- Optional<ChangeEdit> edit = editUtil.byChange(change);
- adminRestSession.delete(urlEdit()).assertNoContent();
- edit = editUtil.byChange(change);
- assertThat(edit.isPresent()).isFalse();
+ createArbitraryEditFor(changeId);
+ adminRestSession.delete(urlEdit(changeId)).assertNoContent();
+ assertThat(getEdit(changeId)).isAbsent();
}
@Test
public void publishEditRestWithoutCLA() throws Exception {
+ createArbitraryEditFor(changeId);
setUseContributorAgreements(InheritableBoolean.TRUE);
- PatchSet oldCurrentPatchSet = getCurrentPatchSet(changeId);
- assertThat(modifier.createEdit(change, oldCurrentPatchSet)).isEqualTo(
- RefUpdate.Result.NEW);
- assertThat(
- modifier.modifyFile(editUtil.byChange(change).get(), FILE_NAME,
- RawInputUtil.create(CONTENT_NEW))).isEqualTo(RefUpdate.Result.FORCED);
- adminRestSession.post(urlPublish()).assertForbidden();
+ adminRestSession.post(urlPublish(changeId)).assertForbidden();
setUseContributorAgreements(InheritableBoolean.FALSE);
- adminRestSession.post(urlPublish()).assertNoContent();
+ adminRestSession.post(urlPublish(changeId)).assertNoContent();
}
@Test
public void rebaseEdit() throws Exception {
- assertThat(modifier.createEdit(change, ps)).isEqualTo(RefUpdate.Result.NEW);
- assertThat(
- modifier.modifyFile(editUtil.byChange(change).get(), FILE_NAME,
- RawInputUtil.create(CONTENT_NEW))).isEqualTo(RefUpdate.Result.FORCED);
- ChangeEdit edit = editUtil.byChange(change).get();
- PatchSet current = getCurrentPatchSet(changeId);
- assertThat(edit.getBasePatchSet().getPatchSetId()).isEqualTo(
- current.getPatchSetId() - 1);
- Date beforeRebase = edit.getEditCommit().getCommitterIdent().getWhen();
- modifier.rebaseEdit(edit, current);
- edit = editUtil.byChange(change).get();
- assertByteArray(fileUtil.getContent(projectCache.get(edit.getChange().getProject()),
- ObjectId.fromString(edit.getRevision().get()), FILE_NAME), CONTENT_NEW);
- assertByteArray(fileUtil.getContent(projectCache.get(edit.getChange().getProject()),
- ObjectId.fromString(edit.getRevision().get()), FILE_NAME2), CONTENT_NEW2);
- assertThat(edit.getBasePatchSet().getPatchSetId()).isEqualTo(
- current.getPatchSetId());
- Date afterRebase = edit.getEditCommit().getCommitterIdent().getWhen();
- assertThat(beforeRebase.equals(afterRebase)).isFalse();
+ PatchSet previousPatchSet = getCurrentPatchSet(changeId2);
+ createEmptyEditFor(changeId2);
+ gApi.changes()
+ .id(changeId2)
+ .edit()
+ .modifyFile(FILE_NAME, RawInputUtil.create(CONTENT_NEW));
+ amendChange(admin.getIdent(), changeId2);
+ PatchSet currentPatchSet = getCurrentPatchSet(changeId2);
+
+ Optional<EditInfo> originalEdit = getEdit(changeId2);
+ assertThat(originalEdit).value().baseRevision()
+ .isEqualTo(previousPatchSet.getRevision().get());
+ // The previous check ensures that a value is present in the Optional.
+ @SuppressWarnings("OptionalGetWithoutIsPresent")
+ Timestamp beforeRebase = originalEdit.get().commit.committer.date;
+ gApi.changes()
+ .id(changeId2)
+ .edit()
+ .rebase();
+ ensureSameBytes(getFileContentOfEdit(changeId2, FILE_NAME), CONTENT_NEW);
+ ensureSameBytes(getFileContentOfEdit(changeId2, FILE_NAME2), CONTENT_NEW2);
+ Optional<EditInfo> rebasedEdit = getEdit(changeId2);
+ assertThat(rebasedEdit).value().baseRevision()
+ .isEqualTo(currentPatchSet.getRevision().get());
+ assertThat(rebasedEdit).value().commit().committer().creationDate()
+ .isNotEqualTo(beforeRebase);
}
@Test
public void rebaseEditRest() throws Exception {
- assertThat(modifier.createEdit(change, ps)).isEqualTo(RefUpdate.Result.NEW);
- assertThat(
- modifier.modifyFile(editUtil.byChange(change).get(), FILE_NAME,
- RawInputUtil.create(CONTENT_NEW))).isEqualTo(RefUpdate.Result.FORCED);
- ChangeEdit edit = editUtil.byChange(change).get();
- PatchSet current = getCurrentPatchSet(changeId);
- assertThat(edit.getBasePatchSet().getPatchSetId()).isEqualTo(
- current.getPatchSetId() - 1);
- Date beforeRebase = edit.getEditCommit().getCommitterIdent().getWhen();
- adminRestSession.post(urlRebase()).assertNoContent();
- edit = editUtil.byChange(change).get();
- assertByteArray(fileUtil.getContent(projectCache.get(edit.getChange().getProject()),
- ObjectId.fromString(edit.getRevision().get()), FILE_NAME), CONTENT_NEW);
- assertByteArray(fileUtil.getContent(projectCache.get(edit.getChange().getProject()),
- ObjectId.fromString(edit.getRevision().get()), FILE_NAME2), CONTENT_NEW2);
- assertThat(edit.getBasePatchSet().getPatchSetId()).isEqualTo(
- current.getPatchSetId());
- Date afterRebase = edit.getEditCommit().getCommitterIdent().getWhen();
- assertThat(afterRebase).isNotEqualTo(beforeRebase);
+ PatchSet previousPatchSet = getCurrentPatchSet(changeId2);
+ createEmptyEditFor(changeId2);
+ gApi.changes()
+ .id(changeId2)
+ .edit()
+ .modifyFile(FILE_NAME, RawInputUtil.create(CONTENT_NEW));
+ amendChange(admin.getIdent(), changeId2);
+ PatchSet currentPatchSet = getCurrentPatchSet(changeId2);
+
+ Optional<EditInfo> originalEdit = getEdit(changeId2);
+ assertThat(originalEdit).value().baseRevision()
+ .isEqualTo(previousPatchSet.getRevision().get());
+ // The previous check ensures that a value is present in the Optional.
+ @SuppressWarnings("OptionalGetWithoutIsPresent")
+ Timestamp beforeRebase = originalEdit.get().commit.committer.date;
+ adminRestSession.post(urlRebase(changeId2)).assertNoContent();
+ ensureSameBytes(getFileContentOfEdit(changeId2, FILE_NAME), CONTENT_NEW);
+ ensureSameBytes(getFileContentOfEdit(changeId2, FILE_NAME2), CONTENT_NEW2);
+ Optional<EditInfo> rebasedEdit = getEdit(changeId2);
+ assertThat(rebasedEdit).value().baseRevision()
+ .isEqualTo(currentPatchSet.getRevision().get());
+ assertThat(rebasedEdit).value().commit().committer().creationDate()
+ .isNotEqualTo(beforeRebase);
}
@Test
public void rebaseEditWithConflictsRest_Conflict() throws Exception {
- PatchSet current = getCurrentPatchSet(changeId2);
- assertThat(modifier.createEdit(change2, current)).isEqualTo(RefUpdate.Result.NEW);
- assertThat(
- modifier.modifyFile(editUtil.byChange(change2).get(), FILE_NAME,
- RawInputUtil.create(CONTENT_NEW))).isEqualTo(RefUpdate.Result.FORCED);
- ChangeEdit edit = editUtil.byChange(change2).get();
- assertThat(edit.getBasePatchSet().getPatchSetId()).isEqualTo(
- current.getPatchSetId());
- PushOneCommit push =
- pushFactory.create(db, admin.getIdent(), testRepo, PushOneCommit.SUBJECT, FILE_NAME,
- new String(CONTENT_NEW2), changeId2);
+ PatchSet currentPatchSet = getCurrentPatchSet(changeId2);
+ createEmptyEditFor(changeId2);
+ gApi.changes()
+ .id(changeId2)
+ .edit()
+ .modifyFile(FILE_NAME, RawInputUtil.create(CONTENT_NEW));
+ Optional<EditInfo> edit = getEdit(changeId2);
+ assertThat(edit).value().baseRevision()
+ .isEqualTo(currentPatchSet.getRevision().get());
+ PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo,
+ PushOneCommit.SUBJECT, FILE_NAME, new String(CONTENT_NEW2),
+ changeId2);
push.to("refs/for/master").assertOkStatus();
- adminRestSession.post(urlRebase()).assertConflict();
+ adminRestSession.post(urlRebase(changeId2)).assertConflict();
}
@Test
public void updateExistingFile() throws Exception {
- assertThat(modifier.createEdit(change, ps)).isEqualTo(RefUpdate.Result.NEW);
- Optional<ChangeEdit> edit = editUtil.byChange(change);
- assertThat(modifier.modifyFile(edit.get(), FILE_NAME, RawInputUtil.create(CONTENT_NEW)))
- .isEqualTo(RefUpdate.Result.FORCED);
- edit = editUtil.byChange(change);
- assertByteArray(fileUtil.getContent(projectCache.get(edit.get().getChange().getProject()),
- ObjectId.fromString(edit.get().getRevision().get()), FILE_NAME), CONTENT_NEW);
- editUtil.delete(edit.get());
- edit = editUtil.byChange(change);
- assertThat(edit.isPresent()).isFalse();
+ createEmptyEditFor(changeId);
+ gApi.changes()
+ .id(changeId)
+ .edit()
+ .modifyFile(FILE_NAME, RawInputUtil.create(CONTENT_NEW));
+ assertThat(getEdit(changeId)).isPresent();
+ ensureSameBytes(getFileContentOfEdit(changeId, FILE_NAME), CONTENT_NEW);
+ ensureSameBytes(getFileContentOfEdit(changeId, FILE_NAME), CONTENT_NEW);
}
@Test
@@ -333,64 +331,80 @@
// Re-clone empty repo; TestRepository doesn't let us reset to unborn head.
testRepo = cloneProject(project);
changeId = newChange(admin.getIdent());
- change = getChange(changeId);
- assertThat(modifier.createEdit(change, getCurrentPatchSet(changeId)))
- .isEqualTo(RefUpdate.Result.NEW);
- Optional<ChangeEdit> edit = editUtil.byChange(change);
- assertThat(edit.get().getEditCommit().getParentCount()).isEqualTo(0);
+ createEmptyEditFor(changeId);
+ Optional<EditInfo> edit = getEdit(changeId);
+ assertThat(edit).value().commit().parents().hasSize(0);
String msg = String.format("New commit message\n\nChange-Id: %s\n",
- change.getKey());
- assertThat(modifier.modifyMessage(edit.get(), msg))
- .isEqualTo(RefUpdate.Result.FORCED);
- edit = editUtil.byChange(change);
- assertThat(edit.get().getEditCommit().getFullMessage()).isEqualTo(msg);
+ changeId);
+ gApi.changes()
+ .id(changeId)
+ .edit()
+ .modifyCommitMessage(msg);
+ String commitMessage = gApi.changes()
+ .id(changeId)
+ .edit()
+ .getCommitMessage();
+ assertThat(commitMessage).isEqualTo(msg);
}
@Test
public void updateMessageNoChange() throws Exception {
- assertThat(modifier.createEdit(change, getCurrentPatchSet(changeId)))
- .isEqualTo(RefUpdate.Result.NEW);
- Optional<ChangeEdit> edit = editUtil.byChange(change);
+ createEmptyEditFor(changeId);
+ String commitMessage = gApi.changes()
+ .id(changeId)
+ .edit()
+ .getCommitMessage();
- exception.expect(UnchangedCommitMessageException.class);
+ exception.expect(ResourceConflictException.class);
exception.expectMessage(
"New commit message cannot be same as existing commit message");
- modifier.modifyMessage(
- edit.get(),
- edit.get().getEditCommit().getFullMessage());
+ gApi.changes()
+ .id(changeId)
+ .edit()
+ .modifyCommitMessage(commitMessage);
}
@Test
public void updateMessageOnlyAddTrailingNewLines() throws Exception {
- assertThat(modifier.createEdit(change, getCurrentPatchSet(changeId)))
- .isEqualTo(RefUpdate.Result.NEW);
- Optional<ChangeEdit> edit = editUtil.byChange(change);
+ createEmptyEditFor(changeId);
+ String commitMessage = gApi.changes()
+ .id(changeId)
+ .edit()
+ .getCommitMessage();
- exception.expect(UnchangedCommitMessageException.class);
+ exception.expect(ResourceConflictException.class);
exception.expectMessage(
"New commit message cannot be same as existing commit message");
- modifier.modifyMessage(
- edit.get(),
- edit.get().getEditCommit().getFullMessage() + "\n\n");
+ gApi.changes()
+ .id(changeId)
+ .edit()
+ .modifyCommitMessage(commitMessage + "\n\n");
}
@Test
public void updateMessage() throws Exception {
- assertThat(modifier.createEdit(change, getCurrentPatchSet(changeId)))
- .isEqualTo(RefUpdate.Result.NEW);
- Optional<ChangeEdit> edit = editUtil.byChange(change);
+ createEmptyEditFor(changeId);
String msg = String.format("New commit message\n\nChange-Id: %s\n",
- change.getKey());
- assertThat(modifier.modifyMessage(edit.get(), msg)).isEqualTo(
- RefUpdate.Result.FORCED);
- edit = editUtil.byChange(change);
- assertThat(edit.get().getEditCommit().getFullMessage()).isEqualTo(msg);
+ changeId);
+ gApi.changes()
+ .id(changeId)
+ .edit()
+ .modifyCommitMessage(msg);
+ String commitMessage = gApi.changes()
+ .id(changeId)
+ .edit()
+ .getCommitMessage();
+ assertThat(commitMessage).isEqualTo(msg);
- editUtil.publish(edit.get(), NotifyHandling.NONE,
- ImmutableListMultimap.of());
- assertThat(editUtil.byChange(change).isPresent()).isFalse();
+ PublishChangeEditInput publishInput = new PublishChangeEditInput();
+ publishInput.notify = NotifyHandling.NONE;
+ gApi.changes()
+ .id(changeId)
+ .edit()
+ .publish(publishInput);
+ assertThat(getEdit(changeId)).isAbsent();
ChangeInfo info = get(changeId, ListChangesOption.CURRENT_COMMIT,
ListChangesOption.CURRENT_REVISION);
@@ -399,7 +413,7 @@
assertThat(info.revisions.get(info.currentRevision).description)
.isEqualTo("Edit commit message");
- assertChangeMessages(change,
+ assertChangeMessages(changeId,
ImmutableList.of("Uploaded patch set 1.",
"Uploaded patch set 2.",
"Patch Set 3: Commit message was updated."));
@@ -407,26 +421,31 @@
@Test
public void updateMessageRest() throws Exception {
- adminRestSession.get(urlEditMessage(false)).assertNotFound();
+ adminRestSession.get(urlEditMessage(changeId, false)).assertNotFound();
EditMessage.Input in = new EditMessage.Input();
in.message = String.format("New commit message\n\n" +
CONTENT_NEW2_STR + "\n\nChange-Id: %s\n",
- change.getKey());
- adminRestSession.put(urlEditMessage(false), in).assertNoContent();
- RestResponse r = adminRestSession.getJsonAccept(urlEditMessage(false));
+ changeId);
+ adminRestSession.put(urlEditMessage(changeId, false), in).assertNoContent();
+ RestResponse r = adminRestSession.getJsonAccept(urlEditMessage(changeId,
+ false));
r.assertOK();
assertThat(readContentFromJson(r)).isEqualTo(in.message);
- Optional<ChangeEdit> edit = editUtil.byChange(change);
- assertThat(edit.get().getEditCommit().getFullMessage())
- .isEqualTo(in.message);
+ String commitMessage = gApi.changes()
+ .id(changeId)
+ .edit()
+ .getCommitMessage();
+ assertThat(commitMessage).isEqualTo(in.message);
in.message = String.format("New commit message2\n\nChange-Id: %s\n",
- change.getKey());
- adminRestSession.put(urlEditMessage(false), in).assertNoContent();
- edit = editUtil.byChange(change);
- assertThat(edit.get().getEditCommit().getFullMessage())
- .isEqualTo(in.message);
+ changeId);
+ adminRestSession.put(urlEditMessage(changeId, false), in).assertNoContent();
+ String updatedCommitMessage = gApi.changes()
+ .id(changeId)
+ .edit()
+ .getCommitMessage();
+ assertThat(updatedCommitMessage).isEqualTo(in.message);
- r = adminRestSession.getJsonAccept(urlEditMessage(true));
+ r = adminRestSession.getJsonAccept(urlEditMessage(changeId, true));
try (Repository repo = repoManager.openRepository(project);
RevWalk rw = new RevWalk(repo)) {
RevCommit commit = rw.parseCommit(
@@ -434,9 +453,13 @@
assertThat(readContentFromJson(r)).isEqualTo(commit.getFullMessage());
}
- editUtil.publish(edit.get(), NotifyHandling.NONE,
- ImmutableListMultimap.of());
- assertChangeMessages(change,
+ PublishChangeEditInput publishInput = new PublishChangeEditInput();
+ publishInput.notify = NotifyHandling.NONE;
+ gApi.changes()
+ .id(changeId)
+ .edit()
+ .publish(publishInput);
+ assertChangeMessages(changeId,
ImmutableList.of("Uploaded patch set 1.",
"Uploaded patch set 2.",
"Patch Set 3: Commit message was updated."));
@@ -444,220 +467,192 @@
@Test
public void retrieveEdit() throws Exception {
- adminRestSession.get(urlEdit()).assertNoContent();
- assertThat(modifier.createEdit(change, ps)).isEqualTo(RefUpdate.Result.NEW);
- Optional<ChangeEdit> edit = editUtil.byChange(change);
- assertThat(modifier.modifyFile(edit.get(), FILE_NAME, RawInputUtil.create(CONTENT_NEW)))
- .isEqualTo(RefUpdate.Result.FORCED);
- edit = editUtil.byChange(change);
- EditInfo info = toEditInfo(false);
- assertThat(info.commit.commit).isEqualTo(edit.get().getRevision().get());
- assertThat(info.commit.parents).hasSize(1);
+ adminRestSession.get(urlEdit(changeId)).assertNoContent();
+ createArbitraryEditFor(changeId);
+ EditInfo editInfo = getEditInfo(changeId, false);
+ ChangeInfo changeInfo = get(changeId);
+ assertThat(editInfo.commit.commit).isNotEqualTo(changeInfo.currentRevision);
+ assertThat(editInfo).commit().parents().hasSize(1);
+ assertThat(editInfo).baseRevision().isEqualTo(changeInfo.currentRevision);
- edit = editUtil.byChange(change);
- editUtil.delete(edit.get());
+ gApi.changes()
+ .id(changeId)
+ .edit()
+ .delete();
- adminRestSession.get(urlEdit()).assertNoContent();
+ adminRestSession.get(urlEdit(changeId)).assertNoContent();
}
@Test
public void retrieveFilesInEdit() throws Exception {
- assertThat(modifier.createEdit(change, ps)).isEqualTo(RefUpdate.Result.NEW);
- Optional<ChangeEdit> edit = editUtil.byChange(change);
- assertThat(modifier.modifyFile(edit.get(), FILE_NAME, RawInputUtil.create(CONTENT_NEW)))
- .isEqualTo(RefUpdate.Result.FORCED);
+ createEmptyEditFor(changeId);
+ gApi.changes()
+ .id(changeId)
+ .edit()
+ .modifyFile(FILE_NAME, RawInputUtil.create(CONTENT_NEW));
- EditInfo info = toEditInfo(true);
- assertThat(info.files).hasSize(2);
- List<String> l = Lists.newArrayList(info.files.keySet());
- assertThat(l.get(0)).isEqualTo("/COMMIT_MSG");
- assertThat(l.get(1)).isEqualTo("foo");
+ EditInfo info = getEditInfo(changeId, true);
+ assertThat(info.files).isNotNull();
+ assertThat(info.files.keySet()).containsExactly(Patch.COMMIT_MSG,
+ FILE_NAME, FILE_NAME2);
}
@Test
public void deleteExistingFile() throws Exception {
- assertThat(modifier.createEdit(change, ps)).isEqualTo(RefUpdate.Result.NEW);
- Optional<ChangeEdit> edit = editUtil.byChange(change);
- assertThat(modifier.deleteFile(edit.get(), FILE_NAME)).isEqualTo(
- RefUpdate.Result.FORCED);
- edit = editUtil.byChange(change);
- exception.expect(ResourceNotFoundException.class);
- fileUtil.getContent(projectCache.get(edit.get().getChange().getProject()),
- ObjectId.fromString(edit.get().getRevision().get()), FILE_NAME);
+ createEmptyEditFor(changeId);
+ gApi.changes()
+ .id(changeId)
+ .edit()
+ .deleteFile(FILE_NAME);
+ assertThat(getFileContentOfEdit(changeId, FILE_NAME)).isAbsent();
}
@Test
public void renameExistingFile() throws Exception {
- assertThat(modifier.createEdit(change, ps)).isEqualTo(RefUpdate.Result.NEW);
- Optional<ChangeEdit> edit = editUtil.byChange(change);
- assertThat(modifier.renameFile(edit.get(), FILE_NAME, FILE_NAME3))
- .isEqualTo(RefUpdate.Result.FORCED);
- edit = editUtil.byChange(change);
- assertByteArray(fileUtil.getContent(projectCache.get(edit.get().getChange().getProject()),
- ObjectId.fromString(edit.get().getRevision().get()), FILE_NAME3), CONTENT_OLD);
- exception.expect(ResourceNotFoundException.class);
- fileUtil.getContent(projectCache.get(edit.get().getChange().getProject()),
- ObjectId.fromString(edit.get().getRevision().get()), FILE_NAME);
+ createEmptyEditFor(changeId);
+ gApi.changes()
+ .id(changeId)
+ .edit()
+ .renameFile(FILE_NAME, FILE_NAME3);
+ ensureSameBytes(getFileContentOfEdit(changeId, FILE_NAME3), CONTENT_OLD);
+ assertThat(getFileContentOfEdit(changeId, FILE_NAME)).isAbsent();
}
@Test
public void createEditByDeletingExistingFileRest() throws Exception {
- adminRestSession.delete(urlEditFile()).assertNoContent();
- Optional<ChangeEdit> edit = editUtil.byChange(change);
- exception.expect(ResourceNotFoundException.class);
- fileUtil.getContent(projectCache.get(edit.get().getChange().getProject()),
- ObjectId.fromString(edit.get().getRevision().get()), FILE_NAME);
+ adminRestSession.delete(urlEditFile(changeId, FILE_NAME)).assertNoContent();
+ assertThat(getFileContentOfEdit(changeId, FILE_NAME)).isAbsent();
}
@Test
public void deletingNonExistingEditRest() throws Exception {
- adminRestSession.delete(urlEdit()).assertNotFound();
+ adminRestSession.delete(urlEdit(changeId)).assertNotFound();
}
@Test
public void deleteExistingFileRest() throws Exception {
- assertThat(modifier.createEdit(change, ps)).isEqualTo(RefUpdate.Result.NEW);
- adminRestSession.delete(urlEditFile()).assertNoContent();
- Optional<ChangeEdit> edit = editUtil.byChange(change);
- exception.expect(ResourceNotFoundException.class);
- fileUtil.getContent(projectCache.get(edit.get().getChange().getProject()),
- ObjectId.fromString(edit.get().getRevision().get()), FILE_NAME);
+ createEmptyEditFor(changeId);
+ adminRestSession.delete(urlEditFile(changeId, FILE_NAME)).assertNoContent();
+ assertThat(getFileContentOfEdit(changeId, FILE_NAME)).isAbsent();
}
@Test
public void restoreDeletedFileInPatchSet() throws Exception {
- assertThat(modifier.createEdit(change2, ps2)).isEqualTo(
- RefUpdate.Result.NEW);
- Optional<ChangeEdit> edit = editUtil.byChange(change2);
- assertThat(modifier.restoreFile(edit.get(), FILE_NAME)).isEqualTo(
- RefUpdate.Result.FORCED);
- edit = editUtil.byChange(change2);
- assertByteArray(fileUtil.getContent(projectCache.get(edit.get().getChange().getProject()),
- ObjectId.fromString(edit.get().getRevision().get()), FILE_NAME), CONTENT_OLD);
+ createEmptyEditFor(changeId2);
+ gApi.changes()
+ .id(changeId2)
+ .edit()
+ .restoreFile(FILE_NAME);
+ ensureSameBytes(getFileContentOfEdit(changeId2, FILE_NAME), CONTENT_OLD);
}
@Test
public void revertChanges() throws Exception {
- assertThat(modifier.createEdit(change2, ps2)).isEqualTo(
- RefUpdate.Result.NEW);
- Optional<ChangeEdit> edit = editUtil.byChange(change2);
- assertThat(modifier.restoreFile(edit.get(), FILE_NAME)).isEqualTo(
- RefUpdate.Result.FORCED);
- edit = editUtil.byChange(change2);
- assertByteArray(fileUtil.getContent(projectCache.get(edit.get().getChange().getProject()),
- ObjectId.fromString(edit.get().getRevision().get()), FILE_NAME), CONTENT_OLD);
- assertThat(
- modifier.modifyFile(editUtil.byChange(change2).get(), FILE_NAME,
- RawInputUtil.create(CONTENT_NEW))).isEqualTo(RefUpdate.Result.FORCED);
- edit = editUtil.byChange(change2);
- assertByteArray(fileUtil.getContent(projectCache.get(edit.get().getChange().getProject()),
- ObjectId.fromString(edit.get().getRevision().get()), FILE_NAME), CONTENT_NEW);
- assertThat(modifier.restoreFile(edit.get(), FILE_NAME)).isEqualTo(
- RefUpdate.Result.FORCED);
- edit = editUtil.byChange(change2);
- assertByteArray(fileUtil.getContent(projectCache.get(edit.get().getChange().getProject()),
- ObjectId.fromString(edit.get().getRevision().get()), FILE_NAME), CONTENT_OLD);
- editUtil.delete(edit.get());
+ createEmptyEditFor(changeId2);
+ gApi.changes()
+ .id(changeId2)
+ .edit()
+ .restoreFile(FILE_NAME);
+ ensureSameBytes(getFileContentOfEdit(changeId2, FILE_NAME), CONTENT_OLD);
+ gApi.changes()
+ .id(changeId2)
+ .edit()
+ .modifyFile(FILE_NAME, RawInputUtil.create(CONTENT_NEW));
+ ensureSameBytes(getFileContentOfEdit(changeId2, FILE_NAME), CONTENT_NEW);
+ gApi.changes()
+ .id(changeId2)
+ .edit()
+ .restoreFile(FILE_NAME);
+ ensureSameBytes(getFileContentOfEdit(changeId2, FILE_NAME), CONTENT_OLD);
}
@Test
public void renameFileRest() throws Exception {
- assertThat(modifier.createEdit(change, ps)).isEqualTo(RefUpdate.Result.NEW);
+ createEmptyEditFor(changeId);
Post.Input in = new Post.Input();
in.oldPath = FILE_NAME;
in.newPath = FILE_NAME3;
- adminRestSession.post(urlEdit(), in).assertNoContent();
- Optional<ChangeEdit> edit = editUtil.byChange(change);
- assertByteArray(fileUtil.getContent(projectCache.get(edit.get().getChange().getProject()),
- ObjectId.fromString(edit.get().getRevision().get()), FILE_NAME3), CONTENT_OLD);
- exception.expect(ResourceNotFoundException.class);
- fileUtil.getContent(projectCache.get(edit.get().getChange().getProject()),
- ObjectId.fromString(edit.get().getRevision().get()), FILE_NAME);
+ adminRestSession.post(urlEdit(changeId), in).assertNoContent();
+ ensureSameBytes(getFileContentOfEdit(changeId, FILE_NAME3), CONTENT_OLD);
+ assertThat(getFileContentOfEdit(changeId, FILE_NAME)).isAbsent();
}
@Test
public void restoreDeletedFileInPatchSetRest() throws Exception {
Post.Input in = new Post.Input();
in.restorePath = FILE_NAME;
- adminRestSession.post(urlEdit2(), in).assertNoContent();
- Optional<ChangeEdit> edit = editUtil.byChange(change2);
- assertByteArray(fileUtil.getContent(projectCache.get(edit.get().getChange().getProject()),
- ObjectId.fromString(edit.get().getRevision().get()), FILE_NAME), CONTENT_OLD);
+ adminRestSession.post(urlEdit(changeId2), in).assertNoContent();
+ ensureSameBytes(getFileContentOfEdit(changeId2, FILE_NAME), CONTENT_OLD);
}
@Test
public void amendExistingFile() throws Exception {
- assertThat(modifier.createEdit(change, ps)).isEqualTo(RefUpdate.Result.NEW);
- Optional<ChangeEdit> edit = editUtil.byChange(change);
- assertThat(modifier.modifyFile(edit.get(), FILE_NAME, RawInputUtil.create(CONTENT_NEW)))
- .isEqualTo(RefUpdate.Result.FORCED);
- edit = editUtil.byChange(change);
- assertByteArray(fileUtil.getContent(projectCache.get(edit.get().getChange().getProject()),
- ObjectId.fromString(edit.get().getRevision().get()), FILE_NAME), CONTENT_NEW);
- assertThat(modifier.modifyFile(edit.get(), FILE_NAME, RawInputUtil.create(CONTENT_NEW2)))
- .isEqualTo(RefUpdate.Result.FORCED);
- edit = editUtil.byChange(change);
- assertByteArray(fileUtil.getContent(projectCache.get(edit.get().getChange().getProject()),
- ObjectId.fromString(edit.get().getRevision().get()), FILE_NAME), CONTENT_NEW2);
+ createEmptyEditFor(changeId);
+ gApi.changes()
+ .id(changeId)
+ .edit()
+ .modifyFile(FILE_NAME, RawInputUtil.create(CONTENT_NEW));
+ ensureSameBytes(getFileContentOfEdit(changeId, FILE_NAME), CONTENT_NEW);
+ gApi.changes()
+ .id(changeId)
+ .edit()
+ .modifyFile(FILE_NAME, RawInputUtil.create(CONTENT_NEW2));
+ ensureSameBytes(getFileContentOfEdit(changeId, FILE_NAME), CONTENT_NEW2);
}
@Test
public void createAndChangeEditInOneRequestRest() throws Exception {
Put.Input in = new Put.Input();
in.content = RawInputUtil.create(CONTENT_NEW);
- adminRestSession.putRaw(urlEditFile(), in.content).assertNoContent();
- Optional<ChangeEdit> edit = editUtil.byChange(change);
- assertByteArray(fileUtil.getContent(projectCache.get(edit.get().getChange().getProject()),
- ObjectId.fromString(edit.get().getRevision().get()), FILE_NAME), CONTENT_NEW);
+ adminRestSession.putRaw(urlEditFile(changeId, FILE_NAME), in.content)
+ .assertNoContent();
+ ensureSameBytes(getFileContentOfEdit(changeId, FILE_NAME), CONTENT_NEW);
in.content = RawInputUtil.create(CONTENT_NEW2);
- adminRestSession.putRaw(urlEditFile(), in.content).assertNoContent();
- edit = editUtil.byChange(change);
- assertByteArray(fileUtil.getContent(projectCache.get(edit.get().getChange().getProject()),
- ObjectId.fromString(edit.get().getRevision().get()), FILE_NAME), CONTENT_NEW2);
+ adminRestSession.putRaw(urlEditFile(changeId, FILE_NAME), in.content)
+ .assertNoContent();
+ ensureSameBytes(getFileContentOfEdit(changeId, FILE_NAME), CONTENT_NEW2);
}
@Test
public void changeEditRest() throws Exception {
- assertThat(modifier.createEdit(change, ps)).isEqualTo(RefUpdate.Result.NEW);
+ createEmptyEditFor(changeId);
Put.Input in = new Put.Input();
in.content = RawInputUtil.create(CONTENT_NEW);
- adminRestSession.putRaw(urlEditFile(), in.content).assertNoContent();
- Optional<ChangeEdit> edit = editUtil.byChange(change);
- assertByteArray(fileUtil.getContent(projectCache.get(edit.get().getChange().getProject()),
- ObjectId.fromString(edit.get().getRevision().get()), FILE_NAME), CONTENT_NEW);
+ adminRestSession.putRaw(urlEditFile(changeId, FILE_NAME), in.content)
+ .assertNoContent();
+ ensureSameBytes(getFileContentOfEdit(changeId, FILE_NAME), CONTENT_NEW);
}
@Test
public void emptyPutRequest() throws Exception {
- assertThat(modifier.createEdit(change, ps)).isEqualTo(RefUpdate.Result.NEW);
- adminRestSession.put(urlEditFile()).assertNoContent();
- Optional<ChangeEdit> edit = editUtil.byChange(change);
- assertByteArray(fileUtil.getContent(projectCache.get(edit.get().getChange().getProject()),
- ObjectId.fromString(edit.get().getRevision().get()), FILE_NAME), "".getBytes());
+ createEmptyEditFor(changeId);
+ adminRestSession.put(urlEditFile(changeId, FILE_NAME)).assertNoContent();
+ ensureSameBytes(getFileContentOfEdit(changeId, FILE_NAME), "".getBytes());
}
@Test
public void createEmptyEditRest() throws Exception {
- adminRestSession.post(urlEdit()).assertNoContent();
- Optional<ChangeEdit> edit = editUtil.byChange(change);
- assertByteArray(fileUtil.getContent(projectCache.get(edit.get().getChange().getProject()),
- ObjectId.fromString(edit.get().getRevision().get()), FILE_NAME), CONTENT_OLD);
+ adminRestSession.post(urlEdit(changeId)).assertNoContent();
+ ensureSameBytes(getFileContentOfEdit(changeId, FILE_NAME), CONTENT_OLD);
}
@Test
public void getFileContentRest() throws Exception {
Put.Input in = new Put.Input();
in.content = RawInputUtil.create(CONTENT_NEW);
- adminRestSession.putRaw(urlEditFile(), in.content).assertNoContent();
- Optional<ChangeEdit> edit = editUtil.byChange(change);
- assertThat(modifier.modifyFile(edit.get(), FILE_NAME, RawInputUtil.create(CONTENT_NEW2)))
- .isEqualTo(RefUpdate.Result.FORCED);
- RestResponse r = adminRestSession.getJsonAccept(urlEditFile());
+ adminRestSession.putRaw(urlEditFile(changeId, FILE_NAME), in.content)
+ .assertNoContent();
+ gApi.changes()
+ .id(changeId)
+ .edit()
+ .modifyFile(FILE_NAME, RawInputUtil.create(CONTENT_NEW2));
+ RestResponse r = adminRestSession.getJsonAccept(urlEditFile(changeId,
+ FILE_NAME));
r.assertOK();
assertThat(readContentFromJson(r)).isEqualTo(
new String(CONTENT_NEW2, UTF_8));
- r = adminRestSession.getJsonAccept(urlEditFile(true));
+ r = adminRestSession.getJsonAccept(urlEditFile(changeId, FILE_NAME, true));
r.assertOK();
assertThat(readContentFromJson(r)).isEqualTo(
new String(CONTENT_OLD, UTF_8));
@@ -665,51 +660,46 @@
@Test
public void getFileNotFoundRest() throws Exception {
- assertThat(modifier.createEdit(change, ps)).isEqualTo(RefUpdate.Result.NEW);
- adminRestSession.delete(urlEditFile()).assertNoContent();
- Optional<ChangeEdit> edit = editUtil.byChange(change);
- adminRestSession.get(urlEditFile()).assertNoContent();
- exception.expect(ResourceNotFoundException.class);
- fileUtil.getContent(projectCache.get(edit.get().getChange().getProject()),
- ObjectId.fromString(edit.get().getRevision().get()), FILE_NAME);
+ createEmptyEditFor(changeId);
+ adminRestSession.delete(urlEditFile(changeId, FILE_NAME)).assertNoContent();
+ adminRestSession.get(urlEditFile(changeId, FILE_NAME)).assertNoContent();
+ assertThat(getFileContentOfEdit(changeId, FILE_NAME)).isAbsent();
}
@Test
public void addNewFile() throws Exception {
- assertThat(modifier.createEdit(change, ps)).isEqualTo(RefUpdate.Result.NEW);
- Optional<ChangeEdit> edit = editUtil.byChange(change);
- assertThat(modifier.modifyFile(edit.get(), FILE_NAME2, RawInputUtil.create(CONTENT_NEW)))
- .isEqualTo(RefUpdate.Result.FORCED);
- edit = editUtil.byChange(change);
- assertByteArray(fileUtil.getContent(projectCache.get(edit.get().getChange().getProject()),
- ObjectId.fromString(edit.get().getRevision().get()), FILE_NAME2), CONTENT_NEW);
+ createEmptyEditFor(changeId);
+ gApi.changes()
+ .id(changeId)
+ .edit()
+ .modifyFile(FILE_NAME3, RawInputUtil.create(CONTENT_NEW));
+ ensureSameBytes(getFileContentOfEdit(changeId, FILE_NAME3), CONTENT_NEW);
}
@Test
public void addNewFileAndAmend() throws Exception {
- assertThat(modifier.createEdit(change, ps)).isEqualTo(RefUpdate.Result.NEW);
- Optional<ChangeEdit> edit = editUtil.byChange(change);
- assertThat(modifier.modifyFile(edit.get(), FILE_NAME2, RawInputUtil.create(CONTENT_NEW)))
- .isEqualTo(RefUpdate.Result.FORCED);
- edit = editUtil.byChange(change);
- assertByteArray(fileUtil.getContent(projectCache.get(edit.get().getChange().getProject()),
- ObjectId.fromString(edit.get().getRevision().get()), FILE_NAME2), CONTENT_NEW);
- assertThat(modifier.modifyFile(edit.get(), FILE_NAME2, RawInputUtil.create(CONTENT_NEW2)))
- .isEqualTo(RefUpdate.Result.FORCED);
- edit = editUtil.byChange(change);
- assertByteArray(fileUtil.getContent(projectCache.get(edit.get().getChange().getProject()),
- ObjectId.fromString(edit.get().getRevision().get()), FILE_NAME2), CONTENT_NEW2);
+ createEmptyEditFor(changeId);
+ gApi.changes()
+ .id(changeId)
+ .edit()
+ .modifyFile(FILE_NAME3, RawInputUtil.create(CONTENT_NEW));
+ ensureSameBytes(getFileContentOfEdit(changeId, FILE_NAME3), CONTENT_NEW);
+ gApi.changes()
+ .id(changeId)
+ .edit()
+ .modifyFile(FILE_NAME3, RawInputUtil.create(CONTENT_NEW2));
+ ensureSameBytes(getFileContentOfEdit(changeId, FILE_NAME3), CONTENT_NEW2);
}
@Test
public void writeNoChanges() throws Exception {
- assertThat(modifier.createEdit(change, ps)).isEqualTo(RefUpdate.Result.NEW);
- exception.expect(InvalidChangeOperationException.class);
+ createEmptyEditFor(changeId);
+ exception.expect(ResourceConflictException.class);
exception.expectMessage("no changes were made");
- modifier.modifyFile(
- editUtil.byChange(change).get(),
- FILE_NAME,
- RawInputUtil.create(CONTENT_OLD));
+ gApi.changes()
+ .id(changeId)
+ .edit()
+ .modifyFile(FILE_NAME, RawInputUtil.create(CONTENT_OLD));
}
@Test
@@ -721,24 +711,26 @@
cfg.getLabelSections().put(cr, codeReview);
saveProjectConfig(project, cfg);
- String changeId = change.getKey().get();
ReviewInput r = new ReviewInput();
- r.labels = ImmutableMap.<String, Short> of(cr, (short) 1);
+ r.labels = ImmutableMap.of(cr, (short) 1);
gApi.changes()
.id(changeId)
- .revision(change.currentPatchSetId().get())
+ .current()
.review(r);
- assertThat(modifier.createEdit(change, getCurrentPatchSet(changeId)))
- .isEqualTo(RefUpdate.Result.NEW);
- Optional<ChangeEdit> edit = editUtil.byChange(change);
+ createEmptyEditFor(changeId);
String newSubj = "New commit message";
String newMsg = newSubj + "\n\nChange-Id: " + changeId + "\n";
- assertThat(modifier.modifyMessage(edit.get(), newMsg))
- .isEqualTo(RefUpdate.Result.FORCED);
- edit = editUtil.byChange(change);
- editUtil.publish(edit.get(), NotifyHandling.NONE,
- ImmutableListMultimap.of());
+ gApi.changes()
+ .id(changeId)
+ .edit()
+ .modifyCommitMessage(newMsg);
+ PublishChangeEditInput publishInput = new PublishChangeEditInput();
+ publishInput.notify = NotifyHandling.NONE;
+ gApi.changes()
+ .id(changeId)
+ .edit()
+ .publish(publishInput);
ChangeInfo info = get(changeId);
assertThat(info.subject).isEqualTo(newSubj);
@@ -749,28 +741,36 @@
@Test
public void hasEditPredicate() throws Exception {
- assertThat(modifier.createEdit(change, ps)).isEqualTo(RefUpdate.Result.NEW);
+ createEmptyEditFor(changeId);
assertThat(queryEdits()).hasSize(1);
- PatchSet current = getCurrentPatchSet(changeId2);
- assertThat(modifier.createEdit(change2, current)).isEqualTo(RefUpdate.Result.NEW);
- assertThat(
- modifier.modifyFile(editUtil.byChange(change2).get(), FILE_NAME,
- RawInputUtil.create(CONTENT_NEW))).isEqualTo(RefUpdate.Result.FORCED);
+ createEmptyEditFor(changeId2);
+ gApi.changes()
+ .id(changeId2)
+ .edit()
+ .modifyFile(FILE_NAME, RawInputUtil.create(CONTENT_NEW));
assertThat(queryEdits()).hasSize(2);
- assertThat(
- modifier.modifyFile(editUtil.byChange(change).get(), FILE_NAME,
- RawInputUtil.create(CONTENT_NEW))).isEqualTo(RefUpdate.Result.FORCED);
- editUtil.delete(editUtil.byChange(change).get());
+ gApi.changes()
+ .id(changeId)
+ .edit()
+ .modifyFile(FILE_NAME, RawInputUtil.create(CONTENT_NEW));
+ gApi.changes()
+ .id(changeId)
+ .edit()
+ .delete();
assertThat(queryEdits()).hasSize(1);
- editUtil.publish(editUtil.byChange(change2).get(), NotifyHandling.NONE,
- ImmutableListMultimap.of());
+ PublishChangeEditInput publishInput = new PublishChangeEditInput();
+ publishInput.notify = NotifyHandling.NONE;
+ gApi.changes()
+ .id(changeId2)
+ .edit()
+ .publish(publishInput);
assertThat(queryEdits()).hasSize(0);
setApiUser(user);
- assertThat(modifier.createEdit(change, ps)).isEqualTo(RefUpdate.Result.NEW);
+ createEmptyEditFor(changeId);
assertThat(queryEdits()).hasSize(1);
setApiUser(admin);
@@ -779,35 +779,45 @@
@Test
public void files() throws Exception {
- assertThat(modifier.createEdit(change, ps)).isEqualTo(RefUpdate.Result.NEW);
- ChangeEdit edit = editUtil.byChange(change).get();
- assertThat(modifier.modifyFile(edit, FILE_NAME, RawInputUtil.create(CONTENT_NEW)))
- .isEqualTo(RefUpdate.Result.FORCED);
- edit = editUtil.byChange(change).get();
+ createEmptyEditFor(changeId);
+ gApi.changes()
+ .id(changeId)
+ .edit()
+ .modifyFile(FILE_NAME, RawInputUtil.create(CONTENT_NEW));
+ Optional<EditInfo> edit = getEdit(changeId);
+ assertThat(edit).isPresent();
+ @SuppressWarnings("OptionalGetWithoutIsPresent")
+ String editCommitId = edit.get().commit.commit;
- RestResponse r = adminRestSession.getJsonAccept(urlRevisionFiles(edit));
+ RestResponse r = adminRestSession.getJsonAccept(urlRevisionFiles(changeId,
+ editCommitId));
Map<String, FileInfo> files = readContentFromJson(
r, new TypeToken<Map<String, FileInfo>>() {});
assertThat(files).containsKey(FILE_NAME);
- r = adminRestSession.getJsonAccept(urlRevisionFiles());
+ r = adminRestSession.getJsonAccept(urlRevisionFiles(changeId));
files = readContentFromJson(r, new TypeToken<Map<String, FileInfo>>() {});
assertThat(files).containsKey(FILE_NAME);
}
@Test
public void diff() throws Exception {
- assertThat(modifier.createEdit(change, ps)).isEqualTo(RefUpdate.Result.NEW);
- ChangeEdit edit = editUtil.byChange(change).get();
- assertThat(modifier.modifyFile(edit, FILE_NAME, RawInputUtil.create(CONTENT_NEW)))
- .isEqualTo(RefUpdate.Result.FORCED);
- edit = editUtil.byChange(change).get();
+ createEmptyEditFor(changeId);
+ gApi.changes()
+ .id(changeId)
+ .edit()
+ .modifyFile(FILE_NAME, RawInputUtil.create(CONTENT_NEW));
+ Optional<EditInfo> edit = getEdit(changeId);
+ assertThat(edit).isPresent();
+ @SuppressWarnings("OptionalGetWithoutIsPresent")
+ String editCommitId = edit.get().commit.commit;
- RestResponse r = adminRestSession.getJsonAccept(urlDiff(edit));
+ RestResponse r = adminRestSession.getJsonAccept(urlDiff(changeId,
+ editCommitId, FILE_NAME));
DiffInfo diff = readContentFromJson(r, DiffInfo.class);
assertThat(diff.diffHeader.get(0)).contains(FILE_NAME);
- r = adminRestSession.getJsonAccept(urlDiff());
+ r = adminRestSession.getJsonAccept(urlDiff(changeId, FILE_NAME));
diff = readContentFromJson(r, DiffInfo.class);
assertThat(diff.diffHeader.get(0)).contains(FILE_NAME);
}
@@ -830,8 +840,35 @@
r1.assertOkStatus();
// Try to create edit as admin
- assertThat(modifier.createEdit(r1.getChange().change(),
- r1.getPatchSet())).isEqualTo(RefUpdate.Result.REJECTED);
+ exception.expect(AuthException.class);
+ createEmptyEditFor(r1.getChangeId());
+ }
+
+ private void createArbitraryEditFor(String changeId) throws Exception {
+ createEmptyEditFor(changeId);
+ arbitrarilyModifyEditOf(changeId);
+ }
+
+ private void createEmptyEditFor(String changeId) throws Exception {
+ gApi.changes()
+ .id(changeId)
+ .edit()
+ .create();
+ }
+
+ private void arbitrarilyModifyEditOf(String changeId) throws Exception {
+ gApi.changes()
+ .id(changeId)
+ .edit()
+ .modifyFile(FILE_NAME, RawInputUtil.create(CONTENT_NEW));
+ }
+
+ private Optional<BinaryResult> getFileContentOfEdit(String changeId,
+ String filePath) throws Exception {
+ return gApi.changes()
+ .id(changeId)
+ .edit()
+ .getFile(filePath);
}
private List<ChangeInfo> queryEdits() throws Exception {
@@ -845,117 +882,108 @@
return push.to("refs/for/master").getChangeId();
}
- private String amendChange(PersonIdent ident, String changeId) throws Exception {
- PushOneCommit push =
- pushFactory.create(db, ident, testRepo, PushOneCommit.SUBJECT, FILE_NAME2,
- new String(CONTENT_NEW2, UTF_8), changeId);
+ private String amendChange(PersonIdent ident, String changeId)
+ throws Exception {
+ PushOneCommit push = pushFactory.create(db, ident, testRepo,
+ PushOneCommit.SUBJECT, FILE_NAME2, new String(CONTENT_NEW2, UTF_8),
+ changeId);
return push.to("refs/for/master").getChangeId();
}
private String newChange2(PersonIdent ident) throws Exception {
- PushOneCommit push =
- pushFactory.create(db, ident, testRepo, PushOneCommit.SUBJECT, FILE_NAME,
- new String(CONTENT_OLD, UTF_8));
+ PushOneCommit push = pushFactory.create(db, ident, testRepo,
+ PushOneCommit.SUBJECT, FILE_NAME, new String(CONTENT_OLD, UTF_8));
return push.rm("refs/for/master").getChangeId();
}
- private Change getChange(String changeId) throws Exception {
- return getOnlyElement(queryProvider.get().byKeyPrefix(changeId)).change();
- }
-
private PatchSet getCurrentPatchSet(String changeId) throws Exception {
return getOnlyElement(queryProvider.get().byKeyPrefix(changeId))
.currentPatchSet();
}
- private static void assertByteArray(BinaryResult result, byte[] expected)
- throws Exception {
- ByteArrayOutputStream os = new ByteArrayOutputStream();
- result.writeTo(os);
- assertThat(os.toByteArray()).isEqualTo(expected);
+ @SuppressWarnings("OptionalUsedAsFieldOrParameterType")
+ private void ensureSameBytes(Optional<BinaryResult> fileContent,
+ byte[] expectedFileBytes) throws IOException {
+ assertThat(fileContent).value().bytes().isEqualTo(expectedFileBytes);
}
- private String urlEdit() {
+ private String urlEdit(String changeId) {
return "/changes/"
- + change.getChangeId()
+ + changeId
+ "/edit";
}
- private String urlEdit2() {
+ private String urlEditMessage(String changeId, boolean base) {
return "/changes/"
- + change2.getChangeId()
- + "/edit/";
- }
-
- private String urlEditMessage(boolean base) {
- return "/changes/"
- + change.getChangeId()
+ + changeId
+ "/edit:message"
+ (base ? "?base" : "");
}
- private String urlEditFile() {
- return urlEditFile(false);
+ private String urlEditFile(String changeId, String fileName) {
+ return urlEditFile(changeId, fileName, false);
}
- private String urlEditFile(boolean base) {
- return urlEdit()
+ private String urlEditFile(String changeId, String fileName, boolean base) {
+ return urlEdit(changeId)
+ "/"
- + FILE_NAME
+ + fileName
+ (base ? "?base" : "");
}
- private String urlGetFiles() {
- return urlEdit()
+ private String urlGetFiles(String changeId) {
+ return urlEdit(changeId)
+ "?list";
}
- private String urlRevisionFiles(ChangeEdit edit) {
+ private String urlRevisionFiles(String changeId, String revisionId) {
return "/changes/"
- + change.getChangeId()
+ + changeId
+ "/revisions/"
- + edit.getRevision().get()
+ + revisionId
+ "/files";
}
- private String urlRevisionFiles() {
+ private String urlRevisionFiles(String changeId) {
return "/changes/"
- + change.getChangeId()
+ + changeId
+ "/revisions/0/files";
}
- private String urlPublish() {
+ private String urlPublish(String changeId) {
return "/changes/"
- + change.getChangeId()
+ + changeId
+ "/edit:publish";
}
- private String urlRebase() {
+ private String urlRebase(String changeId) {
return "/changes/"
- + change.getChangeId()
+ + changeId
+ "/edit:rebase";
}
- private String urlDiff() {
+ private String urlDiff(String changeId, String fileName) {
return "/changes/"
- + change.getChangeId()
+ + changeId
+ "/revisions/0/files/"
- + FILE_NAME
+ + fileName
+ "/diff?context=ALL&intraline";
}
- private String urlDiff(ChangeEdit edit) {
+ private String urlDiff(String changeId, String revisionId, String fileName) {
return "/changes/"
- + change.getChangeId()
+ + changeId
+ "/revisions/"
- + edit.getRevision().get()
+ + revisionId
+ "/files/"
- + FILE_NAME
+ + fileName
+ "/diff?context=ALL&intraline";
}
- private EditInfo toEditInfo(boolean files) throws Exception {
- RestResponse r = adminRestSession.get(files ? urlGetFiles() : urlEdit());
+ private EditInfo getEditInfo(String changeId, boolean files)
+ throws Exception {
+ RestResponse r = adminRestSession.get(files ? urlGetFiles(changeId)
+ : urlEdit(changeId));
return readContentFromJson(r, EditInfo.class);
}
@@ -979,16 +1007,15 @@
return readContentFromJson(r, String.class);
}
- private void assertChangeMessages(Change c, List<String> expectedMessages)
+ private void assertChangeMessages(String changeId,
+ List<String> expectedMessages)
throws Exception {
- ChangeInfo ci = get(c.getId().toString());
+ ChangeInfo ci = get(changeId);
assertThat(ci.messages).isNotNull();
assertThat(ci.messages).hasSize(expectedMessages.size());
- List<String> actualMessages = new ArrayList<>();
- Iterator<ChangeMessageInfo> it = ci.messages.iterator();
- while (it.hasNext()) {
- actualMessages.add(it.next().message);
- }
+ List<String> actualMessages = ci.messages.stream()
+ .map(message -> message.message)
+ .collect(Collectors.toList());
assertThat(actualMessages)
.containsExactlyElementsIn(expectedMessages)
.inOrder();
diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/git/AbstractPushForReview.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/git/AbstractPushForReview.java
index d327134..f1af305 100644
--- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/git/AbstractPushForReview.java
+++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/git/AbstractPushForReview.java
@@ -20,6 +20,7 @@
import static com.google.gerrit.acceptance.GitUtil.assertPushRejected;
import static com.google.gerrit.acceptance.GitUtil.pushHead;
import static com.google.gerrit.common.FooterConstants.CHANGE_ID;
+import static com.google.gerrit.extensions.common.EditInfoSubject.assertThat;
import static com.google.gerrit.server.group.SystemGroupBackend.ANONYMOUS_USERS;
import static com.google.gerrit.server.project.Util.category;
import static com.google.gerrit.server.project.Util.value;
@@ -77,6 +78,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
import java.util.Set;
@@ -376,18 +378,20 @@
public void pushForMasterAsEdit() throws Exception {
PushOneCommit.Result r = pushTo("refs/for/master");
r.assertOkStatus();
- EditInfo edit = getEdit(r.getChangeId());
- assertThat(edit).isNull();
+ Optional<EditInfo> edit = getEdit(r.getChangeId());
+ assertThat(edit).isAbsent();
// specify edit as option
r = amendChange(r.getChangeId(), "refs/for/master%edit");
r.assertOkStatus();
edit = getEdit(r.getChangeId());
- assertThat(edit).isNotNull();
+ assertThat(edit).isPresent();
+ @SuppressWarnings("OptionalGetWithoutIsPresent")
+ EditInfo editInfo = edit.get();
r.assertMessage("Updated Changes:\n "
+ canonicalWebUrl.get()
+ r.getChange().getId()
- + " " + edit.commit.subject + " [EDIT]\n");
+ + " " + editInfo.commit.subject + " [EDIT]\n");
}
@Test
diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/git/BUCK b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/git/BUCK
deleted file mode 100644
index 42ece25..0000000
--- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/git/BUCK
+++ /dev/null
@@ -1,27 +0,0 @@
-include_defs('//gerrit-acceptance-tests/tests.defs')
-
-acceptance_tests(
- group = 'git',
- srcs = glob(['*IT.java']),
- deps = [
- ':submodule_util',
- ':push_for_review',
- '//gerrit-extension-api:api',
- ],
- labels = ['git'],
-)
-
-java_library(
- name = 'push_for_review',
- srcs = ['AbstractPushForReview.java'],
- deps = [
- '//gerrit-acceptance-tests:lib',
- '//lib/joda:joda-time',
- ],
-)
-
-java_library(
- name = 'submodule_util',
- srcs = ['AbstractSubmoduleSubscription.java',],
- deps = ['//gerrit-acceptance-tests:lib',]
-)
diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/git/RefAdvertisementIT.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/git/RefAdvertisementIT.java
index a7002fc..78fa70d 100644
--- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/git/RefAdvertisementIT.java
+++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/git/RefAdvertisementIT.java
@@ -36,7 +36,6 @@
import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.config.AnonymousCowardName;
-import com.google.gerrit.server.edit.ChangeEditModifier;
import com.google.gerrit.server.git.ProjectConfig;
import com.google.gerrit.server.git.ReceiveCommitsAdvertiseRefsHook;
import com.google.gerrit.server.git.SearchingChangeCacheImpl;
@@ -69,9 +68,6 @@
@NoHttpd
public class RefAdvertisementIT extends AbstractDaemonTest {
@Inject
- private ChangeEditModifier editModifier;
-
- @Inject
private ProjectControl.GenericFactory projectControlFactory;
@Inject
@@ -260,15 +256,21 @@
deny(Permission.READ, REGISTERED_USERS, "refs/heads/branch");
Change c = notesFactory.createChecked(db, project, c1.getId()).getChange();
- PatchSet ps1 = getPatchSet(new PatchSet.Id(c1.getId(), 1));
+ String changeId = c.getKey().get();
// Admin's edit is not visible.
setApiUser(admin);
- editModifier.createEdit(c, ps1);
+ gApi.changes()
+ .id(changeId)
+ .edit()
+ .create();
// User's edit is visible.
setApiUser(user);
- editModifier.createEdit(c, ps1);
+ gApi.changes()
+ .id(changeId)
+ .edit()
+ .create();
assertUploadPackRefs(
"HEAD",
@@ -288,9 +290,12 @@
deny(Permission.READ, REGISTERED_USERS, "refs/heads/master");
allow(Permission.READ, REGISTERED_USERS, "refs/heads/branch");
- PatchSet ps1 = getPatchSet(new PatchSet.Id(c1.getId(), 1));
+ String changeId = c1.change().getKey().get();
setApiUser(admin);
- editModifier.createEdit(c1.change(), ps1);
+ gApi.changes()
+ .id(changeId)
+ .edit()
+ .create();
setApiUser(user);
assertUploadPackRefs(
diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/pgm/BUCK b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/pgm/BUCK
deleted file mode 100644
index 3522991..0000000
--- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/pgm/BUCK
+++ /dev/null
@@ -1,7 +0,0 @@
-include_defs('//gerrit-acceptance-tests/tests.defs')
-
-acceptance_tests(
- group = 'pgm',
- srcs = glob(['*IT.java']),
- labels = ['pgm'],
-)
diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/account/BUCK b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/account/BUCK
deleted file mode 100644
index 76c918b..0000000
--- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/account/BUCK
+++ /dev/null
@@ -1,23 +0,0 @@
-include_defs('//gerrit-acceptance-tests/tests.defs')
-
-acceptance_tests(
- group = 'rest_account',
- srcs = glob(['*IT.java']),
- deps = [':util'],
- labels = ['rest'],
-)
-
-java_library(
- name = 'util',
- srcs = [
- 'AccountAssert.java',
- 'CapabilityInfo.java',
- ],
- deps = [
- '//gerrit-acceptance-tests:lib',
- '//gerrit-reviewdb:server',
- '//lib:gwtorm',
- '//lib:junit',
- ],
- visibility = ['//gerrit-acceptance-tests/...'],
-)
diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/change/BUCK b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/change/BUCK
deleted file mode 100644
index 654ce29..0000000
--- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/change/BUCK
+++ /dev/null
@@ -1,34 +0,0 @@
-include_defs('//gerrit-acceptance-tests/tests.defs')
-
-SUBMIT_UTIL_SRCS = glob(['AbstractSubmit*.java'])
-SUBMIT_TESTS = glob(['Submit*IT.java'])
-OTHER_TESTS = glob(['*IT.java'], excludes = SUBMIT_TESTS)
-
-acceptance_tests(
- group = 'rest_change_other',
- srcs = OTHER_TESTS,
- deps = [
- ':submit_util',
- '//gerrit-server:server',
- '//lib/guice:guice',
- '//lib/joda:joda-time',
- ],
- labels = ['rest'],
-)
-
-acceptance_tests(
- group = 'rest_change_submit',
- srcs = SUBMIT_TESTS,
- deps = [
- ':submit_util',
- ],
- labels = ['rest'],
-)
-
-java_library(
- name = 'submit_util',
- srcs = SUBMIT_UTIL_SRCS,
- deps = [
- '//gerrit-acceptance-tests:lib',
- ],
-)
diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/change/DeleteVoteIT.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/change/DeleteVoteIT.java
index c36c44b..fb25da1 100644
--- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/change/DeleteVoteIT.java
+++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/change/DeleteVoteIT.java
@@ -19,7 +19,6 @@
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
-import com.google.gson.reflect.TypeToken;
import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.acceptance.PushOneCommit;
import com.google.gerrit.acceptance.RestResponse;
@@ -29,6 +28,7 @@
import com.google.gerrit.extensions.common.ChangeMessageInfo;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.testutil.FakeEmailSender;
+import com.google.gson.reflect.TypeToken;
import org.junit.Test;
diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/config/BUCK b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/config/BUCK
deleted file mode 100644
index d65b84a..0000000
--- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/config/BUCK
+++ /dev/null
@@ -1,7 +0,0 @@
-include_defs('//gerrit-acceptance-tests/tests.defs')
-
-acceptance_tests(
- group = 'rest_config',
- srcs = glob(['*IT.java']),
- labels = ['rest']
-)
diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/group/BUCK b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/group/BUCK
deleted file mode 100644
index 1947148..0000000
--- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/group/BUCK
+++ /dev/null
@@ -1,8 +0,0 @@
-include_defs('//gerrit-acceptance-tests/tests.defs')
-
-acceptance_tests(
- group = 'rest_group',
- srcs = glob(['*IT.java']),
- labels = ['rest']
-)
-
diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/project/BUCK b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/project/BUCK
deleted file mode 100644
index 2d3e2da..0000000
--- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/project/BUCK
+++ /dev/null
@@ -1,37 +0,0 @@
-include_defs('//gerrit-acceptance-tests/tests.defs')
-
-acceptance_tests(
- group = 'rest_project',
- srcs = glob(['*IT.java']),
- deps = [
- ':project',
- ':refassert',
- ],
- labels = ['rest'],
-)
-
-java_library(
- name = 'refassert',
- srcs = [
- 'RefAssert.java',
- ],
- deps = [
- '//lib:truth',
- '//gerrit-extension-api:api',
- '//gerrit-server:server',
- ],
-)
-
-java_library(
- name = 'project',
- srcs = [
- 'ProjectAssert.java',
- ],
- deps = [
- '//gerrit-extension-api:api',
- '//gerrit-reviewdb:server',
- '//gerrit-server:server',
- '//lib:gwtorm',
- '//lib:truth',
- ],
-)
diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/change/BUCK b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/change/BUCK
deleted file mode 100644
index 5384447..0000000
--- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/change/BUCK
+++ /dev/null
@@ -1,7 +0,0 @@
-include_defs('//gerrit-acceptance-tests/tests.defs')
-
-acceptance_tests(
- group = 'server_change',
- srcs = glob(['*IT.java']),
- labels = ['server'],
-)
diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/change/CommentsIT.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/change/CommentsIT.java
index 5b087a4..68b87da 100644
--- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/change/CommentsIT.java
+++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/change/CommentsIT.java
@@ -150,6 +150,40 @@
}
@Test
+ public void postCommentWithReply() throws Exception {
+ for (Integer line : lines) {
+ String file = "file";
+ String contents = "contents " + line;
+ PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo,
+ "first subject", file, contents);
+ PushOneCommit.Result r = push.to("refs/for/master");
+ String changeId = r.getChangeId();
+ String revId = r.getCommit().getName();
+ ReviewInput input = new ReviewInput();
+ CommentInput comment =
+ newComment(file, Side.REVISION, line, "comment 1", false);
+ input.comments = new HashMap<>();
+ input.comments.put(comment.path, Lists.newArrayList(comment));
+ revision(r).review(input);
+ Map<String, List<CommentInfo>> result =
+ getPublishedComments(changeId, revId);
+ CommentInfo actual = Iterables.getOnlyElement(result.get(comment.path));
+
+ input = new ReviewInput();
+ comment = newComment(file, Side.REVISION, line, "comment 1 reply", false);
+ comment.inReplyTo = actual.id;
+ input.comments = new HashMap<>();
+ input.comments.put(comment.path, Lists.newArrayList(comment));
+ revision(r).review(input);
+ result = getPublishedComments(changeId, revId);
+ actual = result.get(comment.path).get(1);
+ assertThat(comment).isEqualTo(infoToInput(file).apply(actual));
+ assertThat(comment).isEqualTo(infoToInput(file).apply(
+ getPublishedComment(changeId, revId, actual.id)));
+ }
+ }
+
+ @Test
public void postCommentWithUnresolved() throws Exception {
for (Integer line : lines) {
String file = "file";
@@ -786,5 +820,6 @@
to.message = from.message;
to.range = from.range;
to.unresolved = from.unresolved;
+ to.inReplyTo = from.inReplyTo;
}
}
diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/change/GetRelatedIT.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/change/GetRelatedIT.java
index a39f300..66200d7 100644
--- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/change/GetRelatedIT.java
+++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/change/GetRelatedIT.java
@@ -16,6 +16,7 @@
import static com.google.common.truth.Truth.assertThat;
import static com.google.gerrit.acceptance.GitUtil.pushHead;
+import static com.google.gerrit.extensions.common.EditInfoSubject.assertThat;
import static java.util.concurrent.TimeUnit.SECONDS;
import com.google.common.collect.ImmutableList;
@@ -27,13 +28,12 @@
import com.google.gerrit.common.RawInputUtil;
import com.google.gerrit.common.TimeUtil;
import com.google.gerrit.extensions.common.CommitInfo;
+import com.google.gerrit.extensions.common.EditInfo;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gerrit.server.change.ChangesCollection;
import com.google.gerrit.server.change.GetRelated.ChangeAndCommit;
import com.google.gerrit.server.change.GetRelated.RelatedInfo;
-import com.google.gerrit.server.edit.ChangeEditModifier;
-import com.google.gerrit.server.edit.ChangeEditUtil;
import com.google.gerrit.server.git.BatchUpdate;
import com.google.gerrit.server.git.BatchUpdate.ChangeContext;
import com.google.gerrit.server.query.change.ChangeData;
@@ -48,6 +48,7 @@
import org.junit.Test;
import java.util.List;
+import java.util.Optional;
public class GetRelatedIT extends AbstractDaemonTest {
private String systemTimeZone;
@@ -65,12 +66,6 @@
}
@Inject
- private ChangeEditUtil editUtil;
-
- @Inject
- private ChangeEditModifier editModifier;
-
- @Inject
private BatchUpdate.Factory updateFactory;
@Inject
@@ -579,11 +574,19 @@
pushHead(testRepo, "refs/for/master", false);
Change ch2 = getChange(c2_1).change();
- editModifier.createEdit(ch2, getPatchSet(ch2.currentPatchSetId()));
- editModifier.modifyFile(editUtil.byChange(ch2).get(), "a.txt",
- RawInputUtil.create(new byte[] {'a'}));
- ObjectId editRev =
- ObjectId.fromString(editUtil.byChange(ch2).get().getRevision().get());
+ String changeId2 = ch2.getKey().get();
+ gApi.changes()
+ .id(changeId2)
+ .edit()
+ .create();
+ gApi.changes()
+ .id(changeId2)
+ .edit()
+ .modifyFile("a.txt", RawInputUtil.create(new byte[] {'a'}));
+ Optional<EditInfo> edit = getEdit(changeId2);
+ assertThat(edit).isPresent();
+ @SuppressWarnings("OptionalGetWithoutIsPresent")
+ ObjectId editRev = ObjectId.fromString(edit.get().commit.commit);
PatchSet.Id ps1_1 = getPatchSetId(c1_1);
PatchSet.Id ps2_1 = getPatchSetId(c2_1);
diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/event/BUCK b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/event/BUCK
deleted file mode 100644
index 4fbc977..0000000
--- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/event/BUCK
+++ /dev/null
@@ -1,7 +0,0 @@
-include_defs('//gerrit-acceptance-tests/tests.defs')
-
-acceptance_tests(
- group = 'server_event',
- srcs = glob(['*IT.java']),
- labels = ['server'],
-)
diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/mail/BUCK b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/mail/BUCK
deleted file mode 100644
index c642154..0000000
--- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/mail/BUCK
+++ /dev/null
@@ -1,10 +0,0 @@
-include_defs('//gerrit-acceptance-tests/tests.defs')
-
-acceptance_tests(
- group = 'server_mail',
- srcs = glob(['*IT.java']),
- labels = ['server'],
- deps = [
- '//lib/joda:joda-time',
- ],
-)
diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/notedb/BUCK b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/notedb/BUCK
deleted file mode 100644
index d9976e5..0000000
--- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/notedb/BUCK
+++ /dev/null
@@ -1,7 +0,0 @@
-include_defs('//gerrit-acceptance-tests/tests.defs')
-
-acceptance_tests(
- group = 'server_notedb',
- srcs = glob(['*IT.java']),
- labels = ['notedb', 'server'],
-)
diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/notedb/ChangeRebuilderIT.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/notedb/ChangeRebuilderIT.java
index cb3a9ff..00be7ba 100644
--- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/notedb/ChangeRebuilderIT.java
+++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/notedb/ChangeRebuilderIT.java
@@ -208,7 +208,18 @@
public void publishedComment() throws Exception {
PushOneCommit.Result r = createChange();
Change.Id id = r.getPatchSetId().getParentKey();
- putComment(user, id, 1, "comment");
+ putComment(user, id, 1, "comment", null);
+ checker.rebuildAndCheckChanges(id);
+ }
+
+ @Test
+ public void publishedCommentAndReply() throws Exception {
+ PushOneCommit.Result r = createChange();
+ Change.Id id = r.getPatchSetId().getParentKey();
+ putComment(user, id, 1, "comment", null);
+ Map<String, List<CommentInfo>> comments = getPublishedComments(id);
+ String parentUuid = comments.get("a.txt").get(0).id;
+ putComment(user, id, 1, "comment", parentUuid);
checker.rebuildAndCheckChanges(id);
}
@@ -242,7 +253,7 @@
PushOneCommit.Result r = createChange();
Change.Id id = r.getPatchSetId().getParentKey();
putDraft(user, id, 1, "draft comment", null);
- putComment(user, id, 1, "published comment");
+ putComment(user, id, 1, "published comment", null);
checker.rebuildAndCheckChanges(id);
}
@@ -1283,11 +1294,12 @@
}
}
- private void putComment(TestAccount account, Change.Id id, int line, String msg)
- throws Exception {
+ private void putComment(TestAccount account, Change.Id id, int line,
+ String msg, String inReplyTo) throws Exception {
CommentInput in = new CommentInput();
in.line = line;
in.message = msg;
+ in.inReplyTo = inReplyTo;
ReviewInput rin = new ReviewInput();
rin.comments = new HashMap<>();
rin.comments.put(PushOneCommit.FILE_NAME, ImmutableList.of(in));
@@ -1348,4 +1360,8 @@
saveProjectConfig(allProjects, cfg);
}
+ private Map<String, List<CommentInfo>> getPublishedComments(Change.Id id)
+ throws Exception {
+ return gApi.changes().id(id.get()).current().comments();
+ }
}
diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/notedb/NoteDbPrimaryIT.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/notedb/NoteDbPrimaryIT.java
index 7b41ee0..fc39a97 100644
--- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/notedb/NoteDbPrimaryIT.java
+++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/notedb/NoteDbPrimaryIT.java
@@ -18,12 +18,16 @@
import static com.google.common.truth.Truth.assert_;
import static com.google.common.truth.TruthJUnit.assume;
import static com.google.gerrit.server.notedb.NoteDbChangeState.PrimaryStorage.REVIEW_DB;
+import static java.util.concurrent.TimeUnit.DAYS;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static java.util.concurrent.TimeUnit.SECONDS;
import static java.util.stream.Collectors.toList;
import com.google.common.base.Throwables;
import com.google.common.collect.Iterables;
import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.acceptance.PushOneCommit;
+import com.google.gerrit.common.Nullable;
import com.google.gerrit.common.TimeUtil;
import com.google.gerrit.extensions.api.changes.DraftInput;
import com.google.gerrit.extensions.api.changes.ReviewInput;
@@ -39,11 +43,22 @@
import com.google.gerrit.server.git.RepoRefCache;
import com.google.gerrit.server.notedb.ChangeNotes;
import com.google.gerrit.server.notedb.NoteDbChangeState;
+import com.google.gerrit.server.notedb.NoteDbChangeState.PrimaryStorage;
+import com.google.gerrit.server.notedb.PrimaryStorageMigrator;
+import com.google.gerrit.server.notedb.TestChangeRebuilderWrapper;
+import com.google.gerrit.testutil.ConfigSuite;
import com.google.gerrit.testutil.NoteDbMode;
import com.google.gerrit.testutil.TestTimeUtil;
+import com.google.gwtorm.server.OrmException;
import com.google.gwtorm.server.OrmRuntimeException;
import com.google.inject.Inject;
+import com.google.inject.util.Providers;
+import com.github.rholder.retry.Retryer;
+import com.github.rholder.retry.RetryerBuilder;
+import com.github.rholder.retry.StopStrategies;
+
+import org.eclipse.jgit.lib.Config;
import org.eclipse.jgit.lib.Repository;
import org.junit.After;
import org.junit.Before;
@@ -54,17 +69,38 @@
import java.util.Collections;
import java.util.List;
import java.util.Optional;
-import java.util.concurrent.TimeUnit;
public class NoteDbPrimaryIT extends AbstractDaemonTest {
+ @ConfigSuite.Default
+ public static Config defaultConfig() {
+ Config cfg = new Config();
+ cfg.setString("notedb", null, "concurrentWriterTimeout", "0s");
+ cfg.setString("notedb", null, "primaryStorageMigrationTimeout", "1d");
+ cfg.setBoolean("noteDb", null, "testRebuilderWrapper", true);
+ return cfg;
+ }
+
@Inject
private AllUsersName allUsers;
+ @Inject
+ private TestChangeRebuilderWrapper rebuilderWrapper;
+
+ private PrimaryStorageMigrator migrator;
+
@Before
public void setUp() throws Exception {
assume().that(NoteDbMode.get()).isEqualTo(NoteDbMode.READ_WRITE);
db = ReviewDbUtil.unwrapDb(db);
- TestTimeUtil.resetWithClockStep(1, TimeUnit.SECONDS);
+ TestTimeUtil.resetWithClockStep(1, SECONDS);
+ migrator = newMigrator(null);
+ }
+
+ private PrimaryStorageMigrator newMigrator(
+ @Nullable Retryer<NoteDbChangeState> ensureRebuiltRetryer) {
+ return new PrimaryStorageMigrator(
+ cfg, Providers.of(db), repoManager, allUsers, rebuilderWrapper,
+ ensureRebuiltRetryer);
}
@After
@@ -228,6 +264,124 @@
assertThat(gApi.changes().id(id.get()).get().topic).isEqualTo("a-topic");
}
+ @Test
+ public void migrateToNoteDb() throws Exception {
+ testMigrateToNoteDb(createChange().getChange().getId());
+ }
+
+ @Test
+ public void migrateToNoteDbWithRebuildingFirst() throws Exception {
+ PushOneCommit.Result r = createChange();
+ Change.Id id = r.getChange().getId();
+
+ Change c = db.changes().get(id);
+ c.setNoteDbState("deadbeefdeadbeefdeadbeefdeadbeefdeadbeef");
+ db.changes().update(Collections.singleton(c));
+ testMigrateToNoteDb(id);
+ }
+
+ private void testMigrateToNoteDb(Change.Id id) throws Exception {
+ assertThat(PrimaryStorage.of(db.changes().get(id)))
+ .isEqualTo(PrimaryStorage.REVIEW_DB);
+ migrator.migrateToNoteDbPrimary(id);
+ assertNoteDbPrimary(id);
+
+ gApi.changes().id(id.get()).topic("a-topic");
+ assertThat(gApi.changes().id(id.get()).get().topic).isEqualTo("a-topic");
+ assertThat(db.changes().get(id).getTopic()).isNull();
+ }
+
+ @Test
+ public void migrateToNoteDbFailsRebuildingOnceAndRetries() throws Exception {
+ Change.Id id = createChange().getChange().getId();
+
+ Change c = db.changes().get(id);
+ c.setNoteDbState("deadbeefdeadbeefdeadbeefdeadbeefdeadbeef");
+ db.changes().update(Collections.singleton(c));
+ rebuilderWrapper.failNextUpdate();
+
+ migrator = newMigrator(
+ RetryerBuilder.<NoteDbChangeState> newBuilder()
+ .retryIfException()
+ .withStopStrategy(StopStrategies.neverStop())
+ .build());
+ migrator.migrateToNoteDbPrimary(id);
+ assertNoteDbPrimary(id);
+ }
+
+ @Test
+ public void migrateToNoteDbFailsRebuildingAndStops() throws Exception {
+ Change.Id id = createChange().getChange().getId();
+
+ Change c = db.changes().get(id);
+ c.setNoteDbState("deadbeefdeadbeefdeadbeefdeadbeefdeadbeef");
+ db.changes().update(Collections.singleton(c));
+ rebuilderWrapper.failNextUpdate();
+
+ migrator = newMigrator(
+ RetryerBuilder.<NoteDbChangeState> newBuilder()
+ .retryIfException()
+ .withStopStrategy(StopStrategies.stopAfterAttempt(1))
+ .build());
+ exception.expect(OrmException.class);
+ exception.expectMessage("Retrying failed");
+ migrator.migrateToNoteDbPrimary(id);
+ }
+
+ @Test
+ public void migrateToNoteDbMissingOldState() throws Exception {
+ PushOneCommit.Result r = createChange();
+ Change.Id id = r.getChange().getId();
+
+ Change c = db.changes().get(id);
+ c.setNoteDbState(null);
+ db.changes().update(Collections.singleton(c));
+
+ exception.expect(OrmRuntimeException.class);
+ exception.expectMessage("no note_db_state");
+ migrator.migrateToNoteDbPrimary(id);
+ }
+
+ @Test
+ public void migrateToNoteDbLeaseExpires() throws Exception {
+ TestTimeUtil.resetWithClockStep(2, DAYS);
+ exception.expect(OrmRuntimeException.class);
+ exception.expectMessage("read-only lease");
+ migrator.migrateToNoteDbPrimary(createChange().getChange().getId());
+ }
+
+ @Test
+ public void migrateToNoteDbAlreadyReadOnly() throws Exception {
+ PushOneCommit.Result r = createChange();
+ Change.Id id = r.getChange().getId();
+
+ Change c = db.changes().get(id);
+ NoteDbChangeState state = NoteDbChangeState.parse(c);
+ Timestamp until =
+ new Timestamp(TimeUtil.nowMs() + MILLISECONDS.convert(1, DAYS));
+ state = state.withReadOnlyUntil(until);
+ c.setNoteDbState(state.toString());
+ db.changes().update(Collections.singleton(c));
+
+ exception.expect(OrmRuntimeException.class);
+ exception.expectMessage("read-only until " + until);
+ migrator.migrateToNoteDbPrimary(id);
+ }
+
+ @Test
+ public void migrateToNoteDbAlreadyMigrated() throws Exception {
+ PushOneCommit.Result r = createChange();
+ Change.Id id = r.getChange().getId();
+
+ assertThat(PrimaryStorage.of(db.changes().get(id)))
+ .isEqualTo(PrimaryStorage.REVIEW_DB);
+ migrator.migrateToNoteDbPrimary(id);
+ assertNoteDbPrimary(id);
+
+ migrator.migrateToNoteDbPrimary(id);
+ assertNoteDbPrimary(id);
+ }
+
private void setNoteDbPrimary(Change.Id id) throws Exception {
Change c = db.changes().get(id);
assertThat(c).named("change " + id).isNotNull();
@@ -249,6 +403,11 @@
db.changes().update(Collections.singleton(c));
}
+ private void assertNoteDbPrimary(Change.Id id) throws Exception {
+ assertThat(PrimaryStorage.of(db.changes().get(id)))
+ .isEqualTo(PrimaryStorage.NOTE_DB);
+ }
+
private List<Account.Id> getReviewers(Change.Id id) throws Exception {
return gApi.changes().id(id.get()).get()
.reviewers.values().stream()
diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/project/BUCK b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/project/BUCK
deleted file mode 100644
index 013115d..0000000
--- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/project/BUCK
+++ /dev/null
@@ -1,7 +0,0 @@
-include_defs('//gerrit-acceptance-tests/tests.defs')
-
-acceptance_tests(
- group = 'server_project',
- srcs = glob(['*IT.java']),
- labels = ['server'],
-)
diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/ssh/BUCK b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/ssh/BUCK
deleted file mode 100644
index 0729b68..0000000
--- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/ssh/BUCK
+++ /dev/null
@@ -1,8 +0,0 @@
-include_defs('//gerrit-acceptance-tests/tests.defs')
-
-acceptance_tests(
- group = 'ssh',
- srcs = glob(['*IT.java']),
- deps = ['//lib/commons:compress'],
- labels = ['ssh'],
-)
diff --git a/gerrit-acceptance-tests/tests.defs b/gerrit-acceptance-tests/tests.defs
deleted file mode 100644
index 648bd63..0000000
--- a/gerrit-acceptance-tests/tests.defs
+++ /dev/null
@@ -1,27 +0,0 @@
-BOUNCYCASTLE = [
- '//lib/bouncycastle:bcpkix',
- '//lib/bouncycastle:bcpg',
-]
-
-def acceptance_tests(
- group,
- srcs,
- deps = [],
- labels = [],
- vm_args = ['-Xmx256m']):
- from os import path
- if path.exists('/dev/urandom'):
- vm_args = vm_args + ['-Djava.security.egd=file:/dev/./urandom']
-
- java_test(
- name = group,
- srcs = srcs,
- deps = deps + BOUNCYCASTLE + [
- '//gerrit-acceptance-tests:lib'
- ],
- labels = labels + [
- 'acceptance',
- 'slow',
- ],
- vm_args = vm_args,
- )
diff --git a/gerrit-antlr/BUCK b/gerrit-antlr/BUCK
deleted file mode 100644
index e858a72..0000000
--- a/gerrit-antlr/BUCK
+++ /dev/null
@@ -1,36 +0,0 @@
-PARSER_DEPS = [
- ':query_exception',
- '//lib/antlr:java_runtime',
-]
-
-java_library(
- name = 'query_exception',
- srcs = ['src/main/java/com/google/gerrit/server/query/QueryParseException.java'],
- visibility = ['PUBLIC'],
-)
-
-genantlr(
- name = 'query_antlr',
- srcs = ['src/main/antlr3/com/google/gerrit/server/query/Query.g'],
- out = 'query_antlr.src.zip',
-)
-
-java_library(
- name = 'lib',
- srcs = [':query_antlr'],
- deps = PARSER_DEPS,
-)
-
-# Hack necessary to expose ANTLR generated code as JAR to Eclipse.
-genrule(
- name = 'query_link',
- cmd = 'ln -s $(location :lib) $OUT',
- out = 'query_parser.jar',
-)
-
-prebuilt_jar(
- name = 'query_parser',
- binary_jar = ':query_link',
- deps = PARSER_DEPS,
- visibility = ['PUBLIC'],
-)
diff --git a/gerrit-cache-h2/BUCK b/gerrit-cache-h2/BUCK
deleted file mode 100644
index 0bc1cb12..0000000
--- a/gerrit-cache-h2/BUCK
+++ /dev/null
@@ -1,28 +0,0 @@
-java_library(
- name = 'cache-h2',
- srcs = glob(['src/main/java/**/*.java']),
- deps = [
- '//gerrit-common:server',
- '//gerrit-extension-api:api',
- '//gerrit-server:server',
- '//lib:guava',
- '//lib:h2',
- '//lib/guice:guice',
- '//lib/jgit/org.eclipse.jgit:jgit',
- '//lib/log:api',
- ],
- visibility = ['PUBLIC'],
-)
-
-java_test(
- name = 'tests',
- srcs = glob(['src/test/java/**/*.java']),
- deps = [
- ':cache-h2',
- '//gerrit-server:server',
- '//lib:guava',
- '//lib:h2',
- '//lib/guice:guice',
- '//lib:junit',
- ],
-)
diff --git a/gerrit-common/BUCK b/gerrit-common/BUCK
deleted file mode 100644
index b2ae8b0..0000000
--- a/gerrit-common/BUCK
+++ /dev/null
@@ -1,75 +0,0 @@
-SRC = 'src/main/java/com/google/gerrit/'
-
-ANNOTATIONS = [
- SRC + x for x in [
- 'common/Nullable.java',
- 'common/audit/Audit.java',
- 'common/auth/SignInRequired.java',
- ]
-]
-
-java_library(
- name = 'annotations',
- srcs = ANNOTATIONS,
- visibility = ['PUBLIC'],
-)
-
-gwt_module(
- name = 'client',
- srcs = glob([SRC + 'common/**/*.java']),
- gwt_xml = SRC + 'Common.gwt.xml',
- exported_deps = [
- '//gerrit-extension-api:api',
- '//gerrit-prettify:client',
- '//lib:guava',
- '//lib:gwtorm_client',
- '//lib/jgit/org.eclipse.jgit:jgit',
- '//lib/joda:joda-time',
- '//lib/log:api',
- ],
- provided_deps = ['//lib:servlet-api-3_1'],
- visibility = ['PUBLIC'],
-)
-
-java_library(
- name = 'server',
- srcs = glob([SRC + 'common/**/*.java'], excludes = ANNOTATIONS),
- deps = [
- ':annotations',
- '//gerrit-extension-api:api',
- '//gerrit-patch-jgit:server',
- '//gerrit-prettify:server',
- '//gerrit-reviewdb:server',
- '//lib:guava',
- '//lib:gwtjsonrpc',
- '//lib:gwtorm',
- '//lib/jgit/org.eclipse.jgit:jgit',
- '//lib/joda:joda-time',
- '//lib/log:api',
- ],
- provided_deps = ['//lib:servlet-api-3_1'],
- visibility = ['PUBLIC'],
-)
-
-TEST = 'src/test/java/com/google/gerrit/common/'
-AUTO_VALUE_TEST_SRCS = [TEST + 'AutoValueTest.java']
-
-java_test(
- name = 'client_tests',
- srcs = glob(['src/test/java/**/*.java'], excludes = AUTO_VALUE_TEST_SRCS),
- deps = [
- ':client',
- '//lib:guava',
- '//lib:junit',
- '//lib:truth',
- ],
-)
-
-java_test(
- name = 'auto_value_tests',
- srcs = AUTO_VALUE_TEST_SRCS,
- deps = [
- '//lib:truth',
- '//lib/auto:auto-value',
- ],
-)
diff --git a/gerrit-elasticsearch/BUCK b/gerrit-elasticsearch/BUCK
deleted file mode 100644
index 32ebb3a..0000000
--- a/gerrit-elasticsearch/BUCK
+++ /dev/null
@@ -1,51 +0,0 @@
-java_library(
- name = 'elasticsearch',
- srcs = glob(['src/main/java/**/*.java']),
- deps = [
- '//gerrit-antlr:query_exception',
- '//gerrit-extension-api:api',
- '//gerrit-reviewdb:client',
- '//gerrit-reviewdb:server',
- '//gerrit-server:server',
- '//lib:gson',
- '//lib:guava',
- '//lib:gwtorm',
- '//lib:protobuf',
- '//lib/commons:codec',
- '//lib/commons:lang',
- '//lib/elasticsearch:elasticsearch',
- '//lib/elasticsearch:jest',
- '//lib/elasticsearch:jest-common',
- '//lib/guice:guice',
- '//lib/guice:guice-assistedinject',
- '//lib/jgit/org.eclipse.jgit:jgit',
- '//lib/joda:joda-time',
- '//lib/log:api',
- '//lib/lucene:lucene-analyzers-common',
- '//lib/lucene:lucene-core',
- ],
- visibility = ['PUBLIC'],
-)
-
-java_test(
- name = 'elasticsearch_tests',
- labels = ['elastic', 'flaky'],
- srcs = glob(['src/test/java/**/*.java']),
- deps = [
- ':elasticsearch',
- '//gerrit-extension-api:api',
- '//gerrit-reviewdb:client',
- '//gerrit-reviewdb:server',
- '//gerrit-server:server',
- '//gerrit-server:testutil',
- '//gerrit-server:query_tests',
- '//lib:gson',
- '//lib:guava',
- '//lib:junit',
- '//lib:truth',
- '//lib/elasticsearch:elasticsearch',
- '//lib/guice:guice',
- '//lib/jgit/org.eclipse.jgit:jgit',
- '//lib/jgit/org.eclipse.jgit.junit:junit',
- ],
-)
diff --git a/gerrit-extension-api/BUCK b/gerrit-extension-api/BUCK
deleted file mode 100644
index 19c1781..0000000
--- a/gerrit-extension-api/BUCK
+++ /dev/null
@@ -1,89 +0,0 @@
-include_defs('//lib/JGIT_VERSION')
-include_defs('//lib/GUAVA_VERSION')
-
-SRC = 'src/main/java/com/google/gerrit/extensions/'
-SRCS = glob([SRC + '**/*.java'])
-
-EXT_API_SRCS = glob([SRC + 'client/*.java'])
-
-gwt_module(
- name = 'client',
- srcs = EXT_API_SRCS,
- gwt_xml = SRC + 'Extensions.gwt.xml',
- visibility = ['PUBLIC'],
-)
-
-java_library(
- name = 'client-lib',
- srcs = EXT_API_SRCS,
- resources = EXT_API_SRCS + glob([SRC + 'Extensions.gwt.xml']),
- visibility = ['PUBLIC'],
-)
-
-java_binary(
- name = 'extension-api',
- deps = [':lib'],
- visibility = ['PUBLIC'],
-)
-
-java_library(
- name = 'lib',
- exported_deps = [
- ':api',
- '//lib:guava',
- '//lib/guice:guice',
- '//lib/guice:guice-assistedinject',
- '//lib/guice:guice-servlet',
- '//lib:servlet-api-3_1',
- ],
- visibility = ['PUBLIC'],
-)
-
-java_library(
- name = 'api',
- srcs = glob([SRC + '**/*.java']),
- deps = [
- '//gerrit-common:annotations',
- ],
- provided_deps = [
- '//lib:guava',
- '//lib/guice:guice',
- '//lib/guice:guice-assistedinject',
- ],
- visibility = ['PUBLIC'],
-)
-
-java_sources(
- name = 'extension-api-src',
- srcs = SRCS,
- visibility = ['PUBLIC'],
-)
-
-java_test(
- name = 'api_tests',
- srcs = glob(['src/test/java/**/*Test.java']),
- deps = [
- ':api',
- '//gerrit-test-util:test_util',
- '//lib:truth',
- '//lib/guice:guice',
- ],
-)
-
-java_doc(
- name = 'extension-api-javadoc',
- title = 'Gerrit Review Extension API Documentation',
- pkgs = ['com.google.gerrit.extensions'],
- source_jar = ':extension-api-src',
- srcs = SRCS,
- deps = [
- '//lib:guava',
- '//lib/guice:javax-inject',
- '//lib/guice:guice_library',
- '//lib/guice:guice-assistedinject',
- '//lib/jgit/org.eclipse.jgit:jgit',
- '//gerrit-common:annotations',
- ],
- visibility = ['PUBLIC'],
- external_docs = [JGIT_DOC_URL, GUAVA_DOC_URL],
-)
diff --git a/gerrit-extension-api/src/main/java/com/google/gerrit/extensions/api/changes/ChangeApi.java b/gerrit-extension-api/src/main/java/com/google/gerrit/extensions/api/changes/ChangeApi.java
index b8a20975..e9111cb 100644
--- a/gerrit-extension-api/src/main/java/com/google/gerrit/extensions/api/changes/ChangeApi.java
+++ b/gerrit-extension-api/src/main/java/com/google/gerrit/extensions/api/changes/ChangeApi.java
@@ -132,10 +132,25 @@
ChangeInfo get() throws RestApiException;
/** {@code get} with {@link ListChangesOption} set to none. */
ChangeInfo info() throws RestApiException;
- /** Retrieve change edit when exists. */
+
+ /**
+ * Retrieve change edit when exists.
+ *
+ * @deprecated Replaced by {@link ChangeApi#edit()} in combination with
+ * {@link ChangeEditApi#get()}.
+ */
+ @Deprecated
EditInfo getEdit() throws RestApiException;
/**
+ * Provides access to an API regarding the change edit of this change.
+ *
+ * @return a {@code ChangeEditApi} for the change edit of this change
+ * @throws RestApiException if the API isn't accessible
+ */
+ ChangeEditApi edit() throws RestApiException;
+
+ /**
* Set hashtags on a change
**/
void setHashtags(HashtagsInput input) throws RestApiException;
@@ -357,6 +372,11 @@
}
@Override
+ public ChangeEditApi edit() {
+ throw new NotImplementedException();
+ }
+
+ @Override
public void setHashtags(HashtagsInput input) {
throw new NotImplementedException();
}
diff --git a/gerrit-extension-api/src/main/java/com/google/gerrit/extensions/api/changes/ChangeEditApi.java b/gerrit-extension-api/src/main/java/com/google/gerrit/extensions/api/changes/ChangeEditApi.java
new file mode 100644
index 0000000..da3c1fc
--- /dev/null
+++ b/gerrit-extension-api/src/main/java/com/google/gerrit/extensions/api/changes/ChangeEditApi.java
@@ -0,0 +1,237 @@
+// Copyright (C) 2017 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.google.gerrit.extensions.api.changes;
+
+import com.google.gerrit.extensions.common.EditInfo;
+import com.google.gerrit.extensions.restapi.BinaryResult;
+import com.google.gerrit.extensions.restapi.NotImplementedException;
+import com.google.gerrit.extensions.restapi.RawInput;
+import com.google.gerrit.extensions.restapi.RestApiException;
+
+import java.util.Optional;
+
+/**
+ * An API for the change edit of a change. A change edit is similar to a patch
+ * set and will become one if it is published
+ * (by {@link #publish(PublishChangeEditInput)}). Whenever the descriptions
+ * below refer to files of a change edit, they actually refer to the files of
+ * the Git tree which is represented by the change edit. A change can have at
+ * most one change edit at each point in time.
+ */
+public interface ChangeEditApi {
+
+ /**
+ * Retrieves details regarding the change edit.
+ *
+ * @return an {@code Optional} containing details about the change edit if it
+ * exists, or {@code Optional.empty()}
+ * @throws RestApiException if the change edit couldn't be retrieved
+ */
+ Optional<EditInfo> get() throws RestApiException;
+
+ /**
+ * Creates a new change edit. It has exactly the same Git tree as the current
+ * patch set of the change.
+ *
+ * @throws RestApiException if the change edit couldn't be created or a change
+ * edit already exists
+ */
+ void create() throws RestApiException;
+
+ /**
+ * Deletes the change edit.
+ *
+ * @throws RestApiException if the change edit couldn't be deleted or a change
+ * edit wasn't present
+ */
+ void delete() throws RestApiException;
+
+ /**
+ * Rebases the change edit on top of the latest patch set of this change.
+ *
+ * @throws RestApiException if the change edit couldn't be rebased or a change
+ * edit wasn't present
+ */
+ void rebase() throws RestApiException;
+
+ /**
+ * Publishes the change edit using default settings. See
+ * {@link #publish(PublishChangeEditInput)} for more details.
+ *
+ * @throws RestApiException if the change edit couldn't be published or a
+ * change edit wasn't present
+ */
+ void publish() throws RestApiException;
+
+ /**
+ * Publishes the change edit. Publishing means that the change edit is turned
+ * into a regular patch set of the change.
+ *
+ * @param publishChangeEditInput a {@code PublishChangeEditInput} specifying
+ * the options which should be applied
+ * @throws RestApiException if the change edit couldn't be published or a
+ * change edit wasn't present
+ */
+ void publish(PublishChangeEditInput publishChangeEditInput)
+ throws RestApiException;
+
+ /**
+ * Retrieves the contents of the specified file from the change edit.
+ *
+ * @param filePath the path of the file
+ * @return an {@code Optional} containing the contents of the file as a
+ * {@code BinaryResult} if the file exists within the change edit, or
+ * {@code Optional.empty()}
+ * @throws RestApiException if the contents of the file couldn't be retrieved
+ * or a change edit wasn't present
+ */
+ Optional<BinaryResult> getFile(String filePath) throws RestApiException;
+
+ /**
+ * Renames a file of the change edit or moves the file to another directory.
+ * If the change edit doesn't exist, it will be created based on the current
+ * patch set of the change.
+ *
+ * @param oldFilePath the current file path
+ * @param newFilePath the desired file path
+ * @throws RestApiException if the file couldn't be renamed
+ */
+ void renameFile(String oldFilePath, String newFilePath)
+ throws RestApiException;
+
+ /**
+ * Restores a file of the change edit to the state in which it was before the
+ * patch set on which the change edit is based. This includes the file content
+ * as well as the existence or non-existence of the file. If the change edit
+ * doesn't exist, it will be created based on the current patch set of the
+ * change.
+ *
+ * @param filePath the path of the file
+ * @throws RestApiException if the file couldn't be restored to its previous
+ * state
+ */
+ void restoreFile(String filePath) throws RestApiException;
+
+ /**
+ * Modify the contents of the specified file of the change edit. If no content
+ * is provided, the content of the file is erased but the file isn't deleted.
+ * If the change edit doesn't exist, it will be created based on the current
+ * patch set of the change.
+ *
+ * @param filePath the path of the file which should be modified
+ * @param newContent the desired content of the file
+ * @throws RestApiException if the content of the file couldn't be modified
+ */
+ void modifyFile(String filePath, RawInput newContent) throws RestApiException;
+
+ /**
+ * Deletes the specified file from the change edit. If the change edit doesn't
+ * exist, it will be created based on the current patch set of the change.
+ *
+ * @param filePath the path fo the file which should be deleted
+ * @throws RestApiException if the file couldn't be deleted
+ */
+ void deleteFile(String filePath) throws RestApiException;
+
+ /**
+ * Retrieves the commit message of the change edit.
+ *
+ * @return the commit message of the change edit
+ * @throws RestApiException if the commit message couldn't be retrieved or a
+ * change edit wasn't present
+ */
+ String getCommitMessage() throws RestApiException;
+
+ /**
+ * Modifies the commit message of the change edit. If the change edit doesn't
+ * exist, it will be created based on the current patch set of the change.
+ *
+ * @param newCommitMessage the desired commit message
+ * @throws RestApiException if the commit message couldn't be modified
+ */
+ void modifyCommitMessage(String newCommitMessage) throws RestApiException;
+
+ /**
+ * A default implementation which allows source compatibility
+ * when adding new methods to the interface.
+ **/
+ class NotImplemented implements ChangeEditApi {
+ @Override
+ public Optional<EditInfo> get() {
+ throw new NotImplementedException();
+ }
+
+ @Override
+ public void create() {
+ throw new NotImplementedException();
+ }
+
+ @Override
+ public void delete() {
+ throw new NotImplementedException();
+ }
+
+ @Override
+ public void rebase() {
+ throw new NotImplementedException();
+ }
+
+ @Override
+ public void publish() {
+ throw new NotImplementedException();
+ }
+
+ @Override
+ public void publish(PublishChangeEditInput publishChangeEditInput) {
+ throw new NotImplementedException();
+ }
+
+ @Override
+ public Optional<BinaryResult> getFile(String filePath) {
+ throw new NotImplementedException();
+ }
+
+ @Override
+ public void renameFile(String oldFilePath, String newFilePath) {
+ throw new NotImplementedException();
+ }
+
+ @Override
+ public void restoreFile(String filePath) {
+ throw new NotImplementedException();
+ }
+
+ @Override
+ public void modifyFile(String filePath, RawInput newContent) {
+ throw new NotImplementedException();
+ }
+
+ @Override
+ public void deleteFile(String filePath) {
+ throw new NotImplementedException();
+ }
+
+ @Override
+ public String getCommitMessage() {
+ throw new NotImplementedException();
+ }
+
+ @Override
+ public void modifyCommitMessage(String newCommitMessage) {
+ throw new NotImplementedException();
+ }
+ }
+
+}
diff --git a/gerrit-gpg/BUCK b/gerrit-gpg/BUCK
deleted file mode 100644
index fe93bf8..0000000
--- a/gerrit-gpg/BUCK
+++ /dev/null
@@ -1,56 +0,0 @@
-DEPS = [
- '//gerrit-common:server',
- '//gerrit-extension-api:api',
- '//gerrit-reviewdb:server',
- '//gerrit-server:server',
- '//lib:guava',
- '//lib:gwtorm',
- '//lib/guice:guice',
- '//lib/guice:guice-assistedinject',
- '//lib/guice:guice-servlet',
- '//lib/jgit/org.eclipse.jgit:jgit',
- '//lib/log:api',
-]
-
-java_library(
- name = 'gpg',
- srcs = glob(['src/main/java/**/*.java']),
- provided_deps = DEPS + [
- '//lib/bouncycastle:bcpg',
- '//lib/bouncycastle:bcprov',
- ],
- visibility = ['PUBLIC'],
-)
-
-TESTUTIL_SRCS = glob(['src/test/**/testutil/**/*.java'])
-
-java_library(
- name = 'testutil',
- srcs = TESTUTIL_SRCS,
- deps = DEPS + [
- ':gpg',
- '//lib/bouncycastle:bcpg',
- '//lib/bouncycastle:bcprov',
- ],
- visibility = ['PUBLIC'],
-)
-
-java_test(
- name = 'gpg_tests',
- srcs = glob(
- ['src/test/java/**/*.java'],
- excludes = TESTUTIL_SRCS,
- ),
- deps = DEPS + [
- ':gpg',
- ':testutil',
- '//gerrit-cache-h2:cache-h2',
- '//gerrit-lucene:lucene',
- '//gerrit-server:testutil',
- '//lib:truth',
- '//lib/bouncycastle:bcpg',
- '//lib/bouncycastle:bcprov',
- '//lib/jgit/org.eclipse.jgit.junit:junit',
- ],
- visibility = ['//tools/eclipse:classpath'],
-)
diff --git a/gerrit-gwtdebug/BUCK b/gerrit-gwtdebug/BUCK
deleted file mode 100644
index 3670916..0000000
--- a/gerrit-gwtdebug/BUCK
+++ /dev/null
@@ -1,17 +0,0 @@
-java_library(
- name = 'gwtdebug',
- srcs = glob(['src/main/java/**/*.java']),
- deps = [
- '//gerrit-pgm:daemon',
- '//gerrit-pgm:pgm',
- '//gerrit-pgm:util',
- '//gerrit-util-cli:cli',
- '//lib/gwt:dev',
- '//lib/jetty:server',
- '//lib/jetty:servlet',
- '//lib/jetty:servlets',
- '//lib/log:api',
- '//lib/log:log4j',
- ],
- visibility = ['//tools/eclipse:classpath'],
-)
diff --git a/gerrit-gwtexpui/BUCK b/gerrit-gwtexpui/BUCK
deleted file mode 100644
index 23db13f..0000000
--- a/gerrit-gwtexpui/BUCK
+++ /dev/null
@@ -1,113 +0,0 @@
-SRC = 'src/main/java/com/google/gwtexpui/'
-
-gwt_module(
- name = 'Clippy',
- srcs = glob([SRC + 'clippy/client/*.java']),
- gwt_xml = SRC + 'clippy/Clippy.gwt.xml',
- resources = [
- SRC + 'clippy/client/clippy.css',
- SRC + 'clippy/client/clippy.swf',
- SRC + 'clippy/client/page_white_copy.png',
- SRC + 'clippy/client/CopyableLabelText.properties',
- ],
- provided_deps = ['//lib/gwt:user'],
- deps = [
- ':SafeHtml',
- ':UserAgent',
- '//lib:LICENSE-clippy',
- '//lib:LICENSE-silk_icons',
- ],
- visibility = ['PUBLIC'],
-)
-
-java_library(
- name = 'CSS',
- srcs = glob([SRC + 'css/rebind/*.java']),
- resources = [SRC + 'css/CSS.gwt.xml'],
- provided_deps = ['//lib/gwt:dev'],
- visibility = ['PUBLIC'],
-)
-
-gwt_module(
- name = 'GlobalKey',
- srcs = glob([SRC + 'globalkey/client/*.java']),
- gwt_xml = SRC + 'globalkey/GlobalKey.gwt.xml',
- resources = [
- SRC + 'globalkey/client/KeyConstants.properties',
- SRC + 'globalkey/client/key.css',
- ],
- provided_deps = ['//lib/gwt:user'],
- deps = [
- ':SafeHtml',
- ':UserAgent',
- ],
- visibility = ['PUBLIC'],
-)
-
-java_library(
- name = 'linker_server',
- srcs = glob([SRC + 'linker/server/*.java']),
- provided_deps = ['//lib:servlet-api-3_1'],
- visibility = ['PUBLIC'],
-)
-
-gwt_module(
- name = 'Progress',
- srcs = glob([SRC + 'progress/client/*.java']),
- gwt_xml = SRC + 'progress/Progress.gwt.xml',
- resources = [SRC + 'progress/client/progress.css'],
- provided_deps = ['//lib/gwt:user'],
- visibility = ['PUBLIC'],
-)
-
-gwt_module(
- name = 'SafeHtml',
- srcs = glob([SRC + 'safehtml/client/*.java']),
- gwt_xml = SRC + 'safehtml/SafeHtml.gwt.xml',
- resources = [SRC + 'safehtml/client/safehtml.css'],
- provided_deps = ['//lib/gwt:user'],
- visibility = ['PUBLIC'],
-)
-
-java_test(
- name = 'SafeHtml_tests',
- srcs = glob([
- 'src/test/java/com/google/gwtexpui/safehtml/client/**/*.java',
- ]),
- deps = [
- ':SafeHtml',
- '//lib:truth',
- '//lib/gwt:user',
- '//lib/gwt:dev',
- ],
-)
-
-gwt_module(
- name = 'UserAgent',
- srcs = glob([SRC + 'user/client/*.java']),
- gwt_xml = SRC + 'user/User.gwt.xml',
- resources = [SRC + 'user/client/tooltip.css'],
- provided_deps = ['//lib/gwt:user'],
- visibility = ['PUBLIC'],
-)
-
-java_library(
- name = 'server',
- srcs = glob([SRC + 'server/*.java']),
- provided_deps = ['//lib:servlet-api-3_1'],
- visibility = ['PUBLIC'],
-)
-
-java_library(
- name = 'client-src-lib',
- srcs = [],
- resources = glob(
- [SRC + n for n in [
- 'clippy/**/*',
- 'globalkey/**/*',
- 'safehtml/**/*',
- 'user/**/*',
- ]]
- ),
- visibility = ['PUBLIC'],
-)
diff --git a/gerrit-gwtui-common/BUCK b/gerrit-gwtui-common/BUCK
deleted file mode 100644
index 729b7e7..0000000
--- a/gerrit-gwtui-common/BUCK
+++ /dev/null
@@ -1,59 +0,0 @@
-EXPORTED_DEPS = [
- '//gerrit-common:client',
- '//gerrit-gwtexpui:Clippy',
- '//gerrit-gwtexpui:GlobalKey',
- '//gerrit-gwtexpui:Progress',
- '//gerrit-gwtexpui:SafeHtml',
- '//gerrit-gwtexpui:UserAgent',
-]
-DEPS = ['//lib/gwt:user']
-SRC = 'src/main/java/com/google/gerrit/'
-
-gwt_module(
- name = 'client',
- srcs = glob([SRC + 'client/**/*.java']),
- gwt_xml = SRC + 'GerritGwtUICommon.gwt.xml',
- resources = glob(['src/main/**/*']),
- exported_deps = EXPORTED_DEPS,
- provided_deps = DEPS,
- visibility = ['PUBLIC'],
-)
-
-java_library(
- name = 'client-lib',
- srcs = glob(['src/main/**/*.java']),
- resources = glob(['src/main/**/*']),
- exported_deps = EXPORTED_DEPS,
- provided_deps = DEPS,
- visibility = ['PUBLIC'],
-)
-
-java_library(
- name = 'client-src-lib',
- srcs = [],
- resources = glob(['src/main/**/*']),
- visibility = ['PUBLIC'],
-)
-
-java_library(
- name = 'diffy_logo',
- resources = glob(['src/main/resources/com/google/gerrit/client/diffy*.png']),
- deps = [
- '//lib:LICENSE-diffy',
- '//lib:LICENSE-CC-BY3.0-unported',
- ],
- visibility = ['PUBLIC'],
-)
-
-java_test(
- name = 'client_tests',
- srcs = glob(['src/test/java/**/*.java']),
- deps = [
- ':client',
- '//lib:junit',
- '//lib/gwt:user',
- '//lib/jgit/org.eclipse.jgit:jgit',
- ],
- vm_args = ['-Xmx512m'],
- visibility = ['//tools/eclipse:classpath'],
-)
diff --git a/gerrit-gwtui/BUCK b/gerrit-gwtui/BUCK
deleted file mode 100644
index 63d52b0..0000000
--- a/gerrit-gwtui/BUCK
+++ /dev/null
@@ -1,66 +0,0 @@
-include_defs('//gerrit-gwtui/gwt.defs')
-include_defs('//tools/gwt-constants.defs')
-
-DEPS = GWT_TRANSITIVE_DEPS + [
- '//gerrit-gwtexpui:CSS',
- '//lib:gwtjsonrpc',
- '//lib/gwt:dev',
-]
-
-gwt_genrule(MODULE, DEPS)
-gwt_genrule(MODULE, DEPS, '_r')
-
-gwt_user_agent_permutations(
- name = 'ui',
- module_name = 'gerrit_ui',
- modules = [MODULE],
- module_deps = [':ui_module'],
- deps = DEPS,
- visibility = ['//:'],
-)
-
-def gen_ui_module(name, suffix = ""):
- gwt_module(
- name = name + suffix,
- srcs = glob(['src/main/java/**/*.java']),
- gwt_xml = 'src/main/java/%s.gwt.xml' % MODULE.replace('.', '/'),
- resources = glob(['src/main/java/**/*']),
- deps = [
- ':silk_icons',
- '//gerrit-gwtui-common:diffy_logo',
- '//gerrit-gwtui-common:client',
- '//gerrit-gwtexpui:CSS',
- '//lib/codemirror:codemirror' + suffix,
- '//lib/gwt:user',
- ],
- visibility = [
- '//tools/eclipse:classpath',
- '//Documentation:licenses.txt',
- '//Documentation:js_licenses.txt',
- ],
- )
-
-gen_ui_module(name = 'ui_module')
-gen_ui_module(name = 'ui_module', suffix = '_r')
-
-java_library(
- name = 'silk_icons',
- deps = [
- '//lib:LICENSE-silk_icons',
- ],
-)
-
-java_test(
- name = 'ui_tests',
- srcs = glob(['src/test/java/**/*.java']),
- deps = [
- ':ui_module',
- '//gerrit-common:client',
- '//gerrit-extension-api:client',
- '//lib:junit',
- '//lib/gwt:dev',
- '//lib/gwt:user',
- ],
- vm_args = ['-Xmx512m'],
- visibility = ['//tools/eclipse:classpath'],
-)
diff --git a/gerrit-gwtui/gwt.defs b/gerrit-gwtui/gwt.defs
deleted file mode 100644
index 85553f2..0000000
--- a/gerrit-gwtui/gwt.defs
+++ /dev/null
@@ -1,141 +0,0 @@
-# Copyright (C) 2013 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-from multiprocessing import cpu_count
-
-BROWSERS = [
- 'chrome',
- 'firefox',
- 'gecko1_8',
- 'safari',
- 'msie', 'ie8', 'ie9', 'ie10',
- 'edge',
-]
-ALIASES = {
- 'chrome': 'safari',
- 'firefox': 'gecko1_8',
- 'msie': 'ie10',
- 'edge': 'gecko1_8',
-}
-MODULE = 'com.google.gerrit.GerritGwtUI'
-CPU_COUNT = cpu_count()
-
-def gwt_genrule(module, deps, suffix = ""):
- dbg = 'ui_dbg' + suffix
- opt = 'ui_opt' + suffix
- soyc = 'ui_soyc' + suffix
- module_dep = ':ui_module' + suffix
- args = GWT_COMPILER_ARGS_RELEASE_MODE if suffix == "_r" else GWT_COMPILER_ARGS
-
- genrule(
- name = 'ui_optdbg' + suffix,
- cmd = 'cd $TMP;' +
- 'unzip -q $(location :%s);' % dbg +
- 'mv' +
- ' gerrit_ui/gerrit_ui.nocache.js' +
- ' gerrit_ui/dbg_gerrit_ui.nocache.js;' +
- 'unzip -qo $(location :%s);' % opt +
- 'mkdir -p \$(dirname $OUT);' +
- 'zip -qr $OUT .',
- out = 'ui_optdbg' + suffix + '.zip',
- visibility = ['PUBLIC'],
- )
-
- gwt_binary(
- name = opt,
- modules = [module],
- module_deps = [module_dep],
- deps = deps + ([':' + dbg] if CPU_COUNT < 8 else []),
- local_workers = CPU_COUNT,
- strict = True,
- experimental_args = args,
- vm_args = GWT_JVM_ARGS,
- )
-
- gwt_binary(
- name = dbg,
- modules = [module],
- style = 'PRETTY',
- optimize = 0,
- module_deps = [module_dep],
- deps = deps,
- local_workers = CPU_COUNT,
- strict = True,
- experimental_args = args,
- vm_args = GWT_JVM_ARGS,
- visibility = ['PUBLIC'],
- )
-
- gwt_binary(
- name = soyc,
- modules = [module],
- module_deps = [module_dep],
- deps = deps + [':' + dbg],
- local_workers = CPU_COUNT,
- strict = True,
- experimental_args = args + ['-compileReport'],
- vm_args = GWT_JVM_ARGS,
- )
-
-def gwt_user_agent_permutations(
- name,
- module_name,
- modules,
- style = 'PRETTY',
- optimize = 0,
- draft_compile = True,
- module_deps = [],
- deps = [],
- browsers = BROWSERS,
- visibility = []):
- for ua in browsers:
- impl = ua
- if ua in ALIASES:
- impl = ALIASES[ua]
- xml = ''.join([
- "<module rename-to='%s'>" % module_name,
- "<inherits name='%s'/>" % modules[0],
- "<set-property name='user.agent' value='%s'/>" % impl,
- "<set-property name='locale' value='default'/>",
- "</module>",
- ])
- gwt = '%s_%s.gwt.xml' % (modules[0].replace('.', '/'), ua)
- gwt_name = '%s_%s' % (name, ua)
- jar = '%s.gwtxml.jar' % (gwt_name)
-
- genrule(
- name = '%s_gwtxml_gen' % gwt_name,
- cmd = 'cd $TMP;' +
- ('mkdir -p \$(dirname %s);' % gwt) +
- ('echo "%s">%s;' % (xml, gwt)) +
- 'zip -qr $OUT .',
- out = jar,
- )
- prebuilt_jar(
- name = '%s_gwtxml_lib' % gwt_name,
- binary_jar = ':%s_gwtxml_gen' % gwt_name,
- )
- gwt_binary(
- name = gwt_name,
- modules = [modules[0] + '_' + ua],
- style = style,
- optimize = optimize,
- draft_compile = draft_compile,
- module_deps = module_deps + [':%s_gwtxml_lib' % gwt_name],
- deps = deps,
- local_workers = CPU_COUNT,
- strict = True,
- experimental_args = GWT_COMPILER_ARGS,
- vm_args = GWT_JVM_ARGS,
- visibility = visibility,
- )
diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/Gerrit.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/Gerrit.java
index 43d32e2..68b8ec8 100644
--- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/Gerrit.java
+++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/Gerrit.java
@@ -138,6 +138,7 @@
private static ViewSite<Screen> body;
private static String lastChangeListToken;
private static String lastViewToken;
+ private static Anchor uiSwitcherLink;
static {
SYSTEM_SVC = GWT.create(SystemInfoService.class);
@@ -175,6 +176,7 @@
public static void display(final String token) {
if (body.getView() == null || !body.getView().displayToken(token)) {
dispatcher.display(token);
+ updateUiLink(token);
}
}
@@ -201,6 +203,7 @@
LocalComments.saveInlineComments();
}
body.setView(view);
+ updateUiLink(token);
}
}
@@ -532,6 +535,23 @@
ApiGlue.fireEvent("history", token);
}
+ private static String getUiSwitcherUrl(String token) {
+ UrlBuilder builder = new UrlBuilder();
+ builder.setProtocol(Location.getProtocol());
+ builder.setHost(Location.getHost());
+ String port = Location.getPort();
+ if (port != null && !port.isEmpty()) {
+ builder.setPort(Integer.parseInt(port));
+ }
+ String[] tokens = token.split("@", 2);
+ builder.setPath(tokens[0]);
+ if (tokens.length == 2) {
+ builder.setHash(tokens[1]);
+ }
+ builder.setParameter("polygerrit", "1");
+ return builder.buildString();
+ }
+
private static void populateBottomMenu(RootPanel btmmenu, HostPageData hpd) {
String vs = hpd.version;
if (vs == null || vs.isEmpty()) {
@@ -542,10 +562,10 @@
if (info().gerrit().webUis().contains(UiType.POLYGERRIT)) {
btmmenu.add(new InlineLabel(" | "));
- Anchor a = new Anchor(
- C.newUi(), GWT.getHostPageBaseURL() + "?polygerrit=1");
- a.setStyleName("");
- btmmenu.add(a);
+ uiSwitcherLink = new Anchor(C.newUi(),
+ getUiSwitcherUrl(History.getToken()));
+ uiSwitcherLink.setStyleName("");
+ btmmenu.add(uiSwitcherLink);
}
String reportBugUrl = info().gerrit().reportBugUrl();
@@ -563,6 +583,10 @@
btmmenu.add(new InlineLabel(C.keyHelp()));
}
+ private static void updateUiLink(String token) {
+ uiSwitcherLink.setHref(getUiSwitcherUrl(token));
+ }
+
private void onModuleLoad2(HostPageData hpd) {
RESOURCES.gwt_override().ensureInjected();
RESOURCES.css().ensureInjected();
diff --git a/gerrit-httpd/BUCK b/gerrit-httpd/BUCK
deleted file mode 100644
index 0b0499c..0000000
--- a/gerrit-httpd/BUCK
+++ /dev/null
@@ -1,78 +0,0 @@
-SRCS = glob(
- ['src/main/java/**/*.java'],
-)
-RESOURCES = glob(['src/main/resources/**/*'])
-
-java_library(
- name = 'httpd',
- srcs = SRCS,
- resources = RESOURCES,
- deps = [
- '//gerrit-antlr:query_exception',
- '//gerrit-common:annotations',
- '//gerrit-common:server',
- '//gerrit-extension-api:api',
- '//gerrit-gwtexpui:linker_server',
- '//gerrit-gwtexpui:server',
- '//gerrit-launcher:launcher',
- '//gerrit-patch-jgit:server',
- '//gerrit-prettify:server',
- '//gerrit-reviewdb:server',
- '//gerrit-server:server',
- '//gerrit-util-cli:cli',
- '//gerrit-util-http:http',
- '//lib:args4j',
- '//lib:gson',
- '//lib:guava',
- '//lib:gwtjsonrpc',
- '//lib:gwtorm',
- '//lib:jsch',
- '//lib:mime-util',
- '//lib/auto:auto-value',
- '//lib/commons:codec',
- '//lib/guice:guice',
- '//lib/guice:guice-assistedinject',
- '//lib/guice:guice-servlet',
- '//lib/jgit/org.eclipse.jgit:jgit',
- '//lib/jgit/org.eclipse.jgit.http.server:jgit-servlet',
- '//lib/log:api',
- '//lib/lucene:lucene-core-and-backward-codecs',
- ],
- provided_deps = ['//lib:servlet-api-3_1'],
- visibility = ['PUBLIC'],
-)
-
-java_sources(
- name = 'httpd-src',
- srcs = SRCS + RESOURCES,
- visibility = ['PUBLIC'],
-)
-
-java_test(
- name = 'httpd_tests',
- srcs = glob(['src/test/java/**/*.java']),
- deps = [
- ':httpd',
- '//gerrit-common:server',
- '//gerrit-extension-api:api',
- '//gerrit-reviewdb:server',
- '//gerrit-server:server',
- '//gerrit-util-http:http',
- '//gerrit-util-http:testutil',
- '//lib:jimfs',
- '//lib:junit',
- '//lib:gson',
- '//lib:gwtorm',
- '//lib:guava',
- '//lib:servlet-api-3_1',
- '//lib:truth',
- '//lib/easymock:easymock',
- '//lib/guice:guice',
- '//lib/guice:guice-servlet',
- '//lib/jgit/org.eclipse.jgit:jgit',
- '//lib/jgit/org.eclipse.jgit.junit:junit',
- '//lib/joda:joda-time',
- ],
- # TODO(sop) Remove after Buck supports Eclipse
- visibility = ['//tools/eclipse:classpath'],
-)
diff --git a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/raw/BazelBuild.java b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/raw/BazelBuild.java
index 594d209..966a2fb 100644
--- a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/raw/BazelBuild.java
+++ b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/raw/BazelBuild.java
@@ -29,8 +29,8 @@
protected ProcessBuilder newBuildProcess(Label label) throws IOException {
Properties properties = loadBuildProperties(
sourceRoot.resolve(".primary_build_tool"));
- String buck = firstNonNull(properties.getProperty("bazel"), "bazel");
- ProcessBuilder proc = new ProcessBuilder(buck, "build", label.fullName());
+ String bazel = firstNonNull(properties.getProperty("bazel"), "bazel");
+ ProcessBuilder proc = new ProcessBuilder(bazel, "build", label.fullName());
if (properties.containsKey("PATH")) {
proc.environment().put("PATH", properties.getProperty("PATH"));
}
diff --git a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/raw/BuckUtils.java b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/raw/BuckUtils.java
deleted file mode 100644
index 7d85877..0000000
--- a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/raw/BuckUtils.java
+++ /dev/null
@@ -1,79 +0,0 @@
-// Copyright (C) 2015 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.gerrit.httpd.raw;
-
-import static com.google.common.base.MoreObjects.firstNonNull;
-
-import java.io.IOException;
-import java.nio.file.Path;
-import java.util.Properties;
-
-class BuckUtils extends BuildSystem {
- BuckUtils(Path sourceRoot) {
- super(sourceRoot);
- }
-
- @Override
- protected ProcessBuilder newBuildProcess(Label label) throws IOException {
- Properties properties = loadBuildProperties(
- sourceRoot.resolve("buck-out/gen/tools/buck/buck.properties"));
- String buck = firstNonNull(properties.getProperty("buck"), "buck");
- ProcessBuilder proc = new ProcessBuilder(buck, "build", label.fullName());
- if (properties.containsKey("PATH")) {
- proc.environment().put("PATH", properties.getProperty("PATH"));
- }
- return proc;
- }
-
- @Override
- public Path targetPath(Label label) {
- return sourceRoot.resolve("buck-out")
- .resolve("gen").resolve(label.artifact);
- }
-
- @Override
- public String buildCommand(Label l) {
- return "buck build " + l.toString();
- }
-
- @Override
- public Label gwtZipLabel(String agent) {
- // TODO(davido): instead of assuming specific Buck's internal
- // target directory for gwt_binary() artifacts, ask Buck for
- // the location of user agent permutation GWT zip, e. g.:
- // $ buck targets --show_output //gerrit-gwtui:ui_safari \
- // | awk '{print $2}'
- String t = "ui_" + agent;
- return new BuildSystem.Label("gerrit-gwtui", t,
- String.format("gerrit-gwtui/__gwt_binary_%s__/%s.zip", t, t));
- }
-
- @Override
- public Label polygerritComponents() {
- return new Label("polygerrit-ui", "polygerrit_components",
- "polygerrit-ui/polygerrit_components/" +
- "polygerrit_components.bower_components.zip");
- }
-
- @Override
- public Label fontZipLabel() {
- return new Label("polygerrit-ui", "fonts", "polygerrit-ui/fonts/fonts.zip");
- }
-
- @Override
- public String name() {
- return "buck";
- }
-}
diff --git a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/raw/StaticModule.java b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/raw/StaticModule.java
index d1070fc..0571ee6 100644
--- a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/raw/StaticModule.java
+++ b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/raw/StaticModule.java
@@ -362,13 +362,11 @@
"Error initializing static content paths", e);
}
- sourceRoot = getSourseRootOrNull();
- builder = GerritLauncher.isBazel()
- ? new BazelBuild(sourceRoot)
- : new BuckUtils(sourceRoot);
+ sourceRoot = getSourceRootOrNull();
+ builder = new BazelBuild(sourceRoot);
}
- private static Path getSourseRootOrNull() {
+ private static Path getSourceRootOrNull() {
try {
return GerritLauncher.resolveInSourceRoot(".");
} catch (FileNotFoundException e) {
diff --git a/gerrit-launcher/BUCK b/gerrit-launcher/BUCK
deleted file mode 100644
index 5be25fa..0000000
--- a/gerrit-launcher/BUCK
+++ /dev/null
@@ -1,13 +0,0 @@
-# NOTE: GerritLauncher must be a single, self-contained class. Do not add any
-# additional srcs or deps to this rule.
-java_library(
- name = 'launcher',
- srcs = ['src/main/java/com/google/gerrit/launcher/GerritLauncher.java'],
- visibility = [
- '//gerrit-acceptance-framework/...',
- '//gerrit-acceptance-tests/...',
- '//gerrit-httpd:',
- '//gerrit-main:main_lib',
- '//gerrit-pgm:',
- ],
-)
diff --git a/gerrit-launcher/src/main/java/com/google/gerrit/launcher/GerritLauncher.java b/gerrit-launcher/src/main/java/com/google/gerrit/launcher/GerritLauncher.java
index a865ffa..b0eabea 100644
--- a/gerrit-launcher/src/main/java/com/google/gerrit/launcher/GerritLauncher.java
+++ b/gerrit-launcher/src/main/java/com/google/gerrit/launcher/GerritLauncher.java
@@ -627,36 +627,6 @@
}
static String SOURCE_ROOT_RESOURCE = "/gerrit-launcher/workspace-root.txt";
- static String PRIMARY_BUILD_TOOL = ".primary_build_tool";
-
- /** returns whether we're running out of a bazel build. */
- public static boolean isBazel() {
- Class<GerritLauncher> self = GerritLauncher.class;
- URL rootURL = self.getResource(SOURCE_ROOT_RESOURCE);
- if (rootURL != null) {
- return true;
- }
-
- Path p = null;
- try {
- p = resolveInSourceRoot("eclipse-out");
- if (!Files.exists(p)) {
- p = resolveInSourceRoot("bazel-out");
- }
- Path path = p.getParent().resolve(PRIMARY_BUILD_TOOL);
- if (Files.exists(path)) {
- String content = new String(Files.readAllBytes(path));
- if (content.toLowerCase().contains("bazel")) {
- return true;
- }
- }
- } catch (IOException e) {
- // Ignore
- }
-
- // Not Bazel then
- return false;
- }
/**
* Locate a path in the source tree.
@@ -710,8 +680,7 @@
// Pop up to the top-level source folder by looking for .buckconfig.
Path dir = Paths.get(u.getPath());
- while (!Files.isRegularFile(dir.resolve(".buckconfig"))
- && !Files.isRegularFile(dir.resolve("WORKSPACE"))) {
+ while (!Files.isRegularFile(dir.resolve("WORKSPACE"))) {
Path parent = dir.getParent();
if (parent == null) {
throw new FileNotFoundException("Cannot find source root from " + u);
diff --git a/gerrit-lucene/BUCK b/gerrit-lucene/BUCK
deleted file mode 100644
index 771a021..0000000
--- a/gerrit-lucene/BUCK
+++ /dev/null
@@ -1,41 +0,0 @@
-QUERY_BUILDER = [
- 'src/main/java/com/google/gerrit/lucene/QueryBuilder.java',
-]
-
-java_library(
- name = 'query_builder',
- srcs = QUERY_BUILDER,
- deps = [
- '//gerrit-antlr:query_exception',
- '//gerrit-reviewdb:server',
- '//gerrit-server:server',
- '//lib:gwtorm',
- '//lib:guava',
- '//lib/lucene:lucene-core-and-backward-codecs',
- ],
- visibility = ['PUBLIC'],
-)
-
-java_library(
- name = 'lucene',
- srcs = glob(['src/main/java/**/*.java'], excludes = QUERY_BUILDER),
- deps = [
- ':query_builder',
- '//gerrit-antlr:query_exception',
- '//gerrit-common:annotations',
- '//gerrit-common:server',
- '//gerrit-extension-api:api',
- '//gerrit-reviewdb:server',
- '//gerrit-server:server',
- '//lib:guava',
- '//lib:gwtorm',
- '//lib/guice:guice',
- '//lib/guice:guice-assistedinject',
- '//lib/jgit/org.eclipse.jgit:jgit',
- '//lib/log:api',
- '//lib/lucene:lucene-analyzers-common',
- '//lib/lucene:lucene-core-and-backward-codecs',
- '//lib/lucene:lucene-misc',
- ],
- visibility = ['PUBLIC'],
-)
diff --git a/gerrit-main/BUCK b/gerrit-main/BUCK
deleted file mode 100644
index da39eec..0000000
--- a/gerrit-main/BUCK
+++ /dev/null
@@ -1,13 +0,0 @@
-java_binary(
- name = 'main_bin',
- main_class = 'Main',
- deps = [':main_lib'],
- visibility = ['PUBLIC'],
-)
-
-java_library(
- name = 'main_lib',
- srcs = ['src/main/java/Main.java'],
- deps = ['//gerrit-launcher:launcher'],
- visibility = ['//tools/eclipse:classpath'],
-)
diff --git a/gerrit-oauth/BUCK b/gerrit-oauth/BUCK
deleted file mode 100644
index fa5a8e2..0000000
--- a/gerrit-oauth/BUCK
+++ /dev/null
@@ -1,26 +0,0 @@
-SRCS = glob(
- ['src/main/java/**/*.java'],
-)
-RESOURCES = glob(['src/main/resources/**/*'])
-
-java_library(
- name = 'oauth',
- srcs = SRCS,
- resources = RESOURCES,
- deps = [
- '//gerrit-common:annotations',
- '//gerrit-extension-api:api',
- '//gerrit-httpd:httpd',
- '//gerrit-reviewdb:server',
- '//gerrit-server:server',
- '//lib:gson',
- '//lib:guava',
- '//lib:gwtorm',
- '//lib/commons:codec',
- '//lib/guice:guice',
- '//lib/guice:guice-servlet',
- '//lib/log:api',
- ],
- provided_deps = ['//lib:servlet-api-3_1'],
- visibility = ['PUBLIC'],
-)
diff --git a/gerrit-openid/BUCK b/gerrit-openid/BUCK
deleted file mode 100644
index 5eace7b..0000000
--- a/gerrit-openid/BUCK
+++ /dev/null
@@ -1,26 +0,0 @@
-java_library(
- name = 'openid',
- srcs = glob(['src/main/java/**/*.java']),
- resources = glob(['src/main/resources/**/*']),
- deps = [
- '//lib/openid:consumer',
- ],
- provided_deps = [
- '//gerrit-common:annotations',
- '//gerrit-common:server',
- '//gerrit-extension-api:api',
- '//gerrit-gwtexpui:server',
- '//gerrit-httpd:httpd',
- '//gerrit-reviewdb:server',
- '//gerrit-server:server',
- '//lib:guava',
- '//lib:gwtorm',
- '//lib:servlet-api-3_1',
- '//lib/commons:codec',
- '//lib/guice:guice',
- '//lib/guice:guice-servlet',
- '//lib/jgit/org.eclipse.jgit:jgit',
- '//lib/log:api',
- ],
- visibility = ['PUBLIC'],
-)
diff --git a/gerrit-patch-commonsnet/BUCK b/gerrit-patch-commonsnet/BUCK
deleted file mode 100644
index 53b382f..0000000
--- a/gerrit-patch-commonsnet/BUCK
+++ /dev/null
@@ -1,11 +0,0 @@
-java_library(
- name = 'commons-net',
- srcs = glob(['src/main/java/org/apache/commons/net/**/*.java']),
- deps = [
- '//gerrit-util-ssl:ssl',
- '//lib/commons:codec',
- '//lib/commons:net',
- '//lib/log:api',
- ],
- visibility = ['PUBLIC'],
-)
diff --git a/gerrit-patch-jgit/BUCK b/gerrit-patch-jgit/BUCK
deleted file mode 100644
index 4a4929e..0000000
--- a/gerrit-patch-jgit/BUCK
+++ /dev/null
@@ -1,65 +0,0 @@
-SRC = 'src/main/java/org/eclipse/jgit/'
-
-gwt_module(
- name = 'client',
- srcs = [
- SRC + 'diff/Edit_JsonSerializer.java',
- SRC + 'diff/ReplaceEdit.java',
- ],
- gwt_xml = SRC + 'JGit.gwt.xml',
- deps = [
- '//lib:gwtjsonrpc',
- ':Edit',
- ],
- provided_deps = ['//lib/gwt:user'],
- visibility = ['PUBLIC'],
-)
-
-gwt_module(
- name = 'Edit',
- srcs = [':jgit_edit_src'],
- deps = [':edit_src'],
- visibility = ['PUBLIC'],
-)
-
-prebuilt_jar(
- name = 'edit_src',
- binary_jar = ':jgit_edit_src',
-)
-
-genrule(
- name = 'jgit_edit_src',
- cmd = 'unzip -qd $TMP $(location //lib/jgit/org.eclipse.jgit:jgit_src) ' +
- 'org/eclipse/jgit/diff/Edit.java;' +
- 'cd $TMP;' +
- 'zip -Dq $OUT org/eclipse/jgit/diff/Edit.java',
- out = 'edit-sources.jar',
-)
-
-java_library(
- name = 'server',
- srcs = [
- SRC + x for x in [
- 'diff/EditDeserializer.java',
- 'diff/ReplaceEdit.java',
- 'internal/storage/file/WindowCacheStatAccessor.java',
- 'lib/ObjectIdSerialization.java',
- ]
- ],
- deps = [
- '//lib:gson',
- '//lib/jgit/org.eclipse.jgit:jgit',
- ],
- visibility = ['PUBLIC'],
-)
-
-java_test(
- name = 'jgit_patch_tests',
- srcs = glob(['src/test/java/**/*.java']),
- deps = [
- ':server',
- '//lib/jgit/org.eclipse.jgit:jgit',
- '//lib:junit',
- ],
- visibility = ['//tools/eclipse:classpath'],
-)
diff --git a/gerrit-pgm/BUCK b/gerrit-pgm/BUCK
deleted file mode 100644
index a9c568d..0000000
--- a/gerrit-pgm/BUCK
+++ /dev/null
@@ -1,185 +0,0 @@
-SRCS = 'src/main/java/com/google/gerrit/pgm/'
-RSRCS = 'src/main/resources/com/google/gerrit/pgm/'
-
-INIT_API_SRCS = glob([SRCS + 'init/api/*.java'])
-
-BASE_JETTY_DEPS = [
- '//gerrit-common:server',
- '//gerrit-extension-api:api',
- '//gerrit-gwtexpui:linker_server',
- '//gerrit-gwtexpui:server',
- '//gerrit-httpd:httpd',
- '//gerrit-server:server',
- '//gerrit-sshd:sshd',
- '//lib:guava',
- '//lib/guice:guice',
- '//lib/guice:guice-assistedinject',
- '//lib/guice:guice-servlet',
- '//lib/jgit/org.eclipse.jgit:jgit',
- '//lib/joda:joda-time',
- '//lib/log:api',
- '//lib/log:log4j',
-]
-
-DEPS = BASE_JETTY_DEPS + [
- '//gerrit-reviewdb:server',
- '//lib/log:jsonevent-layout',
-]
-
-java_library(
- name = 'init-api',
- srcs = INIT_API_SRCS,
- deps = DEPS + ['//gerrit-common:annotations'],
- visibility = ['PUBLIC'],
-)
-
-java_sources(
- name = 'init-api-src',
- srcs = INIT_API_SRCS,
- visibility = ['PUBLIC'],
-)
-
-java_library(
- name = 'init',
- srcs = glob([SRCS + 'init/**/*.java']),
- resources = glob([RSRCS + 'init/*']),
- deps = DEPS + [
- ':init-api',
- ':util',
- '//gerrit-common:annotations',
- '//gerrit-elasticsearch:elasticsearch',
- '//gerrit-lucene:lucene',
- '//lib:args4j',
- '//lib:derby',
- '//lib:gwtjsonrpc',
- '//lib:gwtorm',
- '//lib:h2',
- '//lib/commons:validator',
- '//lib/mina:sshd',
- ],
- provided_deps = ['//gerrit-launcher:launcher'],
- visibility = [
- '//gerrit-acceptance-framework/...',
- '//gerrit-acceptance-tests/...',
- '//gerrit-war:',
- ],
-)
-
-REST_UTIL_DEPS = [
- '//gerrit-cache-h2:cache-h2',
- '//gerrit-elasticsearch:elasticsearch',
- '//gerrit-util-cli:cli',
- '//lib:args4j',
- '//lib:gwtorm',
- '//lib/commons:dbcp',
-]
-
-java_library(
- name = 'util',
- deps = DEPS + REST_UTIL_DEPS,
- exported_deps = [':util-nodep'],
- visibility = [
- '//gerrit-acceptance-tests/...',
- '//gerrit-gwtdebug:gwtdebug',
- '//gerrit-war:',
- ],
-)
-
-java_library(
- name = 'util-nodep',
- srcs = glob([SRCS + 'util/*.java']),
- provided_deps = DEPS + REST_UTIL_DEPS,
- visibility = ['//gerrit-acceptance-framework/...'],
-)
-
-JETTY_DEPS = [
- '//lib/jetty:jmx',
- '//lib/jetty:server',
- '//lib/jetty:servlet',
-]
-
-java_library(
- name = 'http',
- deps = DEPS + JETTY_DEPS,
- exported_deps = [':http-jetty'],
- visibility = ['//gerrit-war:'],
-)
-
-java_library(
- name = 'http-jetty',
- srcs = glob([SRCS + 'http/jetty/*.java']),
- provided_deps = JETTY_DEPS + BASE_JETTY_DEPS + [
- '//gerrit-launcher:launcher',
- '//gerrit-reviewdb:client',
- '//lib:servlet-api-3_1',
- ],
- visibility = ['//gerrit-acceptance-framework/...'],
-)
-
-REST_PGM_DEPS = [
- ':http',
- ':init',
- ':init-api',
- ':util',
- '//gerrit-cache-h2:cache-h2',
- '//gerrit-elasticsearch:elasticsearch',
- '//gerrit-gpg:gpg',
- '//gerrit-lucene:lucene',
- '//gerrit-oauth:oauth',
- '//gerrit-openid:openid',
- '//lib:args4j',
- '//lib:gwtorm',
- '//lib:protobuf',
- '//lib:servlet-api-3_1',
- '//lib/prolog:cafeteria',
- '//lib/prolog:compiler',
- '//lib/prolog:runtime',
-]
-
-java_library(
- name = 'pgm',
- resources = glob([RSRCS + '*']),
- deps = DEPS + REST_PGM_DEPS + [
- ':daemon',
- ],
- visibility = [
- '//:',
- '//gerrit-acceptance-tests/...',
- '//gerrit-gwtdebug:gwtdebug',
- '//tools/eclipse:classpath',
- '//Documentation:licenses.txt',
- ],
-)
-
-# no transitive deps, used for gerrit-acceptance-framework
-java_library(
- name = 'daemon',
- srcs = glob([SRCS + '*.java', SRCS + 'rules/*.java']),
- resources = glob([RSRCS + '*']),
- deps = ['//lib/auto:auto-value'],
- provided_deps = DEPS + REST_PGM_DEPS + [
- '//gerrit-launcher:launcher',
- ],
- visibility = [
- '//gerrit-acceptance-framework/...',
- '//gerrit-gwtdebug:gwtdebug',
- ],
-)
-
-java_test(
- name = 'pgm_tests',
- srcs = glob(['src/test/java/**/*.java']),
- deps = [
- ':init',
- ':init-api',
- ':pgm',
- '//gerrit-common:server',
- '//gerrit-server:server',
- '//lib:guava',
- '//lib:junit',
- '//lib/easymock:easymock',
- '//lib/guice:guice',
- '//lib/jgit/org.eclipse.jgit:jgit',
- '//lib/jgit/org.eclipse.jgit.junit:junit',
- ],
-)
diff --git a/gerrit-pgm/src/main/resources/com/google/gerrit/pgm/init/libraries.config b/gerrit-pgm/src/main/resources/com/google/gerrit/pgm/init/libraries.config
index 141706a..3a0d7e5 100644
--- a/gerrit-pgm/src/main/resources/com/google/gerrit/pgm/init/libraries.config
+++ b/gerrit-pgm/src/main/resources/com/google/gerrit/pgm/init/libraries.config
@@ -37,9 +37,9 @@
remove = bcpg-.*[.]jar
[library "mysqlDriver"]
- name = MySQL Connector/J 5.1.21
- url = https://repo1.maven.org/maven2/mysql/mysql-connector-java/5.1.21/mysql-connector-java-5.1.21.jar
- sha1 = 7abbd19fc2e2d5b92c0895af8520f7fa30266be9
+ name = MySQL Connector/J 5.1.40
+ url = https://repo1.maven.org/maven2/mysql/mysql-connector-java/5.1.40/mysql-connector-java-5.1.40.jar
+ sha1 = ef2a2ceab1735eaaae0b5d1cccf574fb7c6e1c52
remove = mysql-connector-java-.*[.]jar
[library "oracleDriver"]
diff --git a/gerrit-plugin-api/BUCK b/gerrit-plugin-api/BUCK
deleted file mode 100644
index fc17d0d..0000000
--- a/gerrit-plugin-api/BUCK
+++ /dev/null
@@ -1,99 +0,0 @@
-SRCS = [
- 'gerrit-server/src/main/java/',
- 'gerrit-httpd/src/main/java/',
- 'gerrit-sshd/src/main/java/',
-]
-
-PLUGIN_API = [
- '//gerrit-httpd:httpd',
- '//gerrit-pgm:init-api',
- '//gerrit-server:server',
- '//gerrit-sshd:sshd',
-]
-
-java_binary(
- name = 'plugin-api',
- merge_manifests = False,
- manifest_file = ':manifest',
- deps = [':lib'],
- visibility = ['PUBLIC'],
-)
-
-genrule(
- name = 'manifest',
- cmd = 'echo "Manifest-Version: 1.0" >$OUT;' +
- 'echo "Implementation-Title: Gerrit Plugin API" >>$OUT;' +
- 'echo "Implementation-Vendor: Gerrit Code Review Project" >>$OUT',
- out = 'manifest.txt',
-)
-
-java_library(
- name = 'lib',
- exported_deps = PLUGIN_API + [
- '//gerrit-antlr:query_exception',
- '//gerrit-antlr:query_parser',
- '//gerrit-common:annotations',
- '//gerrit-common:server',
- '//gerrit-extension-api:api',
- '//gerrit-gwtexpui:server',
- '//gerrit-reviewdb:server',
- '//lib:args4j',
- '//lib:blame-cache',
- '//lib:gson',
- '//lib:guava',
- '//lib:gwtorm',
- '//lib:icu4j',
- '//lib:jsch',
- '//lib:jsr305',
- '//lib:mime-util',
- '//lib:protobuf',
- '//lib:servlet-api-3_1',
- '//lib:soy',
- '//lib:velocity',
- '//lib/commons:lang',
- '//lib/dropwizard:dropwizard-core',
- '//lib/guice:guice',
- '//lib/guice:guice-assistedinject',
- '//lib/guice:javax-inject',
- '//lib/guice:multibindings',
- '//lib/guice:guice-servlet',
- "//lib/httpcomponents:httpclient",
- "//lib/httpcomponents:httpcore",
- '//lib/jgit/org.eclipse.jgit:jgit',
- '//lib/jgit/org.eclipse.jgit.http.server:jgit-servlet',
- '//lib/joda:joda-time',
- '//lib/log:api',
- '//lib/log:log4j',
- '//lib/mina:sshd',
- '//lib/ow2:ow2-asm',
- '//lib/ow2:ow2-asm-analysis',
- '//lib/ow2:ow2-asm-commons',
- '//lib/ow2:ow2-asm-util',
- '//lib/prolog:compiler',
- '//lib/prolog:runtime',
- ],
- visibility = ['PUBLIC'],
-)
-
-java_binary(
- name = 'plugin-api-src',
- deps = [
- '//gerrit-extension-api:extension-api-src',
- ] + [d + '-src' for d in PLUGIN_API],
- visibility = ['PUBLIC'],
-)
-
-java_doc(
- name = 'plugin-api-javadoc',
- title = 'Gerrit Review Plugin API Documentation',
- pkgs = ['com.google.gerrit'],
- source_jar = ':plugin-api-src',
- srcs = glob([n + '**/*.java' for n in SRCS]),
- deps = [
- ':plugin-api',
- '//lib/bouncycastle:bcprov',
- '//lib/bouncycastle:bcpg',
- '//lib/bouncycastle:bcpkix',
- ],
- visibility = ['PUBLIC'],
-)
diff --git a/gerrit-plugin-gwtui/BUCK b/gerrit-plugin-gwtui/BUCK
deleted file mode 100644
index 575ebfc..0000000
--- a/gerrit-plugin-gwtui/BUCK
+++ /dev/null
@@ -1,60 +0,0 @@
-SRCS = glob(['src/main/java/com/google/gerrit/**/*.java'])
-DEPS = ['//lib/gwt:user']
-
-java_binary(
- name = 'gwtui-api',
- deps = [
- ':gwtui-api-lib',
- '//gerrit-gwtui-common:client-lib',
- ],
- visibility = ['PUBLIC'],
-)
-
-java_library(
- name = 'gwtui-api-lib',
- srcs = SRCS,
- resources = glob(['src/main/**/*']),
- exported_deps = ['//gerrit-gwtui-common:client-lib'],
- provided_deps = DEPS + ['//lib/gwt:dev'],
- visibility = ['PUBLIC'],
-)
-
-java_binary(
- name = 'gwtui-api-src',
- deps = [
- ':gwtui-api-src-lib',
- '//gerrit-gwtexpui:client-src-lib',
- '//gerrit-gwtui-common:client-src-lib',
- ],
- visibility = ['PUBLIC'],
-)
-
-java_library(
- name = 'gwtui-api-src-lib',
- srcs = [],
- resources = glob(['src/main/**/*']),
- visibility = ['PUBLIC'],
-)
-
-java_doc(
- name = 'gwtui-api-javadoc',
- title = 'Gerrit Review GWT Extension API Documentation',
- pkgs = [
- 'com.google.gerrit',
- 'com.google.gwtexpui.clippy',
- 'com.google.gwtexpui.globalkey',
- 'com.google.gwtexpui.safehtml',
- 'com.google.gwtexpui.user',
- ],
- source_jar = ':gwtui-api-src',
- srcs = SRCS,
- deps = DEPS + [
- '//lib:gwtjsonrpc',
- '//lib:gwtorm_client',
- '//lib/gwt:dev',
- '//gerrit-gwtui-common:client-lib',
- '//gerrit-common:client',
- '//gerrit-reviewdb:client',
- ],
- visibility = ['PUBLIC'],
-)
diff --git a/gerrit-prettify/BUCK b/gerrit-prettify/BUCK
deleted file mode 100644
index bf2e02a..0000000
--- a/gerrit-prettify/BUCK
+++ /dev/null
@@ -1,47 +0,0 @@
-SRC = 'src/main/java/com/google/gerrit/prettify/'
-
-gwt_module(
- name = 'client',
- srcs = glob([
- SRC + 'common/**/*.java',
- ]),
- gwt_xml = SRC + 'PrettyFormatter.gwt.xml',
- deps = [
- '//gerrit-gwtexpui:SafeHtml',
- ],
- exported_deps = [
- '//gerrit-extension-api:client',
- '//gerrit-patch-jgit:client',
- '//gerrit-patch-jgit:Edit',
- '//gerrit-reviewdb:client',
- '//lib:gwtjsonrpc',
- '//lib:gwtjsonrpc_src',
- ],
- provided_deps = ['//lib/gwt:user'],
- visibility = ['PUBLIC'],
-)
-
-java_library(
- name = 'server',
- srcs = glob([SRC + 'common/**/*.java']),
- deps = [
- '//gerrit-patch-jgit:server',
- '//gerrit-reviewdb:server',
- '//lib:guava',
- '//lib:gwtjsonrpc',
- '//lib/jgit/org.eclipse.jgit:jgit',
- ],
- visibility = ['PUBLIC'],
-)
-
-export_file(
- name = 'prettify.min.js',
- src = 'src/main/resources/com/google/gerrit/prettify/client/prettify.js',
- visibility = ['//Documentation:'],
-)
-
-export_file(
- name = 'prettify.min.css',
- src = 'src/main/resources/com/google/gerrit/prettify/client/prettify.css',
- visibility = ['//Documentation:'],
-)
diff --git a/gerrit-reviewdb/BUCK b/gerrit-reviewdb/BUCK
deleted file mode 100644
index 532ce801..0000000
--- a/gerrit-reviewdb/BUCK
+++ /dev/null
@@ -1,38 +0,0 @@
-SRC = 'src/main/java/com/google/gerrit/reviewdb/'
-TESTS = 'src/test/java/com/google/gerrit/reviewdb/'
-
-gwt_module(
- name = 'client',
- srcs = glob([SRC + 'client/**/*.java']),
- gwt_xml = SRC + 'ReviewDB.gwt.xml',
- deps = [
- '//gerrit-extension-api:client',
- '//lib:gwtorm_client',
- '//lib:gwtorm_client_src'
- ],
- visibility = ['PUBLIC'],
-)
-
-java_library(
- name = 'server',
- srcs = glob([SRC + '**/*.java']),
- resources = glob(['src/main/resources/**/*']),
- deps = [
- '//gerrit-extension-api:api',
- '//lib:guava',
- '//lib:gwtorm',
- ],
- visibility = ['PUBLIC'],
-)
-
-java_test(
- name = 'client_tests',
- srcs = glob([TESTS + 'client/**/*.java']),
- deps = [
- ':client',
- '//gerrit-server:testutil',
- '//lib:gwtorm',
- '//lib:truth',
- ],
- visibility = ['//tools/eclipse:classpath'],
-)
diff --git a/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/client/Account.java b/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/client/Account.java
index 81d642d..39a59b9 100644
--- a/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/client/Account.java
+++ b/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/client/Account.java
@@ -77,7 +77,7 @@
protected Id() {
}
- public Id(final int id) {
+ public Id(int id) {
this.id = id;
}
@@ -92,8 +92,8 @@
}
/** Parse an Account.Id out of a string representation. */
- public static Id parse(final String str) {
- final Id r = new Id();
+ public static Id parse(String str) {
+ Id r = new Id();
r.fromString(str);
return r;
}
@@ -154,10 +154,14 @@
// DELETED: id = 6 (generalPreferences)
- /** Is this user active */
+ /** Is this user inactive? */
@Column(id = 7)
protected boolean inactive;
+ /** The user-settable status of this account (e.g. busy, OOO, available) */
+ @Column(id = 8, notNull = false)
+ protected String status;
+
/** <i>computed</i> the username selected from the identities. */
protected String userName;
@@ -190,7 +194,7 @@
}
/** Set the full name of the user ("Given-name Surname" style). */
- public void setFullName(final String name) {
+ public void setFullName(String name) {
if (name != null && !name.trim().isEmpty()) {
fullName = name.trim();
} else {
@@ -204,7 +208,7 @@
}
/** Set the email address the user prefers to be contacted through. */
- public void setPreferredEmail(final String addr) {
+ public void setPreferredEmail(String addr) {
preferredEmail = addr;
}
@@ -272,13 +276,21 @@
inactive = ! active;
}
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
/** @return the computed user name for this account */
public String getUserName() {
return userName;
}
/** Update the computed user name property. */
- public void setUserName(final String userName) {
+ public void setUserName(String userName) {
this.userName = userName;
}
diff --git a/gerrit-server/BUCK b/gerrit-server/BUCK
deleted file mode 100644
index 6fc7c4b..0000000
--- a/gerrit-server/BUCK
+++ /dev/null
@@ -1,216 +0,0 @@
-CONSTANTS_SRC = [
- 'src/main/java/com/google/gerrit/server/documentation/Constants.java',
-]
-
-SRCS = glob(
- ['src/main/java/**/*.java'],
- excludes = CONSTANTS_SRC,
-)
-RESOURCES = glob(['src/main/resources/**/*'])
-
-java_library(
- name = 'constants',
- srcs = CONSTANTS_SRC,
- visibility = ['PUBLIC'],
-)
-
-# TODO(sop) break up gerrit-server java_library(), its too big
-java_library(
- name = 'server',
- srcs = SRCS,
- resources = RESOURCES,
- deps = [
- ':constants',
- '//gerrit-antlr:query_exception',
- '//gerrit-antlr:query_parser',
- '//gerrit-common:annotations',
- '//gerrit-common:server',
- '//gerrit-extension-api:api',
- '//gerrit-patch-commonsnet:commons-net',
- '//gerrit-patch-jgit:server',
- '//gerrit-prettify:server',
- '//gerrit-reviewdb:server',
- '//gerrit-util-cli:cli',
- '//gerrit-util-ssl:ssl',
- '//lib:args4j',
- '//lib:automaton',
- '//lib:blame-cache',
- '//lib:grappa',
- '//lib:gson',
- '//lib:guava',
- '//lib:guava-retrying',
- '//lib:gwtjsonrpc',
- '//lib:gwtorm',
- '//lib:jsch',
- '//lib:juniversalchardet',
- '//lib:mime-util',
- '//lib:pegdown',
- '//lib:protobuf',
- '//lib:soy',
- '//lib:tukaani-xz',
- '//lib:velocity',
- '//lib/antlr:java_runtime',
- '//lib/auto:auto-value',
- '//lib/commons:codec',
- '//lib/commons:compress',
- '//lib/commons:dbcp',
- '//lib/commons:lang',
- '//lib/commons:net',
- '//lib/commons:validator',
- '//lib/dropwizard:dropwizard-core',
- '//lib/guice:guice',
- '//lib/guice:guice-assistedinject',
- '//lib/guice:guice-servlet',
- '//lib/jgit/org.eclipse.jgit:jgit',
- '//lib/jgit/org.eclipse.jgit.archive:jgit-archive',
- '//lib/joda:joda-time',
- '//lib/jsoup:jsoup',
- '//lib/log:api',
- '//lib/log:jsonevent-layout',
- '//lib/log:log4j',
- '//lib/lucene:lucene-analyzers-common',
- '//lib/lucene:lucene-core-and-backward-codecs',
- '//lib/lucene:lucene-queryparser',
- '//lib/mime4j:core',
- '//lib/mime4j:dom',
- '//lib/ow2:ow2-asm',
- '//lib/ow2:ow2-asm-tree',
- '//lib/ow2:ow2-asm-util',
- '//lib/prolog:runtime',
- ],
- provided_deps = [
- '//lib:servlet-api-3_1',
- ],
- visibility = ['PUBLIC'],
-)
-
-java_sources(
- name = 'server-src',
- srcs = SRCS + RESOURCES,
- visibility = ['PUBLIC'],
-)
-
-TESTUTIL_DEPS = [
- ':server',
- '//gerrit-common:server',
- '//gerrit-cache-h2:cache-h2',
- '//gerrit-elasticsearch:elasticsearch',
- '//gerrit-extension-api:api',
- '//gerrit-gpg:gpg',
- '//gerrit-lucene:lucene',
- '//gerrit-reviewdb:server',
- '//lib:gwtorm',
- '//lib:h2',
- '//lib:truth',
- '//lib/guice:guice',
- '//lib/guice:guice-servlet',
- '//lib/jgit/org.eclipse.jgit:jgit',
- '//lib/jgit/org.eclipse.jgit.junit:junit',
- '//lib/joda:joda-time',
- '//lib/log:api',
- '//lib/log:impl_log4j',
- '//lib/log:log4j',
-]
-
-TESTUTIL = glob([
- 'src/test/java/com/google/gerrit/testutil/**/*.java',
- 'src/test/java/com/google/gerrit/server/project/Util.java',
- ])
-java_library(
- name = 'testutil',
- srcs = TESTUTIL,
- deps = [
- '//lib/auto:auto-value',
- ],
- provided_deps = TESTUTIL_DEPS,
- exported_deps = [
- '//lib/easymock:easymock',
- '//lib/powermock:powermock-api-easymock',
- '//lib/powermock:powermock-api-support',
- '//lib/powermock:powermock-core',
- '//lib/powermock:powermock-module-junit4',
- '//lib/powermock:powermock-module-junit4-common',
- ],
- visibility = ['PUBLIC'],
-)
-
-PROLOG_TEST_CASE = [
- 'src/test/java/com/google/gerrit/rules/PrologTestCase.java',
-]
-PROLOG_TESTS = glob(
- ['src/test/java/com/google/gerrit/rules/**/*.java'],
- excludes = PROLOG_TEST_CASE,
-)
-
-java_library(
- name = 'prolog_test_case',
- srcs = PROLOG_TEST_CASE,
- deps = [
- ':server',
- ':testutil',
- '//gerrit-common:server',
- '//gerrit-extension-api:api',
- '//lib:guava',
- '//lib:junit',
- '//lib:truth',
- '//lib/guice:guice',
- '//lib/prolog:runtime',
- ],
-)
-
-java_test(
- name = 'prolog_tests',
- srcs = PROLOG_TESTS,
- resources = glob(['src/test/resources/com/google/gerrit/rules/**/*']),
- deps = TESTUTIL_DEPS + [
- ':prolog_test_case',
- ':testutil',
- '//gerrit-server/src/main/prolog:common',
- '//lib/prolog:runtime',
- ],
-)
-
-QUERY_TESTS = glob(
- ['src/test/java/com/google/gerrit/server/query/**/*.java'],
-)
-
-java_test(
- name = 'query_tests',
- srcs = QUERY_TESTS,
- deps = TESTUTIL_DEPS + [
- ':testutil',
- '//gerrit-antlr:query_exception',
- '//gerrit-antlr:query_parser',
- '//gerrit-common:annotations',
- '//gerrit-server/src/main/prolog:common',
- '//lib/antlr:java_runtime',
- ],
- visibility = ['PUBLIC'],
-)
-
-java_test(
- name = 'server_tests',
- labels = ['server'],
- srcs = glob(
- ['src/test/java/**/*.java'],
- excludes = TESTUTIL + PROLOG_TESTS + PROLOG_TEST_CASE + QUERY_TESTS
- ),
- resources = glob(['src/test/resources/com/google/gerrit/server/mail/*']),
- deps = TESTUTIL_DEPS + [
- ':testutil',
- '//gerrit-antlr:query_exception',
- '//gerrit-common:annotations',
- '//gerrit-patch-jgit:server',
- '//gerrit-server/src/main/prolog:common',
- '//lib:args4j',
- '//lib:grappa',
- '//lib:gson',
- '//lib:guava',
- '//lib:guava-retrying',
- '//lib:protobuf',
- '//lib/dropwizard:dropwizard-core',
- '//lib/guice:guice-assistedinject',
- '//lib/prolog:runtime',
- ],
- visibility = ['//tools/eclipse:classpath'],
-)
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/CommentsUtil.java b/gerrit-server/src/main/java/com/google/gerrit/server/CommentsUtil.java
index 0e15774..a9af7e0 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/CommentsUtil.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/CommentsUtil.java
@@ -169,6 +169,7 @@
new Comment.Key(ChangeUtil.messageUuid(), path, psId.get()),
ctx.getUser().getAccountId(), ctx.getWhen(), side, message, serverId,
unresolved);
+ c.parentUuid = parentUuid;
ctx.getUser().updateRealAccountId(c::setRealAuthor);
return c;
}
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/api/changes/ChangeApiImpl.java b/gerrit-server/src/main/java/com/google/gerrit/server/api/changes/ChangeApiImpl.java
index 6fb5bde..cf0a445 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/api/changes/ChangeApiImpl.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/api/changes/ChangeApiImpl.java
@@ -18,6 +18,7 @@
import com.google.gerrit.extensions.api.changes.AddReviewerInput;
import com.google.gerrit.extensions.api.changes.AssigneeInput;
import com.google.gerrit.extensions.api.changes.ChangeApi;
+import com.google.gerrit.extensions.api.changes.ChangeEditApi;
import com.google.gerrit.extensions.api.changes.Changes;
import com.google.gerrit.extensions.api.changes.FixInput;
import com.google.gerrit.extensions.api.changes.HashtagsInput;
@@ -40,7 +41,6 @@
import com.google.gerrit.extensions.restapi.Response;
import com.google.gerrit.extensions.restapi.RestApiException;
import com.google.gerrit.server.change.Abandon;
-import com.google.gerrit.server.change.ChangeEdits;
import com.google.gerrit.server.change.ChangeJson;
import com.google.gerrit.server.change.ChangeResource;
import com.google.gerrit.server.change.Check;
@@ -113,9 +113,9 @@
private final ListChangeComments listComments;
private final ListChangeRobotComments listChangeRobotComments;
private final ListChangeDrafts listDrafts;
+ private final ChangeEditApiImpl.Factory changeEditApi;
private final Check check;
private final Index index;
- private final ChangeEdits.Detail editDetail;
private final Move move;
@Inject
@@ -145,9 +145,9 @@
ListChangeComments listComments,
ListChangeRobotComments listChangeRobotComments,
ListChangeDrafts listDrafts,
+ ChangeEditApiImpl.Factory changeEditApi,
Check check,
Index index,
- ChangeEdits.Detail editDetail,
Move move,
@Assisted ChangeResource change) {
this.changeApi = changeApi;
@@ -176,9 +176,9 @@
this.listComments = listComments;
this.listChangeRobotComments = listChangeRobotComments;
this.listDrafts = listDrafts;
+ this.changeEditApi = changeEditApi;
this.check = check;
this.index = index;
- this.editDetail = editDetail;
this.move = move;
this.change = change;
}
@@ -409,12 +409,12 @@
@Override
public EditInfo getEdit() throws RestApiException {
- try {
- Response<EditInfo> edit = editDetail.apply(change);
- return edit.isNone() ? null : edit.value();
- } catch (IOException | OrmException e) {
- throw new RestApiException("Cannot retrieve change edit", e);
- }
+ return edit().get().orElse(null);
+ }
+
+ @Override
+ public ChangeEditApi edit() throws RestApiException {
+ return changeEditApi.create(change);
}
@Override
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/api/changes/ChangeEditApiImpl.java b/gerrit-server/src/main/java/com/google/gerrit/server/api/changes/ChangeEditApiImpl.java
new file mode 100644
index 0000000..b186767
--- /dev/null
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/api/changes/ChangeEditApiImpl.java
@@ -0,0 +1,226 @@
+// Copyright (C) 2017 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.google.gerrit.server.api.changes;
+
+import com.google.gerrit.extensions.api.changes.ChangeEditApi;
+import com.google.gerrit.extensions.api.changes.PublishChangeEditInput;
+import com.google.gerrit.extensions.common.EditInfo;
+import com.google.gerrit.extensions.restapi.AuthException;
+import com.google.gerrit.extensions.restapi.BinaryResult;
+import com.google.gerrit.extensions.restapi.IdString;
+import com.google.gerrit.extensions.restapi.RawInput;
+import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
+import com.google.gerrit.extensions.restapi.Response;
+import com.google.gerrit.extensions.restapi.RestApiException;
+import com.google.gerrit.server.change.ChangeEditResource;
+import com.google.gerrit.server.change.ChangeEdits;
+import com.google.gerrit.server.change.ChangeResource;
+import com.google.gerrit.server.change.DeleteChangeEdit;
+import com.google.gerrit.server.change.PublishChangeEdit;
+import com.google.gerrit.server.change.RebaseChangeEdit;
+import com.google.gerrit.server.git.UpdateException;
+import com.google.gwtorm.server.OrmException;
+import com.google.inject.Inject;
+import com.google.inject.assistedinject.Assisted;
+
+import java.io.IOException;
+import java.util.Optional;
+
+public class ChangeEditApiImpl implements ChangeEditApi {
+ interface Factory {
+ ChangeEditApiImpl create(ChangeResource changeResource);
+ }
+
+ private final ChangeEdits.Detail editDetail;
+ private final ChangeEdits.Post changeEditsPost;
+ private final DeleteChangeEdit deleteChangeEdit;
+ private final RebaseChangeEdit.Rebase rebaseChangeEdit;
+ private final PublishChangeEdit.Publish publishChangeEdit;
+ private final ChangeEdits.Get changeEditsGet;
+ private final ChangeEdits.Put changeEditsPut;
+ private final ChangeEdits.DeleteContent changeEditDeleteContent;
+ private final ChangeEdits.GetMessage getChangeEditCommitMessage;
+ private final ChangeEdits.EditMessage modifyChangeEditCommitMessage;
+ private final ChangeEdits changeEdits;
+ private final ChangeResource changeResource;
+
+ @Inject
+ public ChangeEditApiImpl(ChangeEdits.Detail editDetail,
+ ChangeEdits.Post changeEditsPost,
+ DeleteChangeEdit deleteChangeEdit,
+ RebaseChangeEdit.Rebase rebaseChangeEdit,
+ PublishChangeEdit.Publish publishChangeEdit,
+ ChangeEdits.Get changeEditsGet,
+ ChangeEdits.Put changeEditsPut,
+ ChangeEdits.DeleteContent changeEditDeleteContent,
+ ChangeEdits.GetMessage getChangeEditCommitMessage,
+ ChangeEdits.EditMessage modifyChangeEditCommitMessage,
+ ChangeEdits changeEdits,
+ @Assisted ChangeResource changeResource) {
+ this.editDetail = editDetail;
+ this.changeEditsPost = changeEditsPost;
+ this.deleteChangeEdit = deleteChangeEdit;
+ this.rebaseChangeEdit = rebaseChangeEdit;
+ this.publishChangeEdit = publishChangeEdit;
+ this.changeEditsGet = changeEditsGet;
+ this.changeEditsPut = changeEditsPut;
+ this.changeEditDeleteContent = changeEditDeleteContent;
+ this.getChangeEditCommitMessage = getChangeEditCommitMessage;
+ this.modifyChangeEditCommitMessage = modifyChangeEditCommitMessage;
+ this.changeEdits = changeEdits;
+ this.changeResource = changeResource;
+ }
+
+ @Override
+ public Optional<EditInfo> get() throws RestApiException {
+ try {
+ Response<EditInfo> edit = editDetail.apply(changeResource);
+ return edit.isNone() ? Optional.empty() : Optional.of(edit.value());
+ } catch (IOException | OrmException e) {
+ throw new RestApiException("Cannot retrieve change edit", e);
+ }
+ }
+
+ @Override
+ public void create() throws RestApiException {
+ try {
+ changeEditsPost.apply(changeResource, null);
+ } catch (IOException | OrmException e) {
+ throw new RestApiException("Cannot create change edit", e);
+ }
+ }
+
+ @Override
+ public void delete() throws RestApiException {
+ try {
+ deleteChangeEdit.apply(changeResource, new DeleteChangeEdit.Input());
+ } catch (IOException | OrmException e) {
+ throw new RestApiException("Cannot delete change edit", e);
+ }
+ }
+
+ @Override
+ public void rebase() throws RestApiException {
+ try {
+ rebaseChangeEdit.apply(changeResource, null);
+ } catch (IOException | OrmException e) {
+ throw new RestApiException("Cannot rebase change edit", e);
+ }
+ }
+
+ @Override
+ public void publish() throws RestApiException {
+ publish(null);
+ }
+
+ @Override
+ public void publish(PublishChangeEditInput publishChangeEditInput)
+ throws RestApiException {
+ try {
+ publishChangeEdit.apply(changeResource, publishChangeEditInput);
+ } catch (IOException | OrmException | UpdateException e) {
+ throw new RestApiException("Cannot publish change edit", e);
+ }
+ }
+
+ @Override
+ public Optional<BinaryResult> getFile(String filePath)
+ throws RestApiException {
+ try {
+ ChangeEditResource changeEditResource = getChangeEditResource(filePath);
+ Response<BinaryResult> fileResponse =
+ changeEditsGet.apply(changeEditResource);
+ return fileResponse.isNone()
+ ? Optional.empty()
+ : Optional.of(fileResponse.value());
+ } catch (IOException | OrmException e) {
+ throw new RestApiException("Cannot retrieve file of change edit", e);
+ }
+ }
+
+ @Override
+ public void renameFile(String oldFilePath, String newFilePath)
+ throws RestApiException {
+ try {
+ ChangeEdits.Post.Input renameInput = new ChangeEdits.Post.Input();
+ renameInput.oldPath = oldFilePath;
+ renameInput.newPath = newFilePath;
+ changeEditsPost.apply(changeResource, renameInput);
+ } catch (IOException | OrmException e) {
+ throw new RestApiException("Cannot rename file of change edit", e);
+ }
+ }
+
+ @Override
+ public void restoreFile(String filePath) throws RestApiException {
+ try {
+ ChangeEdits.Post.Input restoreInput = new ChangeEdits.Post.Input();
+ restoreInput.restorePath = filePath;
+ changeEditsPost.apply(changeResource, restoreInput);
+ } catch (IOException | OrmException e) {
+ throw new RestApiException("Cannot restore file of change edit", e);
+ }
+ }
+
+ @Override
+ public void modifyFile(String filePath, RawInput newContent)
+ throws RestApiException {
+ try {
+ changeEditsPut.apply(changeResource.getControl(), filePath, newContent);
+ } catch (IOException | OrmException e) {
+ throw new RestApiException("Cannot modify file of change edit", e);
+ }
+ }
+
+ @Override
+ public void deleteFile(String filePath) throws RestApiException {
+ try {
+ changeEditDeleteContent.apply(changeResource.getControl(), filePath);
+ } catch (IOException | OrmException e) {
+ throw new RestApiException("Cannot delete file of change edit", e);
+ }
+ }
+
+ @Override
+ public String getCommitMessage() throws RestApiException {
+ try {
+ try (BinaryResult binaryResult =
+ getChangeEditCommitMessage.apply(changeResource)) {
+ return binaryResult.asString();
+ }
+ } catch (IOException | OrmException e) {
+ throw new RestApiException("Cannot get commit message of change edit", e);
+ }
+ }
+
+ @Override
+ public void modifyCommitMessage(String newCommitMessage)
+ throws RestApiException {
+ ChangeEdits.EditMessage.Input input = new ChangeEdits.EditMessage.Input();
+ input.message = newCommitMessage;
+ try {
+ modifyChangeEditCommitMessage.apply(changeResource, input);
+ } catch (IOException | OrmException e) {
+ throw new RestApiException("Cannot modify commit message of change edit",
+ e);
+ }
+ }
+
+ private ChangeEditResource getChangeEditResource(String filePath)
+ throws ResourceNotFoundException, AuthException, IOException,
+ OrmException {
+ return changeEdits.parse(changeResource, IdString.fromDecoded(filePath));
+ }
+}
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/api/changes/Module.java b/gerrit-server/src/main/java/com/google/gerrit/server/api/changes/Module.java
index 0e3fbcb..e91d64a 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/api/changes/Module.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/api/changes/Module.java
@@ -30,5 +30,6 @@
factory(FileApiImpl.Factory.class);
factory(ReviewerApiImpl.Factory.class);
factory(RevisionReviewerApiImpl.Factory.class);
+ factory(ChangeEditApiImpl.Factory.class);
}
}
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/change/ChangeEditResource.java b/gerrit-server/src/main/java/com/google/gerrit/server/change/ChangeEditResource.java
index c57f5a0..9deb864 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/change/ChangeEditResource.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/change/ChangeEditResource.java
@@ -17,7 +17,6 @@
import com.google.gerrit.extensions.restapi.RestResource;
import com.google.gerrit.extensions.restapi.RestView;
import com.google.gerrit.reviewdb.client.Account;
-import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.edit.ChangeEdit;
import com.google.gerrit.server.project.ChangeControl;
@@ -60,10 +59,6 @@
return getChangeResource().getControl();
}
- public Change getChange() {
- return edit.getChange();
- }
-
public ChangeEdit getChangeEdit() {
return edit;
}
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/change/ChangeEdits.java b/gerrit-server/src/main/java/com/google/gerrit/server/change/ChangeEdits.java
index 330ff7b..640d785 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/change/ChangeEdits.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/change/ChangeEdits.java
@@ -38,8 +38,7 @@
import com.google.gerrit.extensions.restapi.RestView;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.PatchSet;
-import com.google.gerrit.reviewdb.server.ReviewDb;
-import com.google.gerrit.server.PatchSetUtil;
+import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.WebLinks;
import com.google.gerrit.server.edit.ChangeEdit;
import com.google.gerrit.server.edit.ChangeEditJson;
@@ -48,6 +47,7 @@
import com.google.gerrit.server.edit.UnchangedCommitMessageException;
import com.google.gerrit.server.git.GitRepositoryManager;
import com.google.gerrit.server.patch.PatchListNotAvailableException;
+import com.google.gerrit.server.project.ChangeControl;
import com.google.gerrit.server.project.InvalidChangeOperationException;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
@@ -106,7 +106,7 @@
@Override
public ChangeEditResource parse(ChangeResource rsrc, IdString id)
throws ResourceNotFoundException, AuthException, IOException,
- InvalidChangeOperationException, OrmException {
+ OrmException {
Optional<ChangeEdit> edit = editUtil.byChange(rsrc.getChange());
if (!edit.isPresent()) {
throw new ResourceNotFoundException(id);
@@ -118,7 +118,7 @@
@Override
public Create create(ChangeResource parent, IdString id)
throws RestApiException {
- return createFactory.create(parent.getChange(), id.get());
+ return createFactory.create(id.get());
}
@@ -148,58 +148,51 @@
RestModifyView<ChangeResource, Put.Input> {
interface Factory {
- Create create(Change change, String path);
+ Create create(String path);
}
- private final Provider<ReviewDb> db;
- private final ChangeEditUtil editUtil;
private final ChangeEditModifier editModifier;
- private final PatchSetUtil psUtil;
+ private final GitRepositoryManager repositoryManager;
private final Put putEdit;
- private final Change change;
private final String path;
@Inject
- Create(Provider<ReviewDb> db,
- ChangeEditUtil editUtil,
- ChangeEditModifier editModifier,
- PatchSetUtil psUtil,
+ Create(ChangeEditModifier editModifier,
+ GitRepositoryManager repositoryManager,
Put putEdit,
- @Assisted Change change,
@Assisted @Nullable String path) {
- this.db = db;
- this.editUtil = editUtil;
this.editModifier = editModifier;
- this.psUtil = psUtil;
+ this.repositoryManager = repositoryManager;
this.putEdit = putEdit;
- this.change = change;
this.path = path;
}
@Override
public Response<?> apply(ChangeResource resource, Put.Input input)
- throws AuthException, IOException, ResourceConflictException,
- OrmException, InvalidChangeOperationException {
- Optional<ChangeEdit> edit = editUtil.byChange(change);
- if (edit.isPresent()) {
- throw new ResourceConflictException(String.format(
- "edit already exists for the change %s",
- resource.getId()));
- }
- edit = createEdit(resource);
- if (!Strings.isNullOrEmpty(path)) {
- putEdit.apply(new ChangeEditResource(resource, edit.get(), path),
- input);
+ throws AuthException, ResourceConflictException, IOException,
+ OrmException {
+
+ if (Strings.isNullOrEmpty(path)) {
+ // TODO(aliceks): Consider the following:
+ // Generating an edit with a put (instead of a post) isn't mentioned in
+ // the documentation of the REST API. We should consider whether we want
+ // to keep this hidden 'feature', make it public via the documentation,
+ // or remove it.
+ createEdit(resource);
+ } else {
+ putEdit.apply(resource.getControl(), path, input.content);
}
return Response.none();
}
- private Optional<ChangeEdit> createEdit(ChangeResource resource)
- throws AuthException, IOException, ResourceConflictException,
- OrmException {
- editModifier.createEdit(change,
- psUtil.current(db.get(), resource.getNotes()));
- return editUtil.byChange(change);
+ private void createEdit(ChangeResource resource) throws AuthException,
+ IOException, OrmException, ResourceConflictException {
+ Project.NameKey project = resource.getProject();
+ try (Repository repository = repositoryManager.openRepository(project)) {
+ editModifier.createEdit(repository, resource.getControl());
+ } catch (InvalidChangeOperationException e) {
+ throw new ResourceConflictException(e.getMessage());
+ }
}
}
@@ -214,20 +207,17 @@
private final ChangeEditUtil editUtil;
private final ChangeEditModifier editModifier;
- private final PatchSetUtil psUtil;
- private final Provider<ReviewDb> db;
+ private final GitRepositoryManager repoManager;
private final String path;
@Inject
DeleteFile(ChangeEditUtil editUtil,
ChangeEditModifier editModifier,
- PatchSetUtil psUtil,
- Provider<ReviewDb> db,
+ GitRepositoryManager repoManager,
@Assisted String path) {
this.editUtil = editUtil;
this.editModifier = editModifier;
- this.psUtil = psUtil;
- this.db = db;
+ this.repoManager = repoManager;
this.path = path;
}
@@ -235,6 +225,10 @@
public Response<?> apply(ChangeResource rsrc, DeleteFile.Input in)
throws IOException, AuthException, ResourceConflictException,
OrmException, InvalidChangeOperationException, BadRequestException {
+ // TODO(aliceks): Consider the following:
+ // This check is strange. If there was already a change edit, this method
+ // wouldn't be called because DeleteContent would take over. We should
+ // consider to remove the positive case.
Optional<ChangeEdit> edit = editUtil.byChange(rsrc.getChange());
if (edit.isPresent()) {
// Edit is wiped out
@@ -244,10 +238,10 @@
// Even if the latest patch set changed since the user triggered
// the operation, deleting the whole file is probably still what
// they intended.
- editModifier.createEdit(rsrc.getChange(),
- psUtil.current(db.get(), rsrc.getNotes()));
- edit = editUtil.byChange(rsrc.getChange());
- editModifier.deleteFile(edit.get(), path);
+ Project.NameKey project = rsrc.getProject();
+ try (Repository repository = repoManager.openRepository(project)) {
+ editModifier.deleteFile(repository, rsrc.getControl(), path);
+ }
}
return Response.none();
}
@@ -329,48 +323,46 @@
public String newPath;
}
- private final Provider<ReviewDb> db;
- private final ChangeEditUtil editUtil;
private final ChangeEditModifier editModifier;
- private final PatchSetUtil psUtil;
+ private final GitRepositoryManager repositoryManager;
@Inject
- Post(Provider<ReviewDb> db,
- ChangeEditUtil editUtil,
- ChangeEditModifier editModifier,
- PatchSetUtil psUtil) {
- this.db = db;
- this.editUtil = editUtil;
+ Post(ChangeEditModifier editModifier,
+ GitRepositoryManager repositoryManager) {
this.editModifier = editModifier;
- this.psUtil = psUtil;
+ this.repositoryManager = repositoryManager;
}
@Override
public Response<?> apply(ChangeResource resource, Post.Input input)
- throws AuthException, InvalidChangeOperationException, IOException,
- ResourceConflictException, OrmException {
- Optional<ChangeEdit> edit = editUtil.byChange(resource.getChange());
- if (!edit.isPresent()) {
- edit = createEdit(resource);
- }
-
- if (input != null) {
- if (!Strings.isNullOrEmpty(input.restorePath)) {
- editModifier.restoreFile(edit.get(), input.restorePath);
- } else if (!Strings.isNullOrEmpty(input.oldPath)
- && !Strings.isNullOrEmpty(input.newPath)) {
- editModifier.renameFile(edit.get(), input.oldPath, input.newPath);
+ throws AuthException, IOException, ResourceConflictException,
+ OrmException {
+ Project.NameKey project = resource.getProject();
+ try (Repository repository = repositoryManager.openRepository(project)) {
+ ChangeControl changeControl = resource.getControl();
+ if (isRestoreFile(input)) {
+ editModifier.restoreFile(repository, changeControl,
+ input.restorePath);
+ } else if (isRenameFile(input)) {
+ editModifier.renameFile(repository, changeControl, input.oldPath,
+ input.newPath);
+ } else {
+ editModifier.createEdit(repository, changeControl);
}
+ } catch (InvalidChangeOperationException e) {
+ throw new ResourceConflictException(e.getMessage());
}
return Response.none();
}
- private Optional<ChangeEdit> createEdit(ChangeResource resource)
- throws AuthException, IOException, ResourceConflictException,
- OrmException {
- editModifier.createEdit(resource.getChange(),
- psUtil.current(db.get(), resource.getNotes()));
- return editUtil.byChange(resource.getChange());
+ private static boolean isRestoreFile(Input input) {
+ return input != null && !Strings.isNullOrEmpty(input.restorePath);
+ }
+
+ private static boolean isRenameFile(Input input) {
+ return input != null
+ && !Strings.isNullOrEmpty(input.oldPath)
+ && !Strings.isNullOrEmpty(input.newPath);
}
}
@@ -387,26 +379,33 @@
}
private final ChangeEditModifier editModifier;
+ private final GitRepositoryManager repositoryManager;
@Inject
- Put(ChangeEditModifier editModifier) {
+ Put(ChangeEditModifier editModifier,
+ GitRepositoryManager repositoryManager) {
this.editModifier = editModifier;
+ this.repositoryManager = repositoryManager;
}
@Override
public Response<?> apply(ChangeEditResource rsrc, Input input)
- throws AuthException, ResourceConflictException {
- String path = rsrc.getPath();
+ throws AuthException, ResourceConflictException, IOException,
+ OrmException {
+ return apply(rsrc.getControl(), rsrc.getPath(), input.content);
+ }
+
+ public Response<?> apply(ChangeControl changeControl, String path,
+ RawInput newContent) throws ResourceConflictException, AuthException,
+ IOException, OrmException {
if (Strings.isNullOrEmpty(path) || path.charAt(0) == '/') {
throw new ResourceConflictException("Invalid path: " + path);
}
- try {
- editModifier.modifyFile(
- rsrc.getChangeEdit(),
- rsrc.getPath(),
- input.content);
- } catch (InvalidChangeOperationException | IOException e) {
+ Project.NameKey project = changeControl.getChange().getProject();
+ try (Repository repository = repositoryManager.openRepository(project)) {
+ editModifier.modifyFile(repository, changeControl, path, newContent);
+ } catch (InvalidChangeOperationException e) {
throw new ResourceConflictException(e.getMessage());
}
return Response.none();
@@ -426,18 +425,29 @@
}
private final ChangeEditModifier editModifier;
+ private final GitRepositoryManager repositoryManager;
@Inject
- DeleteContent(ChangeEditModifier editModifier) {
+ DeleteContent(ChangeEditModifier editModifier,
+ GitRepositoryManager repositoryManager) {
this.editModifier = editModifier;
+ this.repositoryManager = repositoryManager;
}
@Override
public Response<?> apply(ChangeEditResource rsrc, DeleteContent.Input input)
- throws AuthException, ResourceConflictException {
- try {
- editModifier.deleteFile(rsrc.getChangeEdit(), rsrc.getPath());
- } catch (InvalidChangeOperationException | IOException e) {
+ throws AuthException, ResourceConflictException, OrmException,
+ IOException {
+ return apply(rsrc.getControl(), rsrc.getPath());
+ }
+
+ public Response<?> apply(ChangeControl changeControl, String filePath)
+ throws AuthException, IOException, OrmException,
+ ResourceConflictException {
+ Project.NameKey project = changeControl.getChange().getProject();
+ try (Repository repository = repositoryManager.openRepository(project)) {
+ editModifier.deleteFile(repository, changeControl, filePath);
+ } catch (InvalidChangeOperationException e) {
throw new ResourceConflictException(e.getMessage());
}
return Response.none();
@@ -458,7 +468,7 @@
}
@Override
- public Response<?> apply(ChangeEditResource rsrc)
+ public Response<BinaryResult> apply(ChangeEditResource rsrc)
throws IOException {
try {
ChangeEdit edit = rsrc.getChangeEdit();
@@ -515,41 +525,30 @@
public String message;
}
- private final Provider<ReviewDb> db;
private final ChangeEditModifier editModifier;
- private final ChangeEditUtil editUtil;
- private final PatchSetUtil psUtil;
+ private final GitRepositoryManager repositoryManager;
@Inject
- EditMessage(Provider<ReviewDb> db,
- ChangeEditModifier editModifier,
- ChangeEditUtil editUtil,
- PatchSetUtil psUtil) {
- this.db = db;
+ EditMessage(ChangeEditModifier editModifier,
+ GitRepositoryManager repositoryManager) {
this.editModifier = editModifier;
- this.editUtil = editUtil;
- this.psUtil = psUtil;
+ this.repositoryManager = repositoryManager;
}
@Override
public Object apply(ChangeResource rsrc, Input input) throws AuthException,
- IOException, InvalidChangeOperationException, BadRequestException,
- ResourceConflictException, OrmException {
- Optional<ChangeEdit> edit = editUtil.byChange(rsrc.getChange());
- if (!edit.isPresent()) {
- editModifier.createEdit(rsrc.getChange(),
- psUtil.current(db.get(), rsrc.getNotes()));
- edit = editUtil.byChange(rsrc.getChange());
- }
-
+ IOException, BadRequestException, ResourceConflictException,
+ OrmException {
if (input == null || Strings.isNullOrEmpty(input.message)) {
throw new BadRequestException("commit message must be provided");
}
- try {
- editModifier.modifyMessage(edit.get(), input.message);
- } catch (UnchangedCommitMessageException ucm) {
- throw new ResourceConflictException(ucm.getMessage());
+ Project.NameKey project = rsrc.getProject();
+ try (Repository repository = repositoryManager.openRepository(project)) {
+ ChangeControl changeControl = rsrc.getControl();
+ editModifier.modifyMessage(repository, changeControl, input.message);
+ } catch (UnchangedCommitMessageException e) {
+ throw new ResourceConflictException(e.getMessage());
}
return Response.none();
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/change/RebaseChangeEdit.java b/gerrit-server/src/main/java/com/google/gerrit/server/change/RebaseChangeEdit.java
index ac1b770..db125eb 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/change/RebaseChangeEdit.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/change/RebaseChangeEdit.java
@@ -25,20 +25,17 @@
import com.google.gerrit.extensions.restapi.RestApiException;
import com.google.gerrit.extensions.restapi.RestModifyView;
import com.google.gerrit.extensions.restapi.RestView;
-import com.google.gerrit.reviewdb.client.PatchSet;
-import com.google.gerrit.reviewdb.server.ReviewDb;
-import com.google.gerrit.server.PatchSetUtil;
-import com.google.gerrit.server.edit.ChangeEdit;
+import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.edit.ChangeEditModifier;
-import com.google.gerrit.server.edit.ChangeEditUtil;
+import com.google.gerrit.server.git.GitRepositoryManager;
import com.google.gerrit.server.project.InvalidChangeOperationException;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
-import com.google.inject.Provider;
import com.google.inject.Singleton;
+import org.eclipse.jgit.lib.Repository;
+
import java.io.IOException;
-import java.util.Optional;
@Singleton
public class RebaseChangeEdit implements
@@ -78,41 +75,26 @@
public static class Input {
}
+ private final GitRepositoryManager repositoryManager;
private final ChangeEditModifier editModifier;
- private final ChangeEditUtil editUtil;
- private final PatchSetUtil psUtil;
- private final Provider<ReviewDb> db;
@Inject
- Rebase(ChangeEditModifier editModifier,
- ChangeEditUtil editUtil,
- PatchSetUtil psUtil,
- Provider<ReviewDb> db) {
+ Rebase(GitRepositoryManager repositoryManager,
+ ChangeEditModifier editModifier) {
+ this.repositoryManager = repositoryManager;
this.editModifier = editModifier;
- this.editUtil = editUtil;
- this.psUtil = psUtil;
- this.db = db;
}
@Override
public Response<?> apply(ChangeResource rsrc, Rebase.Input in)
throws AuthException, ResourceConflictException, IOException,
- InvalidChangeOperationException, OrmException {
- Optional<ChangeEdit> edit = editUtil.byChange(rsrc.getChange());
- if (!edit.isPresent()) {
- throw new ResourceConflictException(String.format(
- "no edit exists for change %s",
- rsrc.getChange().getChangeId()));
+ OrmException {
+ Project.NameKey project = rsrc.getProject();
+ try (Repository repository = repositoryManager.openRepository(project)) {
+ editModifier.rebaseEdit(repository, rsrc.getControl());
+ } catch (InvalidChangeOperationException e) {
+ throw new ResourceConflictException(e.getMessage());
}
-
- PatchSet current = psUtil.current(db.get(), rsrc.getNotes());
- if (current.getId().equals(edit.get().getBasePatchSet().getId())) {
- throw new ResourceConflictException(String.format(
- "edit for change %s is already on latest patch set: %s",
- rsrc.getChange().getChangeId(),
- current.getId()));
- }
- editModifier.rebaseEdit(edit.get(), current);
return Response.none();
}
}
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/config/GerritGlobalModule.java b/gerrit-server/src/main/java/com/google/gerrit/server/config/GerritGlobalModule.java
index 6012142..39f5144 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/config/GerritGlobalModule.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/config/GerritGlobalModule.java
@@ -126,10 +126,10 @@
import com.google.gerrit.server.git.validators.MergeValidationListener;
import com.google.gerrit.server.git.validators.MergeValidators;
import com.google.gerrit.server.git.validators.MergeValidators.ProjectConfigValidator;
-import com.google.gerrit.server.git.validators.RefOperationValidationListener;
-import com.google.gerrit.server.git.validators.RefOperationValidators;
import com.google.gerrit.server.git.validators.OnSubmitValidationListener;
import com.google.gerrit.server.git.validators.OnSubmitValidators;
+import com.google.gerrit.server.git.validators.RefOperationValidationListener;
+import com.google.gerrit.server.git.validators.RefOperationValidators;
import com.google.gerrit.server.git.validators.UploadValidationListener;
import com.google.gerrit.server.git.validators.UploadValidators;
import com.google.gerrit.server.group.GroupInfoCache;
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/edit/ChangeEditModifier.java b/gerrit-server/src/main/java/com/google/gerrit/server/edit/ChangeEditModifier.java
index 45128bd..e7e093a 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/edit/ChangeEditModifier.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/edit/ChangeEditModifier.java
@@ -14,67 +14,54 @@
package com.google.gerrit.server.edit;
-import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
-import static org.eclipse.jgit.lib.Constants.OBJ_BLOB;
import com.google.common.base.Strings;
-import com.google.common.io.ByteStreams;
-import com.google.gerrit.common.Nullable;
import com.google.gerrit.common.TimeUtil;
import com.google.gerrit.extensions.restapi.AuthException;
+import com.google.gerrit.extensions.restapi.MergeConflictException;
import com.google.gerrit.extensions.restapi.RawInput;
-import com.google.gerrit.extensions.restapi.ResourceConflictException;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.PatchSet;
-import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.client.RefNames;
import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.GerritPersonIdent;
import com.google.gerrit.server.IdentifiedUser;
-import com.google.gerrit.server.git.GitRepositoryManager;
+import com.google.gerrit.server.PatchSetUtil;
+import com.google.gerrit.server.edit.tree.ChangeFileContentModification;
+import com.google.gerrit.server.edit.tree.DeleteFileModification;
+import com.google.gerrit.server.edit.tree.RenameFileModification;
+import com.google.gerrit.server.edit.tree.RestoreFileModification;
+import com.google.gerrit.server.edit.tree.TreeCreator;
+import com.google.gerrit.server.edit.tree.TreeModification;
import com.google.gerrit.server.index.change.ChangeIndexer;
import com.google.gerrit.server.project.ChangeControl;
import com.google.gerrit.server.project.InvalidChangeOperationException;
-import com.google.gerrit.server.project.NoSuchChangeException;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;
-import org.eclipse.jgit.dircache.DirCache;
-import org.eclipse.jgit.dircache.DirCacheBuilder;
-import org.eclipse.jgit.dircache.DirCacheEditor;
-import org.eclipse.jgit.dircache.DirCacheEditor.DeletePath;
-import org.eclipse.jgit.dircache.DirCacheEditor.PathEdit;
-import org.eclipse.jgit.dircache.DirCacheEntry;
-import org.eclipse.jgit.errors.InvalidObjectIdException;
import org.eclipse.jgit.lib.BatchRefUpdate;
import org.eclipse.jgit.lib.CommitBuilder;
-import org.eclipse.jgit.lib.FileMode;
import org.eclipse.jgit.lib.NullProgressMonitor;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.ObjectInserter;
-import org.eclipse.jgit.lib.ObjectReader;
import org.eclipse.jgit.lib.PersonIdent;
-import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.RefUpdate;
-import org.eclipse.jgit.lib.RefUpdate.Result;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.merge.MergeStrategy;
import org.eclipse.jgit.merge.ThreeWayMerger;
import org.eclipse.jgit.revwalk.RevCommit;
+import org.eclipse.jgit.revwalk.RevTree;
import org.eclipse.jgit.revwalk.RevWalk;
import org.eclipse.jgit.transport.ReceiveCommand;
-import org.eclipse.jgit.treewalk.TreeWalk;
import java.io.IOException;
-import java.io.InputStream;
import java.sql.Timestamp;
-import java.util.Map;
+import java.util.Optional;
import java.util.TimeZone;
-import java.util.concurrent.atomic.AtomicReference;
/**
* Utility functions to manipulate change edits.
@@ -87,454 +74,455 @@
@Singleton
public class ChangeEditModifier {
- private enum TreeOperation {
- CHANGE_ENTRY,
- DELETE_ENTRY,
- RENAME_ENTRY,
- RESTORE_ENTRY
- }
private final TimeZone tz;
- private final GitRepositoryManager gitManager;
private final ChangeIndexer indexer;
private final Provider<ReviewDb> reviewDb;
private final Provider<CurrentUser> currentUser;
- private final ChangeControl.GenericFactory changeControlFactory;
+ private final ChangeEditUtil changeEditUtil;
+ private final PatchSetUtil patchSetUtil;
@Inject
ChangeEditModifier(@GerritPersonIdent PersonIdent gerritIdent,
- GitRepositoryManager gitManager,
ChangeIndexer indexer,
Provider<ReviewDb> reviewDb,
Provider<CurrentUser> currentUser,
- ChangeControl.GenericFactory changeControlFactory) {
- this.gitManager = gitManager;
+ ChangeEditUtil changeEditUtil,
+ PatchSetUtil patchSetUtil) {
this.indexer = indexer;
this.reviewDb = reviewDb;
this.currentUser = currentUser;
this.tz = gerritIdent.getTimeZone();
- this.changeControlFactory = changeControlFactory;
+ this.changeEditUtil = changeEditUtil;
+ this.patchSetUtil = patchSetUtil;
}
/**
- * Create new change edit.
+ * Creates a new change edit.
*
- * @param change to create change edit for
- * @param ps patch set to create change edit on
- * @return result
- * @throws AuthException
- * @throws IOException
- * @throws ResourceConflictException When change edit already
- * exists for the change
- * @throws OrmException
+ * @param repository the affected Git repository
+ * @param changeControl the {@code ChangeControl} of the change for which
+ * the change edit should be created
+ * @throws AuthException if the user isn't authenticated or not allowed to
+ * use change edits
+ * @throws InvalidChangeOperationException if a change edit already existed
+ * for the change
*/
- public RefUpdate.Result createEdit(Change change, PatchSet ps)
- throws AuthException, IOException, ResourceConflictException, OrmException {
- if (!currentUser.get().isIdentifiedUser()) {
- throw new AuthException("Authentication required");
- }
- IdentifiedUser me = currentUser.get().asIdentifiedUser();
- String refPrefix = RefNames.refsEditPrefix(me.getAccountId(), change.getId());
+ public void createEdit(Repository repository, ChangeControl changeControl)
+ throws AuthException, IOException, InvalidChangeOperationException,
+ OrmException {
+ ensureAuthenticatedAndPermitted(changeControl);
- try {
- ChangeControl c =
- changeControlFactory.controlFor(reviewDb.get(), change, me);
- if (!c.canAddPatchSet(reviewDb.get())) {
- return RefUpdate.Result.REJECTED;
- }
- } catch (NoSuchChangeException e) {
- return RefUpdate.Result.NO_CHANGE;
+ Optional<ChangeEdit> changeEdit = lookupChangeEdit(changeControl);
+ if (changeEdit.isPresent()) {
+ throw new InvalidChangeOperationException(String.format("A change edit "
+ + "already exists for change %s", changeControl.getId()));
}
- try (Repository repo = gitManager.openRepository(change.getProject())) {
- Map<String, Ref> refs = repo.getRefDatabase().getRefs(refPrefix);
- if (!refs.isEmpty()) {
- throw new ResourceConflictException("edit already exists");
- }
-
- try (RevWalk rw = new RevWalk(repo)) {
- ObjectId revision = ObjectId.fromString(ps.getRevision().get());
- String editRefName = RefNames.refsEdit(me.getAccountId(), change.getId(),
- ps.getId());
- Result res = update(repo, me, editRefName, rw, ObjectId.zeroId(),
- revision, TimeUtil.nowTs());
- indexer.index(reviewDb.get(), change);
- return res;
- }
- }
+ PatchSet currentPatchSet = lookupCurrentPatchSet(changeControl);
+ ObjectId patchSetCommitId = getPatchSetCommitId(currentPatchSet);
+ createEditReference(repository, changeControl, currentPatchSet,
+ patchSetCommitId, TimeUtil.nowTs());
}
/**
* Rebase change edit on latest patch set
*
- * @param edit change edit that contains edit to rebase
- * @param current patch set to rebase the edit on
- * @throws AuthException
- * @throws ResourceConflictException thrown if rebase fails due to merge conflicts
- * @throws InvalidChangeOperationException
- * @throws IOException
+ * @param repository the affected Git repository
+ * @param changeControl the {@code ChangeControl} of the change whose change
+ * edit should be rebased
+ * @throws AuthException if the user isn't authenticated or not allowed to
+ * use change edits
+ * @throws InvalidChangeOperationException if a change edit doesn't exist
+ * for the specified change, the change edit is already based on the latest
+ * patch set, or the change represents the root commit
+ * @throws MergeConflictException if rebase fails due to merge conflicts
*/
- public void rebaseEdit(ChangeEdit edit, PatchSet current)
- throws AuthException, ResourceConflictException,
- InvalidChangeOperationException, IOException {
- if (!currentUser.get().isIdentifiedUser()) {
- throw new AuthException("Authentication required");
+ public void rebaseEdit(Repository repository, ChangeControl changeControl)
+ throws AuthException, InvalidChangeOperationException, IOException,
+ OrmException, MergeConflictException {
+ ensureAuthenticatedAndPermitted(changeControl);
+
+ Optional<ChangeEdit> optionalChangeEdit = lookupChangeEdit(changeControl);
+ if (!optionalChangeEdit.isPresent()) {
+ throw new InvalidChangeOperationException(String.format(
+ "No change edit exists for change %s", changeControl.getId()));
+ }
+ ChangeEdit changeEdit = optionalChangeEdit.get();
+
+ PatchSet currentPatchSet = lookupCurrentPatchSet(changeControl);
+ if (isBasedOn(changeEdit, currentPatchSet)) {
+ throw new InvalidChangeOperationException(String.format(
+ "Change edit for change %s is already based on latest patch set %s",
+ changeControl.getId(), currentPatchSet.getId()));
}
- Change change = edit.getChange();
- IdentifiedUser me = currentUser.get().asIdentifiedUser();
- String refName = RefNames.refsEdit(me.getAccountId(), change.getId(),
- current.getId());
- try (Repository repo = gitManager.openRepository(change.getProject());
- RevWalk rw = new RevWalk(repo);
- ObjectInserter inserter = repo.newObjectInserter()) {
- BatchRefUpdate ru = repo.getRefDatabase().newBatchUpdate();
- RevCommit editCommit = edit.getEditCommit();
- if (editCommit.getParentCount() == 0) {
- throw new InvalidChangeOperationException(
- "Rebase edit against root commit not supported");
- }
- RevCommit tip = rw.parseCommit(ObjectId.fromString(
- current.getRevision().get()));
- ThreeWayMerger m = MergeStrategy.RESOLVE.newMerger(repo, true);
- m.setObjectInserter(inserter);
- m.setBase(ObjectId.fromString(
- edit.getBasePatchSet().getRevision().get()));
+ rebase(repository, changeEdit, currentPatchSet);
+ }
- if (m.merge(tip, editCommit)) {
- ObjectId tree = m.getResultTreeId();
-
- CommitBuilder commit = new CommitBuilder();
- commit.setTreeId(tree);
- for (int i = 0; i < tip.getParentCount(); i++) {
- commit.addParentId(tip.getParent(i));
- }
- commit.setAuthor(editCommit.getAuthorIdent());
- commit.setCommitter(new PersonIdent(
- editCommit.getCommitterIdent(), TimeUtil.nowTs()));
- commit.setMessage(editCommit.getFullMessage());
- ObjectId newEdit = inserter.insert(commit);
- inserter.flush();
-
- ru.addCommand(new ReceiveCommand(ObjectId.zeroId(), newEdit,
- refName));
- ru.addCommand(new ReceiveCommand(edit.getRef().getObjectId(),
- ObjectId.zeroId(), edit.getRefName()));
- ru.execute(rw, NullProgressMonitor.INSTANCE);
- for (ReceiveCommand cmd : ru.getCommands()) {
- if (cmd.getResult() != ReceiveCommand.Result.OK) {
- throw new IOException("failed: " + cmd);
- }
- }
- } else {
- // TODO(davido): Allow to resolve conflicts inline
- throw new ResourceConflictException("merge conflict");
- }
+ private void rebase(Repository repository, ChangeEdit changeEdit,
+ PatchSet currentPatchSet) throws IOException, MergeConflictException,
+ InvalidChangeOperationException, OrmException {
+ RevCommit currentEditCommit = changeEdit.getEditCommit();
+ if (currentEditCommit.getParentCount() == 0) {
+ throw new InvalidChangeOperationException(
+ "Rebase change edit against root commit not supported");
}
+
+ Change change = changeEdit.getChange();
+ RevCommit basePatchSetCommit = lookupCommit(repository, currentPatchSet);
+ RevTree basePatchSetTree = basePatchSetCommit.getTree();
+
+ ObjectId newTreeId = merge(repository, changeEdit, basePatchSetTree);
+ Timestamp nowTimestamp = TimeUtil.nowTs();
+ String commitMessage = currentEditCommit.getFullMessage();
+ ObjectId newEditCommitId = createCommit(repository, basePatchSetCommit,
+ newTreeId, commitMessage, nowTimestamp);
+
+ String newEditRefName = getEditRefName(change, currentPatchSet);
+ updateReferenceWithNameChange(repository, changeEdit.getRefName(),
+ currentEditCommit, newEditRefName, newEditCommitId, nowTimestamp);
+ reindex(change);
}
/**
- * Modify commit message in existing change edit.
+ * Modifies the commit message of a change edit. If the change edit doesn't
+ * exist, a new one will be created based on the current patch set.
*
- * @param edit change edit
- * @param msg new commit message
- * @return result
- * @throws AuthException
- * @throws InvalidChangeOperationException
- * @throws IOException
- * @throws UnchangedCommitMessageException
+ * @param repository the affected Git repository
+ * @param changeControl the {@code ChangeControl} of the change whose change
+ * edit's message should be modified
+ * @param newCommitMessage the new commit message
+ * @throws AuthException if the user isn't authenticated or not allowed to
+ * use change edits
+ * @throws UnchangedCommitMessageException if the commit message is the same
+ * as before
*/
- public RefUpdate.Result modifyMessage(ChangeEdit edit, String msg)
- throws AuthException, InvalidChangeOperationException, IOException,
- UnchangedCommitMessageException {
- msg = msg.trim() + "\n";
- checkState(!Strings.isNullOrEmpty(msg), "message cannot be null");
- if (!currentUser.get().isIdentifiedUser()) {
- throw new AuthException("Authentication required");
- }
+ public void modifyMessage(Repository repository, ChangeControl changeControl,
+ String newCommitMessage) throws AuthException, IOException,
+ UnchangedCommitMessageException, OrmException {
+ ensureAuthenticatedAndPermitted(changeControl);
+ newCommitMessage = getWellFormedCommitMessage(newCommitMessage);
- RevCommit prevEdit = edit.getEditCommit();
- if (prevEdit.getFullMessage().equals(msg)) {
+ Optional<ChangeEdit> optionalChangeEdit = lookupChangeEdit(changeControl);
+ PatchSet basePatchSet = getBasePatchSet(optionalChangeEdit, changeControl);
+ RevCommit basePatchSetCommit = lookupCommit(repository, basePatchSet);
+ RevCommit baseCommit = optionalChangeEdit.map(ChangeEdit::getEditCommit)
+ .orElse(basePatchSetCommit);
+
+ String currentCommitMessage = baseCommit.getFullMessage();
+ if (newCommitMessage.equals(currentCommitMessage)) {
throw new UnchangedCommitMessageException();
}
- IdentifiedUser me = currentUser.get().asIdentifiedUser();
- Project.NameKey project = edit.getChange().getProject();
- try (Repository repo = gitManager.openRepository(project);
- RevWalk rw = new RevWalk(repo);
- ObjectInserter inserter = repo.newObjectInserter()) {
- String refName = edit.getRefName();
- Timestamp now = TimeUtil.nowTs();
- ObjectId commit = createCommit(me, inserter, prevEdit,
- prevEdit.getTree(),
- msg, now);
- inserter.flush();
- return update(repo, me, refName, rw, prevEdit, commit, now);
+ RevTree baseTree = baseCommit.getTree();
+ Timestamp nowTimestamp = TimeUtil.nowTs();
+ ObjectId newEditCommit = createCommit(repository, basePatchSetCommit,
+ baseTree, newCommitMessage, nowTimestamp);
+
+ if (optionalChangeEdit.isPresent()) {
+ updateEditReference(repository, optionalChangeEdit.get(), newEditCommit,
+ nowTimestamp);
+ } else {
+ createEditReference(repository, changeControl, basePatchSet,
+ newEditCommit, nowTimestamp);
}
}
/**
- * Modify file in existing change edit from its base commit.
+ * Modifies the contents of a file of a change edit. If the change edit
+ * doesn't exist, a new one will be created based on the current patch set.
*
- * @param edit change edit
- * @param file path to modify
- * @param content new content
- * @return result
- * @throws AuthException
- * @throws InvalidChangeOperationException
- * @throws IOException
+ * @param repository the affected Git repository
+ * @param changeControl the {@code ChangeControl} of the change whose change
+ * edit should be modified
+ * @param filePath the path of the file whose contents should be modified
+ * @param newContent the new file content
+ * @throws AuthException if the user isn't authenticated or not allowed to
+ * use change edits
+ * @throws InvalidChangeOperationException if the file already had the
+ * specified content
*/
- public RefUpdate.Result modifyFile(ChangeEdit edit,
- String file, RawInput content) throws AuthException,
- InvalidChangeOperationException, IOException {
- return modify(TreeOperation.CHANGE_ENTRY, edit, file, null, content);
+ public void modifyFile(Repository repository, ChangeControl changeControl,
+ String filePath, RawInput newContent) throws AuthException,
+ InvalidChangeOperationException, IOException, OrmException {
+ modifyTree(repository, changeControl,
+ new ChangeFileContentModification(filePath, newContent));
}
/**
- * Delete file in existing change edit.
+ * Deletes a file from the Git tree of a change edit. If the change edit
+ * doesn't exist, a new one will be created based on the current patch set.
*
- * @param edit change edit
- * @param file path to delete
- * @return result
- * @throws AuthException
- * @throws InvalidChangeOperationException
- * @throws IOException
+ * @param repository the affected Git repository
+ * @param changeControl the {@code ChangeControl} of the change whose change
+ * edit should be modified
+ * @param file path of the file which should be deleted
+ * @throws AuthException if the user isn't authenticated or not allowed to
+ * use change edits
+ * @throws InvalidChangeOperationException if the file does not exist
*/
- public RefUpdate.Result deleteFile(ChangeEdit edit,
+ public void deleteFile(Repository repository, ChangeControl changeControl,
String file) throws AuthException, InvalidChangeOperationException,
- IOException {
- return modify(TreeOperation.DELETE_ENTRY, edit, file, null, null);
+ IOException, OrmException {
+ modifyTree(repository, changeControl, new DeleteFileModification(file));
}
/**
- * Rename file in existing change edit.
+ * Renames a file of a change edit or moves it to another directory. If the
+ * change edit doesn't exist, a new one will be created based on the current
+ * patch set.
*
- * @param edit change edit
- * @param file path to rename
- * @param newFile path to rename the file to
- * @return result
- * @throws AuthException
- * @throws InvalidChangeOperationException
- * @throws IOException
+ * @param repository the affected Git repository
+ * @param changeControl the {@code ChangeControl} of the change whose change
+ * edit should be modified
+ * @param currentFilePath the current path/name of the file
+ * @param newFilePath the desired path/name of the file
+ * @throws AuthException if the user isn't authenticated or not allowed to
+ * use change edits
+ * @throws InvalidChangeOperationException if the file was already renamed
+ * to the specified new name
*/
- public RefUpdate.Result renameFile(ChangeEdit edit, String file,
- String newFile) throws AuthException, InvalidChangeOperationException,
- IOException {
- return modify(TreeOperation.RENAME_ENTRY, edit, file, newFile, null);
+ public void renameFile(Repository repository, ChangeControl changeControl,
+ String currentFilePath, String newFilePath) throws AuthException,
+ InvalidChangeOperationException, IOException, OrmException {
+ modifyTree(repository, changeControl,
+ new RenameFileModification(currentFilePath, newFilePath));
}
/**
- * Restore file in existing change edit.
+ * Restores a file of a change edit to the state it was in before the patch
+ * set on which the change edit is based. If the change edit doesn't exist, a
+ * new one will be created based on the current patch set.
*
- * @param edit change edit
- * @param file path to restore
- * @return result
- * @throws AuthException
- * @throws InvalidChangeOperationException
- * @throws IOException
+ * @param repository the affected Git repository
+ * @param changeControl the {@code ChangeControl} of the change whose change
+ * edit should be modified
+ * @param file the path of the file which should be restored
+ * @throws AuthException if the user isn't authenticated or not allowed to
+ * use change edits
+ * @throws InvalidChangeOperationException if the file was already restored
*/
- public RefUpdate.Result restoreFile(ChangeEdit edit,
+ public void restoreFile(Repository repository, ChangeControl changeControl,
String file) throws AuthException, InvalidChangeOperationException,
- IOException {
- return modify(TreeOperation.RESTORE_ENTRY, edit, file, null, null);
+ IOException, OrmException {
+ modifyTree(repository, changeControl, new RestoreFileModification(file));
}
- private RefUpdate.Result modify(TreeOperation op, ChangeEdit edit,
- String file, @Nullable String newFile, @Nullable RawInput content)
- throws AuthException, IOException, InvalidChangeOperationException {
+ private void modifyTree(Repository repository, ChangeControl changeControl,
+ TreeModification treeModification) throws AuthException, IOException,
+ OrmException, InvalidChangeOperationException {
+ ensureAuthenticatedAndPermitted(changeControl);
+
+ Optional<ChangeEdit> optionalChangeEdit = lookupChangeEdit(changeControl);
+ PatchSet basePatchSet = getBasePatchSet(optionalChangeEdit, changeControl);
+ RevCommit basePatchSetCommit = lookupCommit(repository, basePatchSet);
+ RevCommit baseCommit = optionalChangeEdit.map(ChangeEdit::getEditCommit)
+ .orElse(basePatchSetCommit);
+
+ ObjectId newTreeId = createNewTree(repository, baseCommit,
+ treeModification);
+
+ String commitMessage = baseCommit.getFullMessage();
+ Timestamp nowTimestamp = TimeUtil.nowTs();
+ ObjectId newEditCommit = createCommit(repository, basePatchSetCommit,
+ newTreeId, commitMessage, nowTimestamp);
+
+ if (optionalChangeEdit.isPresent()) {
+ updateEditReference(repository, optionalChangeEdit.get(), newEditCommit,
+ nowTimestamp);
+ } else {
+ createEditReference(repository, changeControl, basePatchSet,
+ newEditCommit, nowTimestamp);
+ }
+ }
+
+ private void ensureAuthenticatedAndPermitted(ChangeControl changeControl)
+ throws AuthException, OrmException {
+ ensureAuthenticated();
+ ensurePermitted(changeControl);
+ }
+
+ private void ensureAuthenticated() throws AuthException {
if (!currentUser.get().isIdentifiedUser()) {
throw new AuthException("Authentication required");
}
+ }
+
+ private void ensurePermitted(ChangeControl changeControl)
+ throws OrmException, AuthException {
+ if (!changeControl.canAddPatchSet(reviewDb.get())) {
+ throw new AuthException("Not allowed to edit a change.");
+ }
+ }
+
+ private String getWellFormedCommitMessage(String commitMessage) {
+ String wellFormedMessage = Strings.nullToEmpty(commitMessage).trim();
+ checkState(!wellFormedMessage.isEmpty(),
+ "Commit message cannot be null or empty");
+ wellFormedMessage = wellFormedMessage + "\n";
+ return wellFormedMessage;
+ }
+
+ private Optional<ChangeEdit> lookupChangeEdit(ChangeControl changeControl)
+ throws AuthException, IOException {
+ return changeEditUtil.byChange(changeControl);
+ }
+
+ private PatchSet getBasePatchSet(Optional<ChangeEdit> optionalChangeEdit,
+ ChangeControl changeControl) throws OrmException {
+ Optional<PatchSet> editBasePatchSet =
+ optionalChangeEdit.map(ChangeEdit::getBasePatchSet);
+ return editBasePatchSet.isPresent()
+ ? editBasePatchSet.get()
+ : lookupCurrentPatchSet(changeControl);
+ }
+
+ private PatchSet lookupCurrentPatchSet(ChangeControl changeControl)
+ throws OrmException {
+ return patchSetUtil.current(reviewDb.get(), changeControl.getNotes());
+ }
+
+ private static boolean isBasedOn(ChangeEdit changeEdit, PatchSet patchSet) {
+ PatchSet editBasePatchSet = changeEdit.getBasePatchSet();
+ return editBasePatchSet.getId().equals(patchSet.getId());
+ }
+
+ private static RevCommit lookupCommit(Repository repository,
+ PatchSet patchSet) throws IOException {
+ ObjectId patchSetCommitId = getPatchSetCommitId(patchSet);
+ try (RevWalk revWalk = new RevWalk(repository)) {
+ return revWalk.parseCommit(patchSetCommitId);
+ }
+ }
+
+ private static ObjectId createNewTree(Repository repository,
+ RevCommit baseCommit, TreeModification treeModification)
+ throws IOException, InvalidChangeOperationException {
+ TreeCreator treeCreator = new TreeCreator(baseCommit);
+ treeCreator.addTreeModification(treeModification);
+ ObjectId newTreeId = treeCreator.createNewTreeAndGetId(repository);
+
+ if (ObjectId.equals(newTreeId, baseCommit.getTree())) {
+ throw new InvalidChangeOperationException("no changes were made");
+ }
+ return newTreeId;
+ }
+
+ private ObjectId merge(Repository repository, ChangeEdit changeEdit,
+ ObjectId newTreeId) throws IOException, MergeConflictException {
+ PatchSet basePatchSet = changeEdit.getBasePatchSet();
+ ObjectId basePatchSetCommitId = getPatchSetCommitId(basePatchSet);
+ ObjectId editCommitId = changeEdit.getEditCommit();
+
+ ThreeWayMerger threeWayMerger =
+ MergeStrategy.RESOLVE.newMerger(repository, true);
+ threeWayMerger.setBase(basePatchSetCommitId);
+ boolean successful = threeWayMerger.merge(newTreeId, editCommitId);
+
+ if (!successful) {
+ throw new MergeConflictException(
+ "The existing change edit could not be merged with another tree.");
+ }
+ return threeWayMerger.getResultTreeId();
+ }
+
+ private ObjectId createCommit(Repository repository,
+ RevCommit basePatchSetCommit, ObjectId tree, String commitMessage,
+ Timestamp timestamp) throws IOException {
+ try (ObjectInserter objectInserter = repository.newObjectInserter()) {
+ CommitBuilder builder = new CommitBuilder();
+ builder.setTreeId(tree);
+ builder.setParentIds(basePatchSetCommit.getParents());
+ builder.setAuthor(basePatchSetCommit.getAuthorIdent());
+ builder.setCommitter(getCommitterIdent(timestamp));
+ builder.setMessage(commitMessage);
+ ObjectId newCommitId = objectInserter.insert(builder);
+ objectInserter.flush();
+ return newCommitId;
+ }
+ }
+
+ private PersonIdent getCommitterIdent(Timestamp commitTimestamp) {
+ IdentifiedUser user = currentUser.get().asIdentifiedUser();
+ return user.newCommitterIdent(commitTimestamp, tz);
+ }
+
+ private static ObjectId getPatchSetCommitId(PatchSet patchSet) {
+ return ObjectId.fromString(patchSet.getRevision().get());
+ }
+
+ private void createEditReference(Repository repository,
+ ChangeControl changeControl, PatchSet basePatchSet,
+ ObjectId newEditCommit, Timestamp timestamp)
+ throws IOException, OrmException {
+ Change change = changeControl.getChange();
+ String editRefName = getEditRefName(change, basePatchSet);
+ updateReference(repository, editRefName, ObjectId.zeroId(), newEditCommit,
+ timestamp);
+ reindex(change);
+ }
+
+ private String getEditRefName(Change change, PatchSet basePatchSet) {
IdentifiedUser me = currentUser.get().asIdentifiedUser();
- Project.NameKey project = edit.getChange().getProject();
- try (Repository repo = gitManager.openRepository(project);
- RevWalk rw = new RevWalk(repo);
- ObjectInserter inserter = repo.newObjectInserter();
- ObjectReader reader = repo.newObjectReader()) {
- String refName = edit.getRefName();
- RevCommit prevEdit = edit.getEditCommit();
- ObjectId newTree = writeNewTree(
- op,
- rw,
- inserter,
- prevEdit,
- reader,
- file,
- newFile,
- content);
- if (ObjectId.equals(newTree, prevEdit.getTree())) {
- throw new InvalidChangeOperationException("no changes were made");
- }
-
- Timestamp now = TimeUtil.nowTs();
- ObjectId commit = createCommit(me, inserter, prevEdit, newTree, now);
- inserter.flush();
- return update(repo, me, refName, rw, prevEdit, commit, now);
- }
+ return RefNames.refsEdit(me.getAccountId(), change.getId(),
+ basePatchSet.getId());
}
- private static ObjectId toBlob(ObjectInserter ins, @Nullable RawInput content)
+ private void updateEditReference(Repository repository, ChangeEdit changeEdit,
+ ObjectId newEditCommit, Timestamp timestamp)
+ throws IOException, OrmException {
+ String editRefName = changeEdit.getRefName();
+ RevCommit currentEditCommit = changeEdit.getEditCommit();
+ updateReference(repository, editRefName, currentEditCommit, newEditCommit,
+ timestamp);
+ reindex(changeEdit.getChange());
+ }
+
+ private void updateReference(Repository repository, String refName,
+ ObjectId currentObjectId, ObjectId targetObjectId, Timestamp timestamp)
throws IOException {
- if (content == null) {
- return null;
- }
-
- long len = content.getContentLength();
- InputStream in = content.getInputStream();
- if (len < 0) {
- return ins.insert(OBJ_BLOB, ByteStreams.toByteArray(in));
- }
- return ins.insert(OBJ_BLOB, len, in);
- }
-
- private ObjectId createCommit(IdentifiedUser me, ObjectInserter inserter,
- RevCommit revision, ObjectId tree, Timestamp when) throws IOException {
- return createCommit(me, inserter, revision, tree,
- revision.getFullMessage(), when);
- }
-
- private ObjectId createCommit(IdentifiedUser me, ObjectInserter inserter,
- RevCommit revision, ObjectId tree, String msg, Timestamp when)
- throws IOException {
- CommitBuilder builder = new CommitBuilder();
- builder.setTreeId(tree);
- builder.setParentIds(revision.getParents());
- builder.setAuthor(revision.getAuthorIdent());
- builder.setCommitter(getCommitterIdent(me, when));
- builder.setMessage(msg);
- return inserter.insert(builder);
- }
-
- private RefUpdate.Result update(Repository repo, IdentifiedUser me,
- String refName, RevWalk rw, ObjectId oldObjectId, ObjectId newEdit,
- Timestamp when) throws IOException {
- RefUpdate ru = repo.updateRef(refName);
- ru.setExpectedOldObjectId(oldObjectId);
- ru.setNewObjectId(newEdit);
- ru.setRefLogIdent(getRefLogIdent(me, when));
+ RefUpdate ru = repository.updateRef(refName);
+ ru.setExpectedOldObjectId(currentObjectId);
+ ru.setNewObjectId(targetObjectId);
+ ru.setRefLogIdent(getRefLogIdent(timestamp));
ru.setRefLogMessage("inline edit (amend)", false);
ru.setForceUpdate(true);
- RefUpdate.Result res = ru.update(rw);
- if (res != RefUpdate.Result.NEW &&
- res != RefUpdate.Result.FORCED) {
- throw new IOException("update failed: " + ru);
- }
- return res;
- }
-
- private static ObjectId writeNewTree(
- TreeOperation op,
- RevWalk rw,
- final ObjectInserter ins,
- RevCommit prevEdit,
- ObjectReader reader,
- String fileName,
- @Nullable String newFile,
- @Nullable final RawInput content)
- throws InvalidChangeOperationException, IOException {
- DirCache newTree = readTree(reader, prevEdit);
- DirCacheEditor dce = newTree.editor();
- switch (op) {
- case DELETE_ENTRY:
- dce.add(new DeletePath(fileName));
- break;
-
- case RENAME_ENTRY:
- rw.parseHeaders(prevEdit);
- TreeWalk tw =
- TreeWalk.forPath(rw.getObjectReader(), fileName, prevEdit.getTree());
- if (tw != null) {
- dce.add(new DeletePath(fileName));
- addFileToCommit(newFile, dce, tw);
- }
- break;
-
- case CHANGE_ENTRY:
- checkNotNull(content, "new content required");
-
- final AtomicReference<IOException> ioe =
- new AtomicReference<>(null);
- final AtomicReference<InvalidChangeOperationException> icoe =
- new AtomicReference<>(null);
- dce.add(new PathEdit(fileName) {
- @Override
- public void apply(DirCacheEntry ent) {
- try {
- if (ent.getFileMode() == FileMode.GITLINK) {
- ent.setLength(0);
- ent.setLastModified(0);
- ent.setObjectId(ObjectId.fromString(
- ByteStreams.toByteArray(content.getInputStream()), 0));
- } else {
- if (ent.getRawMode() == 0) {
- ent.setFileMode(FileMode.REGULAR_FILE);
- }
- ent.setObjectId(toBlob(ins, content));
- }
- } catch (IOException e) {
- ioe.set(e);
- } catch (InvalidObjectIdException e) {
- icoe.set(new InvalidChangeOperationException(
- "Invalid object id in submodule link: " + e.getMessage()));
- icoe.get().initCause(e);
- }
- }
- });
- if (ioe.get() != null) {
- throw ioe.get();
- }
- if (icoe.get() != null) {
- throw icoe.get();
- }
- break;
-
- case RESTORE_ENTRY:
- if (prevEdit.getParentCount() == 0) {
- dce.add(new DeletePath(fileName));
- break;
- }
-
- RevCommit base = prevEdit.getParent(0);
- rw.parseHeaders(base);
- tw = TreeWalk.forPath(rw.getObjectReader(), fileName, base.getTree());
- if (tw == null) {
- dce.add(new DeletePath(fileName));
- break;
- }
-
- addFileToCommit(fileName, dce, tw);
- break;
- }
- dce.finish();
- return newTree.writeTree(ins);
- }
-
- private static void addFileToCommit(String newFile, DirCacheEditor dce,
- TreeWalk tw) {
- final FileMode mode = tw.getFileMode(0);
- final ObjectId oid = tw.getObjectId(0);
- dce.add(new PathEdit(newFile) {
- @Override
- public void apply(DirCacheEntry ent) {
- ent.setFileMode(mode);
- ent.setObjectId(oid);
+ try (RevWalk revWalk = new RevWalk(repository)) {
+ RefUpdate.Result res = ru.update(revWalk);
+ if (res != RefUpdate.Result.NEW && res != RefUpdate.Result.FORCED) {
+ throw new IOException("update failed: " + ru);
}
- });
+ }
}
- private static DirCache readTree(ObjectReader reader, RevCommit prevEdit)
+ private void updateReferenceWithNameChange(Repository repository,
+ String currentRefName, ObjectId currentObjectId, String newRefName,
+ ObjectId targetObjectId, Timestamp timestamp)
throws IOException {
- DirCache dc = DirCache.newInCore();
- DirCacheBuilder b = dc.builder();
- b.addTree(new byte[0], DirCacheEntry.STAGE_0, reader, prevEdit.getTree());
- b.finish();
- return dc;
+ BatchRefUpdate batchRefUpdate =
+ repository.getRefDatabase().newBatchUpdate();
+ batchRefUpdate.addCommand(new ReceiveCommand(ObjectId.zeroId(),
+ targetObjectId, newRefName));
+ batchRefUpdate.addCommand(new ReceiveCommand(currentObjectId,
+ ObjectId.zeroId(), currentRefName));
+ batchRefUpdate.setRefLogMessage("rebase edit", false);
+ batchRefUpdate.setRefLogIdent(getRefLogIdent(timestamp));
+ try (RevWalk revWalk = new RevWalk(repository)) {
+ batchRefUpdate.execute(revWalk, NullProgressMonitor.INSTANCE);
+ }
+ for (ReceiveCommand cmd : batchRefUpdate.getCommands()) {
+ if (cmd.getResult() != ReceiveCommand.Result.OK) {
+ throw new IOException("failed: " + cmd);
+ }
+ }
}
- private PersonIdent getCommitterIdent(IdentifiedUser user, Timestamp when) {
- return user.newCommitterIdent(when, tz);
+ private PersonIdent getRefLogIdent(Timestamp timestamp) {
+ IdentifiedUser user = currentUser.get().asIdentifiedUser();
+ return user.newRefLogIdent(timestamp, tz);
}
- private PersonIdent getRefLogIdent(IdentifiedUser user, Timestamp when) {
- return user.newRefLogIdent(when, tz);
+ private void reindex(Change change) throws IOException, OrmException {
+ indexer.index(reviewDb.get(), change);
}
}
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/edit/tree/AddPath.java b/gerrit-server/src/main/java/com/google/gerrit/server/edit/tree/AddPath.java
new file mode 100644
index 0000000..9bf8e2c
--- /dev/null
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/edit/tree/AddPath.java
@@ -0,0 +1,42 @@
+// Copyright (C) 2017 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.google.gerrit.server.edit.tree;
+
+import org.eclipse.jgit.dircache.DirCacheEditor;
+import org.eclipse.jgit.dircache.DirCacheEntry;
+import org.eclipse.jgit.lib.FileMode;
+import org.eclipse.jgit.lib.ObjectId;
+
+/**
+ * A {@code PathEdit} which adds a file path to the index. This operation is the
+ * counterpart to {@link org.eclipse.jgit.dircache.DirCacheEditor.DeletePath}.
+ */
+class AddPath extends DirCacheEditor.PathEdit {
+
+ private final FileMode fileMode;
+ private final ObjectId objectId;
+
+ AddPath(String filePath, FileMode fileMode, ObjectId objectId) {
+ super(filePath);
+ this.fileMode = fileMode;
+ this.objectId = objectId;
+ }
+
+ @Override
+ public void apply(DirCacheEntry dirCacheEntry) {
+ dirCacheEntry.setFileMode(fileMode);
+ dirCacheEntry.setObjectId(objectId);
+ }
+}
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/edit/tree/ChangeFileContentModification.java b/gerrit-server/src/main/java/com/google/gerrit/server/edit/tree/ChangeFileContentModification.java
new file mode 100644
index 0000000..e83155d
--- /dev/null
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/edit/tree/ChangeFileContentModification.java
@@ -0,0 +1,126 @@
+// Copyright (C) 2017 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.google.gerrit.server.edit.tree;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.eclipse.jgit.lib.Constants.OBJ_BLOB;
+
+import com.google.common.io.ByteStreams;
+import com.google.gerrit.extensions.restapi.RawInput;
+
+import org.eclipse.jgit.dircache.DirCacheEditor;
+import org.eclipse.jgit.dircache.DirCacheEntry;
+import org.eclipse.jgit.errors.InvalidObjectIdException;
+import org.eclipse.jgit.lib.FileMode;
+import org.eclipse.jgit.lib.ObjectId;
+import org.eclipse.jgit.lib.ObjectInserter;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.revwalk.RevCommit;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * A {@code TreeModification} which changes the content of a file.
+ */
+public class ChangeFileContentModification implements TreeModification {
+
+ private static final Logger log =
+ LoggerFactory.getLogger(ChangeFileContentModification.class);
+
+ private final String filePath;
+ private final RawInput newContent;
+
+ public ChangeFileContentModification(String filePath, RawInput newContent) {
+ this.filePath = filePath;
+ this.newContent = checkNotNull(newContent, "new content required");
+ }
+
+ @Override
+ public List<DirCacheEditor.PathEdit> getPathEdits(Repository repository,
+ RevCommit baseCommit) {
+ DirCacheEditor.PathEdit changeContentEdit = new ChangeContent(filePath,
+ newContent, repository);
+ return Collections.singletonList(changeContentEdit);
+ }
+
+ /**
+ * A {@code PathEdit} which changes the contents of a file.
+ */
+ private static class ChangeContent extends DirCacheEditor.PathEdit {
+
+ private final RawInput newContent;
+ private final Repository repository;
+
+ ChangeContent(String filePath, RawInput newContent, Repository repository) {
+ super(filePath);
+ this.newContent = newContent;
+ this.repository = repository;
+ }
+
+ @Override
+ public void apply(DirCacheEntry dirCacheEntry) {
+ try {
+ if (dirCacheEntry.getFileMode() == FileMode.GITLINK) {
+ dirCacheEntry.setLength(0);
+ dirCacheEntry.setLastModified(0);
+ ObjectId newObjectId = ObjectId.fromString(getNewContentBytes(), 0);
+ dirCacheEntry.setObjectId(newObjectId);
+ } else {
+ if (dirCacheEntry.getRawMode() == 0) {
+ dirCacheEntry.setFileMode(FileMode.REGULAR_FILE);
+ }
+ ObjectId newBlobObjectId = createNewBlobAndGetItsId();
+ dirCacheEntry.setObjectId(newBlobObjectId);
+ }
+ // Previously, these two exceptions were swallowed. To improve the
+ // situation, we log them now. However, we should think of a better
+ // approach.
+ } catch (IOException e) {
+ String message = String.format("Could not change the content of %s",
+ dirCacheEntry.getPathString());
+ log.error(message, e);
+ } catch (InvalidObjectIdException e) {
+ log.error("Invalid object id in submodule link", e);
+ }
+ }
+
+ private ObjectId createNewBlobAndGetItsId() throws IOException {
+ try (ObjectInserter objectInserter = repository.newObjectInserter()) {
+ ObjectId blobObjectId = createNewBlobAndGetItsId(objectInserter);
+ objectInserter.flush();
+ return blobObjectId;
+ }
+ }
+
+ private ObjectId createNewBlobAndGetItsId(ObjectInserter objectInserter)
+ throws IOException {
+ long contentLength = newContent.getContentLength();
+ if (contentLength < 0) {
+ return objectInserter.insert(OBJ_BLOB, getNewContentBytes());
+ }
+ InputStream contentInputStream = newContent.getInputStream();
+ return objectInserter.insert(OBJ_BLOB, contentLength, contentInputStream);
+ }
+
+ private byte[] getNewContentBytes() throws IOException {
+ return ByteStreams.toByteArray(newContent.getInputStream());
+ }
+ }
+}
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/edit/tree/DeleteFileModification.java b/gerrit-server/src/main/java/com/google/gerrit/server/edit/tree/DeleteFileModification.java
new file mode 100644
index 0000000..64fe63b
--- /dev/null
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/edit/tree/DeleteFileModification.java
@@ -0,0 +1,42 @@
+// Copyright (C) 2017 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.google.gerrit.server.edit.tree;
+
+import org.eclipse.jgit.dircache.DirCacheEditor;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.revwalk.RevCommit;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * A {@code TreeModification} which deletes a file.
+ */
+public class DeleteFileModification implements TreeModification {
+
+ private final String filePath;
+
+ public DeleteFileModification(String filePath) {
+ this.filePath = filePath;
+ }
+
+ @Override
+ public List<DirCacheEditor.PathEdit> getPathEdits(Repository repository,
+ RevCommit baseCommit) {
+ DirCacheEditor.DeletePath deletePathEdit =
+ new DirCacheEditor.DeletePath(filePath);
+ return Collections.singletonList(deletePathEdit);
+ }
+}
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/edit/tree/RenameFileModification.java b/gerrit-server/src/main/java/com/google/gerrit/server/edit/tree/RenameFileModification.java
new file mode 100644
index 0000000..32c1e0d
--- /dev/null
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/edit/tree/RenameFileModification.java
@@ -0,0 +1,61 @@
+// Copyright (C) 2017 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.google.gerrit.server.edit.tree;
+
+import org.eclipse.jgit.dircache.DirCacheEditor;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.revwalk.RevCommit;
+import org.eclipse.jgit.revwalk.RevWalk;
+import org.eclipse.jgit.treewalk.TreeWalk;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * A {@code TreeModification} which renames a file or moves it to a different
+ * path.
+ */
+public class RenameFileModification implements TreeModification {
+
+ private final String currentFilePath;
+ private final String newFilePath;
+
+ public RenameFileModification(String currentFilePath, String newFilePath) {
+ this.currentFilePath = currentFilePath;
+ this.newFilePath = newFilePath;
+ }
+
+ @Override
+ public List<DirCacheEditor.PathEdit> getPathEdits(Repository repository,
+ RevCommit baseCommit)
+ throws IOException {
+ try (RevWalk revWalk = new RevWalk(repository)) {
+ revWalk.parseHeaders(baseCommit);
+ try (TreeWalk treeWalk = TreeWalk.forPath(revWalk.getObjectReader(),
+ currentFilePath, baseCommit.getTree())) {
+ if (treeWalk == null) {
+ return Collections.emptyList();
+ }
+ DirCacheEditor.DeletePath deletePathEdit =
+ new DirCacheEditor.DeletePath(currentFilePath);
+ AddPath addPathEdit = new AddPath(newFilePath, treeWalk.getFileMode(0),
+ treeWalk.getObjectId(0));
+ return Arrays.asList(deletePathEdit, addPathEdit);
+ }
+ }
+ }
+}
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/edit/tree/RestoreFileModification.java b/gerrit-server/src/main/java/com/google/gerrit/server/edit/tree/RestoreFileModification.java
new file mode 100644
index 0000000..b5cc9e6
--- /dev/null
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/edit/tree/RestoreFileModification.java
@@ -0,0 +1,66 @@
+// Copyright (C) 2017 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.google.gerrit.server.edit.tree;
+
+import org.eclipse.jgit.dircache.DirCacheEditor;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.revwalk.RevCommit;
+import org.eclipse.jgit.revwalk.RevWalk;
+import org.eclipse.jgit.treewalk.TreeWalk;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * A {@code TreeModification} which restores a file. The file is added again if
+ * it was present before the specified commit or deleted if it was absent.
+ */
+public class RestoreFileModification implements TreeModification {
+
+ private final String filePath;
+
+ public RestoreFileModification(String filePath) {
+ this.filePath = filePath;
+ }
+
+ @Override
+ public List<DirCacheEditor.PathEdit> getPathEdits(Repository repository,
+ RevCommit baseCommit)
+ throws IOException {
+ if (baseCommit.getParentCount() == 0) {
+ DirCacheEditor.DeletePath deletePath =
+ new DirCacheEditor.DeletePath(filePath);
+ return Collections.singletonList(deletePath);
+ }
+
+ RevCommit base = baseCommit.getParent(0);
+ try (RevWalk revWalk = new RevWalk(repository)) {
+ revWalk.parseHeaders(base);
+ try (TreeWalk treeWalk = TreeWalk.forPath(revWalk.getObjectReader(),
+ filePath, base.getTree())) {
+ if (treeWalk == null) {
+ DirCacheEditor.DeletePath deletePath =
+ new DirCacheEditor.DeletePath(filePath);
+ return Collections.singletonList(deletePath);
+ }
+
+ AddPath addPath = new AddPath(filePath, treeWalk.getFileMode(0),
+ treeWalk.getObjectId(0));
+ return Collections.singletonList(addPath);
+ }
+ }
+ }
+}
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/edit/tree/TreeCreator.java b/gerrit-server/src/main/java/com/google/gerrit/server/edit/tree/TreeCreator.java
new file mode 100644
index 0000000..661956f
--- /dev/null
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/edit/tree/TreeCreator.java
@@ -0,0 +1,118 @@
+// Copyright (C) 2017 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.google.gerrit.server.edit.tree;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.eclipse.jgit.dircache.DirCache;
+import org.eclipse.jgit.dircache.DirCacheBuilder;
+import org.eclipse.jgit.dircache.DirCacheEditor;
+import org.eclipse.jgit.dircache.DirCacheEntry;
+import org.eclipse.jgit.lib.ObjectId;
+import org.eclipse.jgit.lib.ObjectInserter;
+import org.eclipse.jgit.lib.ObjectReader;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.revwalk.RevCommit;
+
+import java.io.IOException;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * A creator for a new Git tree. To create the new tree, the tree of another
+ * commit is taken as a basis and modified.
+ */
+public class TreeCreator {
+
+ private final RevCommit baseCommit;
+ // At the moment, a list wouldn't be necessary as only one modification is
+ // applied per created tree. This is going to change in the near future.
+ private final List<TreeModification> treeModifications = new LinkedList<>();
+
+ public TreeCreator(RevCommit baseCommit) {
+ this.baseCommit = checkNotNull(baseCommit, "baseCommit is required");
+ }
+
+ /**
+ * Apply a modification to the tree which is taken as a basis. If this
+ * method is called multiple times, the modifications are applied
+ * subsequently in exactly the order they were provided.
+ *
+ * @param treeModification a modification which should be applied to the
+ * base tree
+ */
+ public void addTreeModification(TreeModification treeModification) {
+ checkNotNull(treeModification, "treeModification must not be null");
+ treeModifications.add(treeModification);
+ }
+
+ /**
+ * Creates the new tree. When this method is called, the specified base tree
+ * is read from the repository, the specified modifications are applied, and
+ * the resulting tree is written to the object store of the repository.
+ *
+ * @param repository the affected Git repository
+ * @return the {@code ObjectId} of the created tree
+ * @throws IOException if problems arise when accessing the repository
+ */
+ public ObjectId createNewTreeAndGetId(Repository repository)
+ throws IOException {
+ DirCache newTree = createNewTree(repository);
+ return writeAndGetId(repository, newTree);
+ }
+
+ private DirCache createNewTree(Repository repository) throws IOException {
+ DirCache newTree = readBaseTree(repository);
+ List<DirCacheEditor.PathEdit> pathEdits = getPathEdits(repository);
+ applyPathEdits(newTree, pathEdits);
+ return newTree;
+ }
+
+ private DirCache readBaseTree(Repository repository) throws IOException {
+ try (ObjectReader objectReader = repository.newObjectReader()) {
+ DirCache dirCache = DirCache.newInCore();
+ DirCacheBuilder dirCacheBuilder = dirCache.builder();
+ dirCacheBuilder.addTree(new byte[0], DirCacheEntry.STAGE_0, objectReader,
+ baseCommit.getTree());
+ dirCacheBuilder.finish();
+ return dirCache;
+ }
+ }
+
+ private List<DirCacheEditor.PathEdit> getPathEdits(Repository repository)
+ throws IOException {
+ List<DirCacheEditor.PathEdit> pathEdits = new LinkedList<>();
+ for (TreeModification treeModification : treeModifications) {
+ pathEdits.addAll(treeModification.getPathEdits(repository, baseCommit));
+ }
+ return pathEdits;
+ }
+
+ private static void applyPathEdits(DirCache tree,
+ List<DirCacheEditor.PathEdit> pathEdits) {
+ DirCacheEditor dirCacheEditor = tree.editor();
+ pathEdits.forEach(dirCacheEditor::add);
+ dirCacheEditor.finish();
+ }
+
+ private static ObjectId writeAndGetId(Repository repository, DirCache tree)
+ throws IOException {
+ try (ObjectInserter objectInserter = repository.newObjectInserter()) {
+ ObjectId treeId = tree.writeTree(objectInserter);
+ objectInserter.flush();
+ return treeId;
+ }
+ }
+}
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/edit/tree/TreeModification.java b/gerrit-server/src/main/java/com/google/gerrit/server/edit/tree/TreeModification.java
new file mode 100644
index 0000000..4b66cd4
--- /dev/null
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/edit/tree/TreeModification.java
@@ -0,0 +1,42 @@
+// Copyright (C) 2017 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.google.gerrit.server.edit.tree;
+
+import org.eclipse.jgit.dircache.DirCacheEditor;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.revwalk.RevCommit;
+
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * A specific modification of a Git tree.
+ */
+public interface TreeModification {
+
+ /**
+ * Returns a list of {@code PathEdit}s which are necessary in order to
+ * achieve the desired modification of the Git tree. The order of the
+ * {@code PathEdit}s can be crucial and hence shouldn't be changed.
+ *
+ * @param repository the affected Git repository
+ * @param baseCommit the commit to whose tree this modification is applied
+ * @return an ordered list of necessary {@code PathEdit}s
+ * @throws IOException if problems arise when accessing the repository
+ */
+ List<DirCacheEditor.PathEdit> getPathEdits(Repository repository,
+ RevCommit baseCommit) throws IOException;
+
+}
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/notedb/ConfigNotesMigration.java b/gerrit-server/src/main/java/com/google/gerrit/server/notedb/ConfigNotesMigration.java
index bf9bc4e..3d2d4fd 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/notedb/ConfigNotesMigration.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/notedb/ConfigNotesMigration.java
@@ -51,6 +51,7 @@
private static final String NOTE_DB = "noteDb";
+ // All of these names must be reflected in the allowed set in checkConfig.
private static final String PRIMARY_STORAGE = "primaryStorage";
private static final String READ = "read";
private static final String SEQUENCE = "sequence";
@@ -59,9 +60,13 @@
private static void checkConfig(Config cfg) {
Set<String> keys = new HashSet<>();
for (NoteDbTable t : NoteDbTable.values()) {
- keys.add(t.key());
+ keys.add(t.key().toLowerCase());
}
- Set<String> allowed = ImmutableSet.of(READ, WRITE, SEQUENCE);
+ Set<String> allowed = ImmutableSet.of(
+ PRIMARY_STORAGE.toLowerCase(),
+ READ.toLowerCase(),
+ WRITE.toLowerCase(),
+ SEQUENCE.toLowerCase());
for (String t : cfg.getSubsections(NOTE_DB)) {
checkArgument(keys.contains(t.toLowerCase()),
"invalid NoteDb table: %s", t);
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/notedb/PrimaryStorageMigrator.java b/gerrit-server/src/main/java/com/google/gerrit/server/notedb/PrimaryStorageMigrator.java
new file mode 100644
index 0000000..0a5c014
--- /dev/null
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/notedb/PrimaryStorageMigrator.java
@@ -0,0 +1,318 @@
+// Copyright (C) 2017 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.google.gerrit.server.notedb;
+
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static java.util.concurrent.TimeUnit.NANOSECONDS;
+import static java.util.concurrent.TimeUnit.SECONDS;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Stopwatch;
+import com.google.gerrit.common.Nullable;
+import com.google.gerrit.common.TimeUtil;
+import com.google.gerrit.reviewdb.client.Change;
+import com.google.gerrit.reviewdb.client.Project;
+import com.google.gerrit.reviewdb.server.ReviewDb;
+import com.google.gerrit.reviewdb.server.ReviewDbUtil;
+import com.google.gerrit.server.config.AllUsersName;
+import com.google.gerrit.server.config.GerritServerConfig;
+import com.google.gerrit.server.git.GitRepositoryManager;
+import com.google.gerrit.server.git.RepoRefCache;
+import com.google.gerrit.server.notedb.NoteDbChangeState.PrimaryStorage;
+import com.google.gerrit.server.notedb.rebuild.ChangeRebuilder;
+import com.google.gwtorm.server.AtomicUpdate;
+import com.google.gwtorm.server.OrmException;
+import com.google.gwtorm.server.OrmRuntimeException;
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+import com.google.inject.Singleton;
+
+import com.github.rholder.retry.RetryException;
+import com.github.rholder.retry.Retryer;
+import com.github.rholder.retry.RetryerBuilder;
+import com.github.rholder.retry.StopStrategies;
+import com.github.rholder.retry.WaitStrategies;
+
+import org.eclipse.jgit.errors.RepositoryNotFoundException;
+import org.eclipse.jgit.lib.Config;
+import org.eclipse.jgit.lib.Repository;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.sql.Timestamp;
+import java.util.Objects;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+/** Helper to migrate the {@link PrimaryStorage} of individual changes. */
+@Singleton
+public class PrimaryStorageMigrator {
+ private static final Logger log =
+ LoggerFactory.getLogger(PrimaryStorageMigrator.class);
+
+ private final Provider<ReviewDb> db;
+ private final GitRepositoryManager repoManager;
+ private final AllUsersName allUsers;
+ private final ChangeRebuilder rebuilder;
+
+ private final long skewMs;
+ private final long timeoutMs;
+ private final Retryer<NoteDbChangeState> testEnsureRebuiltRetryer;
+
+ @Inject
+ PrimaryStorageMigrator(@GerritServerConfig Config cfg,
+ Provider<ReviewDb> db,
+ GitRepositoryManager repoManager,
+ AllUsersName allUsers,
+ ChangeRebuilder rebuilder) {
+ this(cfg, db, repoManager, allUsers, rebuilder, null);
+ }
+
+ @VisibleForTesting
+ public PrimaryStorageMigrator(Config cfg,
+ Provider<ReviewDb> db,
+ GitRepositoryManager repoManager,
+ AllUsersName allUsers,
+ ChangeRebuilder rebuilder,
+ @Nullable Retryer<NoteDbChangeState> testEnsureRebuiltRetryer) {
+ this.db = db;
+ this.repoManager = repoManager;
+ this.allUsers = allUsers;
+ this.rebuilder = rebuilder;
+ this.testEnsureRebuiltRetryer = testEnsureRebuiltRetryer;
+ skewMs = NoteDbChangeState.getReadOnlySkew(cfg);
+
+ String s = "notedb";
+ timeoutMs = cfg.getTimeUnit(
+ s, null, "primaryStorageMigrationTimeout",
+ MILLISECONDS.convert(60, SECONDS), MILLISECONDS);
+ }
+
+ /**
+ * Migrate a change's primary storage from ReviewDb to NoteDb.
+ * <p>
+ * This method will return only if the primary storage of the change is NoteDb
+ * afterwards. (It may return early if the primary storage was already
+ * NoteDb.)
+ * <p>
+ * If this method throws an exception, then the primary storage of the change
+ * is probably not NoteDb. (It is possible that the primary storage of the
+ * change is NoteDb in this case, but there was an error reading the state.)
+ * Moreover, after an exception, the change may be read-only until a lease
+ * expires. If the caller chooses to retry, they should wait until the
+ * read-only lease expires; this method will fail relatively quickly if called
+ * on a read-only change.
+ * <p>
+ * Note that if the change is read-only after this method throws an exception,
+ * that does not necessarily guarantee that the read-only lease was acquired
+ * during that particular method invocation; this call may have in fact failed
+ * because another thread acquired the lease first.
+ *
+ * @param id change ID.
+ *
+ * @throws OrmException if a ReviewDb-level error occurs.
+ * @throws IOException if a repo-level error occurs.
+ */
+ public void migrateToNoteDbPrimary(Change.Id id)
+ throws OrmException, IOException {
+ // Since there are multiple non-atomic steps in this method, we need to
+ // consider what happens when there is another writer concurrent with the
+ // thread executing this method.
+ //
+ // Let:
+ // * OR = other writer writes noteDbState & new data to ReviewDb (in one
+ // transaction)
+ // * ON = other writer writes to NoteDb
+ // * MRO = migrator sets state to read-only
+ // * MR = ensureRebuilt writes rebuilt noteDbState to ReviewDb (but does not
+ // otherwise update ReviewDb in this transaction)
+ // * MN = ensureRebuilt writes rebuilt state to NoteDb
+ //
+ // Consider all the interleavings of these operations.
+ //
+ // * OR,ON,MRO,...
+ // Other writer completes before migrator begins; this is not a concurrent
+ // write.
+ // * MRO,...,OR,...
+ // OR will fail, since it atomically checks that the noteDbState is not
+ // read-only before proceeding. This results in an exception, but not a
+ // concurrent write.
+ //
+ // Thus all the "interesting" interleavings start with OR,MRO, and differ on
+ // where ON falls relative to MR/MN.
+ //
+ // * OR,MRO,ON,MR,MN
+ // The other NoteDb write succeeds despite the noteDbState being
+ // read-only. Because the read-only state from MRO includes the update
+ // from OR, the change is up-to-date at this point. Thus MR,MN is a no-op.
+ // The end result is an up-to-date, read-only change.
+ //
+ // * OR,MRO,MR,ON,MN
+ // The change is out-of-date when ensureRebuilt begins, because OR
+ // succeeded but the corresponding ON has not happened yet. ON will
+ // succeed, because there have been no intervening NoteDb writes. MN will
+ // fail, because ON updated the state in NoteDb to something other than
+ // what MR claimed. This leaves the change in an out-of-date, read-only
+ // state.
+ //
+ // If this method threw an exception in this case, the change would
+ // eventually switch back to read-write when the read-only lease expires,
+ // so this situation is recoverable. However, it would be inconvenient for
+ // a change to be read-only for so long.
+ //
+ // Thus, as an optimization, we have a retry loop that attempts
+ // ensureRebuilt while still holding the same read-only lease. This
+ // effectively results in the interleaving OR,MR,ON,MR,MN; in contrast
+ // with the previous case, here, MR/MN actually rebuilds the change. In
+ // the case of a write failure, MR/MN might fail and get retried again. If
+ // it exceeds the maximum number of retries, an exception is thrown.
+ //
+ // * OR,MRO,MR,MN,ON
+ // The change is out-of-date when ensureRebuilt begins. The change is
+ // rebuilt, leaving a new state in NoteDb. ON will fail, because the old
+ // NoteDb state has changed since the ref state was read when the update
+ // began (prior to OR). This results in an exception from ON, but the end
+ // result is still an up-to-date, read-only change. The end user that
+ // initiated the other write observes an error, but this is no different
+ // from other errors that need retrying, e.g. due to a backend write
+ // failure.
+
+ Stopwatch sw = Stopwatch.createStarted();
+ Change readOnlyChange = setReadOnly(id); // MRO
+ if (readOnlyChange == null) {
+ return; // Already migrated.
+ }
+
+ NoteDbChangeState rebuiltState;
+ try {
+ // MR,MN
+ rebuiltState = ensureRebuiltRetryer(sw).call(
+ () -> ensureRebuilt(
+ readOnlyChange.getProject(), id,
+ NoteDbChangeState.parse(readOnlyChange)));
+ } catch (RetryException | ExecutionException e) {
+ throw new OrmException(e);
+ }
+
+ // At this point, the noteDbState in ReviewDb is read-only, and it is
+ // guaranteed to match the state actually in NoteDb. Now it is safe to set
+ // the primary storage to NoteDb.
+
+ setPrimaryStorageNoteDb(id, rebuiltState);
+ log.info("Migrated change {} to NoteDb primary in {}ms", id,
+ sw.elapsed(MILLISECONDS));
+ }
+
+ private Change setReadOnly(Change.Id id) throws OrmException {
+ AtomicBoolean alreadyMigrated = new AtomicBoolean(false);
+ Change result = db().changes().atomicUpdate(id, new AtomicUpdate<Change>() {
+ @Override
+ public Change update(Change change) {
+ NoteDbChangeState state = NoteDbChangeState.parse(change);
+ if (state == null) {
+ // Could rebuild the change here, but that's more complexity, and this
+ // really shouldn't happen.
+ throw new OrmRuntimeException(
+ "change " + id + " has no note_db_state; rebuild it first");
+ }
+ // If the change is already read-only, then the lease is held by another
+ // (likely failed) migrator thread. Fail early, as we can't take over
+ // the lease.
+ NoteDbChangeState.checkNotReadOnly(change, skewMs);
+ if (state.getPrimaryStorage() != PrimaryStorage.NOTE_DB) {
+ Timestamp now = TimeUtil.nowTs();
+ Timestamp until = new Timestamp(now.getTime() + timeoutMs);
+ change.setNoteDbState(state.withReadOnlyUntil(until).toString());
+ } else {
+ alreadyMigrated.set(true);
+ }
+ return change;
+ }
+ });
+ return alreadyMigrated.get() ? null : result;
+ }
+
+ private Retryer<NoteDbChangeState> ensureRebuiltRetryer(Stopwatch sw) {
+ if (testEnsureRebuiltRetryer != null) {
+ return testEnsureRebuiltRetryer;
+ }
+ // Retry the ensureRebuilt step with backoff until half the timeout has
+ // expired, leaving the remaining half for the rest of the steps.
+ long remainingNanos =
+ (MILLISECONDS.toNanos(timeoutMs) / 2) - sw.elapsed(NANOSECONDS);
+ remainingNanos = Math.max(remainingNanos, 0);
+ return RetryerBuilder.<NoteDbChangeState>newBuilder()
+ .retryIfException(
+ e -> (e instanceof IOException) || (e instanceof OrmException))
+ .withWaitStrategy(
+ WaitStrategies.join(
+ WaitStrategies.exponentialWait(250, MILLISECONDS),
+ WaitStrategies.randomWait(50, MILLISECONDS)))
+ .withStopStrategy(
+ StopStrategies.stopAfterDelay(remainingNanos, NANOSECONDS))
+ .build();
+ }
+
+ private NoteDbChangeState ensureRebuilt(Project.NameKey project, Change.Id id,
+ NoteDbChangeState readOnlyState)
+ throws IOException, OrmException, RepositoryNotFoundException {
+ try (Repository changeRepo = repoManager.openRepository(project);
+ Repository allUsersRepo = repoManager.openRepository(allUsers)) {
+ if (!readOnlyState.isUpToDate(
+ new RepoRefCache(changeRepo), new RepoRefCache(allUsersRepo))) {
+ NoteDbUpdateManager.Result r =
+ rebuilder.rebuildEvenIfReadOnly(db(), id);
+ checkState(
+ r.newState().getReadOnlyUntil()
+ .equals(readOnlyState.getReadOnlyUntil()),
+ "state after rebuilding has different read-only lease: %s != %s",
+ r.newState(), readOnlyState);
+ readOnlyState = r.newState();
+ }
+ }
+ return readOnlyState;
+ }
+
+ private void setPrimaryStorageNoteDb(Change.Id id,
+ NoteDbChangeState expectedState) throws OrmException {
+ db().changes().atomicUpdate(id, new AtomicUpdate<Change>() {
+ @Override
+ public Change update(Change change) {
+ NoteDbChangeState state = NoteDbChangeState.parse(change);
+ if (!Objects.equals(state, expectedState)) {
+ throw new OrmRuntimeException(badState(state, expectedState));
+ }
+ Timestamp until = state.getReadOnlyUntil().get();
+ if (TimeUtil.nowTs().after(until)) {
+ throw new OrmRuntimeException(
+ "read-only lease on change " + id + " expired at " + until);
+ }
+ change.setNoteDbState(NoteDbChangeState.NOTE_DB_PRIMARY_STATE);
+ return change;
+ }
+ });
+ }
+
+ private ReviewDb db() {
+ return ReviewDbUtil.unwrapDb(db.get());
+ }
+
+ private String badState(NoteDbChangeState actual,
+ NoteDbChangeState expected) {
+ return "state changed unexpectedly: " + actual + " != " + expected;
+ }
+}
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/schema/SchemaVersion.java b/gerrit-server/src/main/java/com/google/gerrit/server/schema/SchemaVersion.java
index 142c60e..2c81c56 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/schema/SchemaVersion.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/schema/SchemaVersion.java
@@ -36,7 +36,7 @@
/** A version of the database schema. */
public abstract class SchemaVersion {
/** The current schema version. */
- public static final Class<Schema_140> C = Schema_140.class;
+ public static final Class<Schema_141> C = Schema_141.class;
public static int getBinaryVersion() {
return guessVersion(C);
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_141.java b/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_141.java
new file mode 100644
index 0000000..c081ea9
--- /dev/null
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_141.java
@@ -0,0 +1,26 @@
+// Copyright (C) 2017 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.google.gerrit.server.schema;
+
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+
+/** Add status field to account. */
+public class Schema_141 extends SchemaVersion {
+ @Inject
+ Schema_141(Provider<Schema_140> prior) {
+ super(prior);
+ }
+}
diff --git a/gerrit-server/src/main/prolog/BUCK b/gerrit-server/src/main/prolog/BUCK
deleted file mode 100644
index 09a6553..0000000
--- a/gerrit-server/src/main/prolog/BUCK
+++ /dev/null
@@ -1,8 +0,0 @@
-include_defs('//lib/prolog/prolog.defs')
-
-prolog_cafe_library(
- name = 'common',
- srcs = ['gerrit_common.pl'],
- deps = ['//gerrit-server:server'],
- visibility = ['PUBLIC'],
-)
diff --git a/gerrit-server/src/test/java/com/google/gerrit/server/query/change/AbstractQueryChangesTest.java b/gerrit-server/src/test/java/com/google/gerrit/server/query/change/AbstractQueryChangesTest.java
index bc107ca..64a71db 100644
--- a/gerrit-server/src/test/java/com/google/gerrit/server/query/change/AbstractQueryChangesTest.java
+++ b/gerrit-server/src/test/java/com/google/gerrit/server/query/change/AbstractQueryChangesTest.java
@@ -69,7 +69,6 @@
import com.google.gerrit.server.change.ChangeTriplet;
import com.google.gerrit.server.change.PatchSetInserter;
import com.google.gerrit.server.config.AllUsersName;
-import com.google.gerrit.server.edit.ChangeEditModifier;
import com.google.gerrit.server.git.BatchUpdate;
import com.google.gerrit.server.git.validators.CommitValidators;
import com.google.gerrit.server.index.IndexConfig;
@@ -138,7 +137,6 @@
@Inject protected ChangeQueryBuilder queryBuilder;
@Inject protected GerritApi gApi;
@Inject protected IdentifiedUser.GenericFactory userFactory;
- @Inject protected ChangeEditModifier changeEditModifier;
@Inject protected ChangeIndexCollection indexes;
@Inject protected ChangeIndexer indexer;
@Inject protected IndexConfig indexConfig;
@@ -1581,25 +1579,27 @@
Account.Id user2 = createAccount("user2");
TestRepository<Repo> repo = createProject("repo");
Change change1 = insert(repo, newChange(repo));
- ChangeNotes notes1 =
- notesFactory.create(db, change1.getProject(), change1.getId());
- PatchSet ps1 = psUtil.get(db, notes1, change1.currentPatchSetId());
+ String changeId1 = change1.getKey().get();
Change change2 = insert(repo, newChange(repo));
- ChangeNotes notes2 =
- notesFactory.create(db, change2.getProject(), change2.getId());
- PatchSet ps2 = psUtil.get(db, notes2, change2.currentPatchSetId());
+ String changeId2 = change2.getKey().get();
requestContext.setContext(newRequestContext(user1));
assertQuery("has:edit");
- assertThat(changeEditModifier.createEdit(change1, ps1))
- .isEqualTo(RefUpdate.Result.NEW);
- assertThat(changeEditModifier.createEdit(change2, ps2))
- .isEqualTo(RefUpdate.Result.NEW);
+ gApi.changes()
+ .id(changeId1)
+ .edit()
+ .create();
+ gApi.changes()
+ .id(changeId2)
+ .edit()
+ .create();
requestContext.setContext(newRequestContext(user2));
assertQuery("has:edit");
- assertThat(changeEditModifier.createEdit(change2, ps2))
- .isEqualTo(RefUpdate.Result.NEW);
+ gApi.changes()
+ .id(changeId2)
+ .edit()
+ .create();
requestContext.setContext(newRequestContext(user1));
assertQuery("has:edit", change2, change1);
@@ -1698,13 +1698,16 @@
Project.NameKey project = new Project.NameKey("repo");
TestRepository<Repo> repo = createProject(project.get());
Change change = insert(repo, newChange(repo));
+ String changeId = change.getKey().get();
ChangeNotes notes =
notesFactory.create(db, change.getProject(), change.getId());
PatchSet ps = psUtil.get(db, notes, change.currentPatchSetId());
requestContext.setContext(newRequestContext(user));
- assertThat(changeEditModifier.createEdit(change, ps))
- .isEqualTo(RefUpdate.Result.NEW);
+ gApi.changes()
+ .id(changeId)
+ .edit()
+ .create();
assertQuery("has:edit", change);
assertThat(indexer.reindexIfStale(project, change.getId()).get()).isFalse();
@@ -1734,17 +1737,17 @@
Change change = insert(repo, newChangeForCommit(repo, commit));
Change.Id id = change.getId();
int c = id.get();
- ChangeNotes notes =
- notesFactory.create(db, change.getProject(), change.getId());
- PatchSet ps = psUtil.get(db, notes, change.currentPatchSetId());
+ String changeId = change.getKey().get();
requestContext.setContext(newRequestContext(user));
// Ensure one of each type of supported ref is present for the change. If
// any more refs are added, update this test to reflect them.
// Edit
- assertThat(changeEditModifier.createEdit(change, ps))
- .isEqualTo(RefUpdate.Result.NEW);
+ gApi.changes()
+ .id(changeId)
+ .edit()
+ .create();
// Star
gApi.accounts()
diff --git a/gerrit-sshd/BUCK b/gerrit-sshd/BUCK
deleted file mode 100644
index fcb844f..0000000
--- a/gerrit-sshd/BUCK
+++ /dev/null
@@ -1,59 +0,0 @@
-SRCS = glob(['src/main/java/**/*.java'])
-
-java_library(
- name = 'sshd',
- srcs = SRCS,
- deps = [
- '//gerrit-extension-api:api',
- '//gerrit-cache-h2:cache-h2',
- '//gerrit-common:annotations',
- '//gerrit-common:server',
- '//gerrit-lucene:lucene',
- '//gerrit-patch-jgit:server',
- '//gerrit-reviewdb:server',
- '//gerrit-server:server',
- '//gerrit-util-cli:cli',
- '//lib:args4j',
- '//lib:gson',
- '//lib:guava',
- '//lib:gwtorm',
- '//lib:jsch',
- '//lib/auto:auto-value',
- '//lib/commons:codec',
- '//lib/dropwizard:dropwizard-core',
- '//lib/guice:guice',
- '//lib/guice:guice-assistedinject',
- '//lib/guice:guice-servlet', # SSH should not depend on servlet
- '//lib/jgit/org.eclipse.jgit:jgit',
- '//lib/jgit/org.eclipse.jgit.archive:jgit-archive',
- '//lib/log:api',
- '//lib/log:log4j',
- '//lib/mina:core',
- '//lib/mina:sshd',
- ],
- provided_deps = [
- '//lib/bouncycastle:bcprov',
- '//lib:servlet-api-3_1',
- ],
- visibility = ['PUBLIC'],
-)
-
-java_sources(
- name = 'sshd-src',
- srcs = SRCS,
- visibility = ['PUBLIC'],
-)
-
-java_test(
- name = 'sshd_tests',
- srcs = glob(
- ['src/test/java/**/*.java'],
- ),
- deps = [
- ':sshd',
- '//gerrit-extension-api:api',
- '//gerrit-server:server',
- '//lib:truth',
- '//lib/mina:sshd',
- ],
-)
diff --git a/gerrit-test-util/src/main/java/com/google/gerrit/extensions/common/CommitInfoSubject.java b/gerrit-test-util/src/main/java/com/google/gerrit/extensions/common/CommitInfoSubject.java
new file mode 100644
index 0000000..9af2e1f
--- /dev/null
+++ b/gerrit-test-util/src/main/java/com/google/gerrit/extensions/common/CommitInfoSubject.java
@@ -0,0 +1,66 @@
+// Copyright (C) 2017 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.google.gerrit.extensions.common;
+
+import static com.google.common.truth.Truth.assertAbout;
+
+import com.google.common.truth.FailureStrategy;
+import com.google.common.truth.StringSubject;
+import com.google.common.truth.Subject;
+import com.google.common.truth.SubjectFactory;
+import com.google.common.truth.Truth;
+import com.google.gerrit.truth.ListSubject;
+
+public class CommitInfoSubject extends Subject<CommitInfoSubject, CommitInfo> {
+
+ private static final SubjectFactory<CommitInfoSubject, CommitInfo>
+ COMMIT_INFO_SUBJECT_FACTORY =
+ new SubjectFactory<CommitInfoSubject, CommitInfo>() {
+ @Override
+ public CommitInfoSubject getSubject(FailureStrategy failureStrategy,
+ CommitInfo commitInfo) {
+ return new CommitInfoSubject(failureStrategy, commitInfo);
+ }
+ };
+
+ public static CommitInfoSubject assertThat(CommitInfo commitInfo) {
+ return assertAbout(COMMIT_INFO_SUBJECT_FACTORY)
+ .that(commitInfo);
+ }
+
+ private CommitInfoSubject(FailureStrategy failureStrategy,
+ CommitInfo commitInfo) {
+ super(failureStrategy, commitInfo);
+ }
+
+ public StringSubject commit() {
+ isNotNull();
+ CommitInfo commitInfo = actual();
+ return Truth.assertThat(commitInfo.commit).named("commit");
+ }
+
+ public ListSubject<CommitInfoSubject, CommitInfo> parents() {
+ isNotNull();
+ CommitInfo commitInfo = actual();
+ return ListSubject.assertThat(commitInfo.parents,
+ CommitInfoSubject::assertThat).named("parents");
+ }
+
+ public GitPersonSubject committer() {
+ isNotNull();
+ CommitInfo commitInfo = actual();
+ return GitPersonSubject.assertThat(commitInfo.committer).named("committer");
+ }
+}
diff --git a/gerrit-test-util/src/main/java/com/google/gerrit/extensions/common/EditInfoSubject.java b/gerrit-test-util/src/main/java/com/google/gerrit/extensions/common/EditInfoSubject.java
new file mode 100644
index 0000000..cf71ca1
--- /dev/null
+++ b/gerrit-test-util/src/main/java/com/google/gerrit/extensions/common/EditInfoSubject.java
@@ -0,0 +1,67 @@
+// Copyright (C) 2017 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.google.gerrit.extensions.common;
+
+import static com.google.common.truth.Truth.assertAbout;
+
+import com.google.common.truth.FailureStrategy;
+import com.google.common.truth.StringSubject;
+import com.google.common.truth.Subject;
+import com.google.common.truth.SubjectFactory;
+import com.google.common.truth.Truth;
+import com.google.gerrit.truth.OptionalSubject;
+
+import java.util.Optional;
+
+public class EditInfoSubject extends Subject<EditInfoSubject, EditInfo> {
+
+ private static final SubjectFactory<EditInfoSubject, EditInfo>
+ EDIT_INFO_SUBJECT_FACTORY =
+ new SubjectFactory<EditInfoSubject, EditInfo>() {
+ @Override
+ public EditInfoSubject getSubject(FailureStrategy failureStrategy,
+ EditInfo editInfo) {
+ return new EditInfoSubject(failureStrategy, editInfo);
+ }
+ };
+
+ public static EditInfoSubject assertThat(EditInfo editInfo) {
+ return assertAbout(EDIT_INFO_SUBJECT_FACTORY)
+ .that(editInfo);
+ }
+
+ @SuppressWarnings("OptionalUsedAsFieldOrParameterType")
+ public static OptionalSubject<EditInfoSubject, EditInfo> assertThat(
+ Optional<EditInfo> editInfoOptional) {
+ return OptionalSubject.assertThat(editInfoOptional,
+ EditInfoSubject::assertThat);
+ }
+
+ private EditInfoSubject(FailureStrategy failureStrategy, EditInfo editInfo) {
+ super(failureStrategy, editInfo);
+ }
+
+ public CommitInfoSubject commit() {
+ isNotNull();
+ EditInfo editInfo = actual();
+ return CommitInfoSubject.assertThat(editInfo.commit).named("commit");
+ }
+
+ public StringSubject baseRevision() {
+ isNotNull();
+ EditInfo editInfo = actual();
+ return Truth.assertThat(editInfo.baseRevision).named("baseRevision");
+ }
+}
diff --git a/gerrit-test-util/src/main/java/com/google/gerrit/extensions/common/GitPersonSubject.java b/gerrit-test-util/src/main/java/com/google/gerrit/extensions/common/GitPersonSubject.java
new file mode 100644
index 0000000..3782e94
--- /dev/null
+++ b/gerrit-test-util/src/main/java/com/google/gerrit/extensions/common/GitPersonSubject.java
@@ -0,0 +1,54 @@
+// Copyright (C) 2017 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.google.gerrit.extensions.common;
+
+import static com.google.common.truth.Truth.assertAbout;
+
+import com.google.common.truth.ComparableSubject;
+import com.google.common.truth.FailureStrategy;
+import com.google.common.truth.Subject;
+import com.google.common.truth.SubjectFactory;
+import com.google.common.truth.Truth;
+
+import java.sql.Timestamp;
+
+public class GitPersonSubject extends Subject<GitPersonSubject, GitPerson> {
+
+ private static final SubjectFactory<GitPersonSubject, GitPerson>
+ GIT_PERSON_SUBJECT_FACTORY =
+ new SubjectFactory<GitPersonSubject, GitPerson>() {
+ @Override
+ public GitPersonSubject getSubject(FailureStrategy failureStrategy,
+ GitPerson gitPerson) {
+ return new GitPersonSubject(failureStrategy, gitPerson);
+ }
+ };
+
+ public static GitPersonSubject assertThat(GitPerson gitPerson) {
+ return assertAbout(GIT_PERSON_SUBJECT_FACTORY)
+ .that(gitPerson);
+ }
+
+ private GitPersonSubject(FailureStrategy failureStrategy,
+ GitPerson gitPerson) {
+ super(failureStrategy, gitPerson);
+ }
+
+ public ComparableSubject<?, Timestamp> creationDate() {
+ isNotNull();
+ GitPerson gitPerson = actual();
+ return Truth.assertThat(gitPerson.date).named("creationDate");
+ }
+}
diff --git a/gerrit-test-util/src/main/java/com/google/gerrit/extensions/restapi/BinaryResultSubject.java b/gerrit-test-util/src/main/java/com/google/gerrit/extensions/restapi/BinaryResultSubject.java
new file mode 100644
index 0000000..15cd16c
--- /dev/null
+++ b/gerrit-test-util/src/main/java/com/google/gerrit/extensions/restapi/BinaryResultSubject.java
@@ -0,0 +1,73 @@
+// Copyright (C) 2017 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.google.gerrit.extensions.restapi;
+
+import static com.google.common.truth.Truth.assertAbout;
+
+import com.google.common.truth.FailureStrategy;
+import com.google.common.truth.PrimitiveByteArraySubject;
+import com.google.common.truth.Subject;
+import com.google.common.truth.SubjectFactory;
+import com.google.common.truth.Truth;
+import com.google.gerrit.truth.OptionalSubject;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Optional;
+
+public class BinaryResultSubject
+ extends Subject<BinaryResultSubject, BinaryResult> {
+
+ private static final SubjectFactory<BinaryResultSubject, BinaryResult>
+ BINARY_RESULT_SUBJECT_FACTORY =
+ new SubjectFactory<BinaryResultSubject, BinaryResult>() {
+ @Override
+ public BinaryResultSubject getSubject(FailureStrategy failureStrategy,
+ BinaryResult binaryResult) {
+ return new BinaryResultSubject(failureStrategy,
+ binaryResult);
+ }
+ };
+
+ public static BinaryResultSubject assertThat(BinaryResult binaryResult) {
+ return assertAbout(BINARY_RESULT_SUBJECT_FACTORY)
+ .that(binaryResult);
+ }
+
+ @SuppressWarnings("OptionalUsedAsFieldOrParameterType")
+ public static OptionalSubject<BinaryResultSubject, BinaryResult> assertThat(
+ Optional<BinaryResult> binaryResultOptional) {
+ return OptionalSubject.assertThat(binaryResultOptional,
+ BinaryResultSubject::assertThat);
+ }
+
+ private BinaryResultSubject(FailureStrategy failureStrategy,
+ BinaryResult binaryResult) {
+ super(failureStrategy, binaryResult);
+ }
+
+ public PrimitiveByteArraySubject bytes() throws IOException {
+ isNotNull();
+ // We shouldn't close the BinaryResult within this method as it might still
+ // be used afterwards. Besides, closing it doesn't have an effect for most
+ // implementations of a BinaryResult.
+ @SuppressWarnings("resource")
+ BinaryResult binaryResult = actual();
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ binaryResult.writeTo(byteArrayOutputStream);
+ byte[] bytes = byteArrayOutputStream.toByteArray();
+ return Truth.assertThat(bytes);
+ }
+}
diff --git a/gerrit-test-util/src/main/java/com/google/gerrit/truth/OptionalSubject.java b/gerrit-test-util/src/main/java/com/google/gerrit/truth/OptionalSubject.java
new file mode 100644
index 0000000..68a73fb
--- /dev/null
+++ b/gerrit-test-util/src/main/java/com/google/gerrit/truth/OptionalSubject.java
@@ -0,0 +1,105 @@
+// Copyright (C) 2017 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.google.gerrit.truth;
+
+import static com.google.common.truth.Truth.assertAbout;
+
+import com.google.common.truth.DefaultSubject;
+import com.google.common.truth.FailureStrategy;
+import com.google.common.truth.Subject;
+import com.google.common.truth.SubjectFactory;
+import com.google.common.truth.Truth;
+
+import java.util.Optional;
+import java.util.function.Function;
+
+@SuppressWarnings("OptionalUsedAsFieldOrParameterType")
+public class OptionalSubject<S extends Subject<S, ? super T>, T>
+ extends Subject<OptionalSubject<S, T>, Optional<T>> {
+
+ private final Function<? super T, ? extends S> valueAssertThatFunction;
+
+ public static <S extends Subject<S, ? super T>, T> OptionalSubject<S, T>
+ assertThat(Optional<T> optional,
+ Function<? super T, ? extends S> elementAssertThatFunction) {
+ OptionalSubjectFactory<S, T> optionalSubjectFactory =
+ new OptionalSubjectFactory<>(elementAssertThatFunction);
+ return assertAbout(optionalSubjectFactory).that(optional);
+ }
+
+ public static OptionalSubject<DefaultSubject, ?> assertThat(
+ Optional<?> optional) {
+ // Unfortunately, we need to cast to DefaultSubject as Truth.assertThat()
+ // only returns Subject<DefaultSubject, Object>. There shouldn't be a way
+ // for that method not to return a DefaultSubject because the generic type
+ // definitions of a Subject are quite strict.
+ Function<Object, DefaultSubject> valueAssertThatFunction =
+ value -> (DefaultSubject) Truth.assertThat(value);
+ return assertThat(optional, valueAssertThatFunction);
+ }
+
+ private OptionalSubject(FailureStrategy failureStrategy, Optional<T> optional,
+ Function<? super T, ? extends S> valueAssertThatFunction) {
+ super(failureStrategy, optional);
+ this.valueAssertThatFunction = valueAssertThatFunction;
+ }
+
+ public void isPresent() {
+ isNotNull();
+ Optional<T> optional = actual();
+ if (!optional.isPresent()) {
+ fail("has a value");
+ }
+ }
+
+ public void isAbsent() {
+ isNotNull();
+ Optional<T> optional = actual();
+ if (optional.isPresent()) {
+ fail("does not have a value");
+ }
+ }
+
+ public void isEmpty() {
+ isAbsent();
+ }
+
+ @SuppressWarnings("OptionalGetWithoutIsPresent")
+ public S value() {
+ isNotNull();
+ isPresent();
+ Optional<T> optional = actual();
+ return valueAssertThatFunction.apply(optional.get());
+ }
+
+ private static class OptionalSubjectFactory<S extends Subject<S, ? super T>,
+ T> extends SubjectFactory<OptionalSubject<S, T>, Optional<T>> {
+
+ private Function<? super T, ? extends S> valueAssertThatFunction;
+
+ OptionalSubjectFactory(
+ Function<? super T, ? extends S> valueAssertThatFunction) {
+ this.valueAssertThatFunction = valueAssertThatFunction;
+ }
+
+ @Override
+ public OptionalSubject<S, T> getSubject(FailureStrategy failureStrategy,
+ Optional<T> optional) {
+ return new OptionalSubject<>(failureStrategy, optional,
+ valueAssertThatFunction);
+ }
+
+ }
+}
diff --git a/gerrit-util-cli/BUCK b/gerrit-util-cli/BUCK
deleted file mode 100644
index 8cdc2dc..0000000
--- a/gerrit-util-cli/BUCK
+++ /dev/null
@@ -1,13 +0,0 @@
-java_library(
- name = 'cli',
- srcs = glob(['src/main/java/**/*.java']),
- deps = [
- '//gerrit-common:annotations',
- '//gerrit-common:server',
- '//lib:args4j',
- '//lib:guava',
- '//lib/guice:guice',
- '//lib/guice:guice-assistedinject',
- ],
- visibility = ['PUBLIC'],
-)
diff --git a/gerrit-util-http/BUCK b/gerrit-util-http/BUCK
deleted file mode 100644
index 79ef836..0000000
--- a/gerrit-util-http/BUCK
+++ /dev/null
@@ -1,39 +0,0 @@
-java_library(
- name = 'http',
- srcs = glob(['src/main/java/**/*.java']),
- provided_deps = ['//lib:servlet-api-3_1'],
- visibility = ['PUBLIC'],
-)
-
-TESTUTIL_SRCS = glob(['src/test/**/testutil/**/*.java'])
-
-java_library(
- name = 'testutil',
- srcs = TESTUTIL_SRCS,
- deps = [
- '//gerrit-extension-api:api',
- '//lib:guava',
- '//lib:servlet-api-3_1',
- '//lib/httpcomponents:httpclient',
- '//lib/jgit/org.eclipse.jgit:jgit',
- ],
- visibility = ['PUBLIC'],
-)
-
-java_test(
- name = 'http_tests',
- srcs = glob(
- ['src/test/java/**/*.java'],
- excludes = TESTUTIL_SRCS,
- ),
- deps = [
- ':http',
- ':testutil',
- '//lib:junit',
- '//lib:servlet-api-3_1',
- '//lib:truth',
- '//lib/easymock:easymock',
- ],
- # TODO(sop) Remove after Buck supports Eclipse
- visibility = ['//tools/eclipse:classpath'],
-)
diff --git a/gerrit-util-ssl/BUCK b/gerrit-util-ssl/BUCK
deleted file mode 100644
index 068f34c..0000000
--- a/gerrit-util-ssl/BUCK
+++ /dev/null
@@ -1,5 +0,0 @@
-java_library(
- name = 'ssl',
- srcs = glob(['src/main/java/**/*.java']),
- visibility = ['PUBLIC'],
-)
diff --git a/gerrit-war/BUCK b/gerrit-war/BUCK
deleted file mode 100644
index 5dd1b04..0000000
--- a/gerrit-war/BUCK
+++ /dev/null
@@ -1,77 +0,0 @@
-include_defs('//tools/git.defs')
-
-java_library(
- name = 'init',
- srcs = glob(['src/main/java/**/*.java']),
- deps = [
- '//gerrit-cache-h2:cache-h2',
- '//gerrit-elasticsearch:elasticsearch',
- '//gerrit-extension-api:api',
- '//gerrit-gpg:gpg',
- '//gerrit-httpd:httpd',
- '//gerrit-lucene:lucene',
- '//gerrit-oauth:oauth',
- '//gerrit-openid:openid',
- '//gerrit-pgm:http',
- '//gerrit-pgm:init',
- '//gerrit-pgm:init-api',
- '//gerrit-pgm:util',
- '//gerrit-reviewdb:server',
- '//gerrit-server:server',
- '//gerrit-server/src/main/prolog:common',
- '//gerrit-sshd:sshd',
- '//lib:guava',
- '//lib:gwtorm',
- '//lib/guice:guice',
- '//lib/guice:guice-servlet',
- '//lib/jgit/org.eclipse.jgit:jgit',
- '//lib/log:api',
- ],
- provided_deps = ['//lib:servlet-api-3_1'],
- visibility = [
- '//:',
- '//gerrit-gwtdebug:gwtdebug',
- '//tools/eclipse:classpath',
- ],
-)
-
-genrule(
- name = 'webapp_assets',
- cmd = 'cd src/main/webapp; zip -qr $OUT .',
- srcs = glob(['src/main/webapp/**/*']),
- out = 'webapp_assets.zip',
- visibility = ['//:'],
-)
-
-genrule(
- name = 'log4j-config__jar',
- cmd = 'jar cf $OUT -C src/main/resources .',
- srcs = ['src/main/resources/log4j.properties'],
- out = 'log4j-config.jar',
-)
-
-prebuilt_jar(
- name = 'log4j-config',
- binary_jar = ':log4j-config__jar',
- visibility = [
- '//:',
- '//tools/eclipse:classpath',
- ],
-)
-
-prebuilt_jar(
- name = 'version',
- binary_jar = ':gen_version',
- visibility = ['//:'],
-)
-
-genrule(
- name = 'gen_version',
- cmd = ';'.join([
- 'cd $TMP',
- 'mkdir -p com/google/gerrit/common',
- 'echo "%s" >com/google/gerrit/common/Version' % git_describe(),
- 'zip -9Dqr $OUT .',
- ]),
- out = 'version.jar',
-)
diff --git a/lib/BUCK b/lib/BUCK
deleted file mode 100644
index 6d26f9e..0000000
--- a/lib/BUCK
+++ /dev/null
@@ -1,319 +0,0 @@
-include_defs('//lib/maven.defs')
-include_defs('//lib/GUAVA_VERSION')
-
-define_license(name = 'antlr')
-define_license(name = 'Apache1.1')
-define_license(name = 'Apache2.0')
-define_license(name = 'args4j')
-define_license(name = 'asciidoctor')
-define_license(name = 'automaton')
-define_license(name = 'bouncycastle')
-define_license(name = 'CC-BY3.0-unported')
-define_license(name = 'clippy')
-define_license(name = 'codemirror-minified')
-define_license(name = 'codemirror-original')
-define_license(name = 'diffy')
-define_license(name = 'es6-promise')
-define_license(name = 'fetch')
-define_license(name = 'h2')
-define_license(name = 'highlightjs')
-define_license(name = 'icu4j')
-define_license(name = 'jgit')
-define_license(name = 'jsch')
-define_license(name = 'jsoup')
-define_license(name = 'MPL1.1')
-define_license(name = 'moment')
-define_license(name = 'OFL1.1')
-define_license(name = 'ow2')
-define_license(name = 'page.js')
-define_license(name = 'polymer')
-define_license(name = 'postgresql')
-define_license(name = 'prologcafe')
-define_license(name = 'promise-polyfill')
-define_license(name = 'protobuf')
-define_license(name = 'PublicDomain')
-define_license(name = 'silk_icons')
-define_license(name = 'slf4j')
-define_license(name = 'xz')
-
-define_license(name = 'DO_NOT_DISTRIBUTE')
-
-maven_jar(
- name = 'gwtorm_client',
- id = 'com.google.gerrit:gwtorm:1.17',
- bin_sha1 = "97bdc872f00388910c9af70771f07bbb32f1b949",
- src_sha1 = "889e35d7295b1af49161a28daaea9905ffa76a63",
- license = 'Apache2.0',
-)
-
-java_library(
- name = 'gwtorm',
- exported_deps = [':gwtorm_client'],
- deps = [':protobuf'],
- visibility = ['PUBLIC'],
-)
-
-maven_jar(
- name = 'gwtjsonrpc',
- id = 'com.google.gerrit:gwtjsonrpc:1.11',
- bin_sha1 = '0990e7eec9eec3a15661edcf9232acbac4aeacec',
- src_sha1 = 'a682afc46284fb58197a173cb5818770a1e7834a',
- license = 'Apache2.0',
-)
-
-maven_jar(
- name = 'gson',
- id = 'com.google.code.gson:gson:2.7',
- sha1 = '751f548c85fa49f330cecbb1875893f971b33c4e',
- license = 'Apache2.0',
-)
-
-maven_jar(
- name = 'guava',
- id = 'com.google.guava:guava:' + GUAVA_VERSION,
- sha1 = GUAVA_BIN_SHA1,
- license = 'Apache2.0',
-)
-
-maven_jar(
- name = 'guava-retrying',
- id = 'com.github.rholder:guava-retrying:2.0.0',
- sha1 = '974bc0a04a11cc4806f7c20a34703bd23c34e7f4',
- license = 'Apache2.0',
- deps = [':jsr305'],
-)
-
-maven_jar(
- name = 'jsr305',
- id = 'com.google.code.findbugs:jsr305:3.0.1',
- sha1 = 'f7be08ec23c21485b9b5a1cf1654c2ec8c58168d',
- license = 'Apache2.0',
- attach_source = False,
- # Whitelist lib targets that have jsr305 as a dependency. Generally speaking
- # Gerrit core should not depend on these annotations, and instead use
- # equivalent annotations in com.google.gerrit.common.
- visibility = [
- '//gerrit-plugin-api:lib',
- '//lib:guava-retrying',
- '//lib:soy',
- ],
-)
-
-maven_jar(
- name = 'velocity',
- id = 'org.apache.velocity:velocity:1.7',
- sha1 = '2ceb567b8f3f21118ecdec129fe1271dbc09aa7a',
- license = 'Apache2.0',
- deps = [
- '//lib/commons:collections',
- '//lib/commons:lang',
- '//lib/commons:oro',
- ],
- exclude = ['META-INF/LICENSE', 'META-INF/NOTICE'],
-)
-
-maven_jar(
- name = 'jsch',
- id = 'com.jcraft:jsch:0.1.54',
- sha1 = 'da3584329a263616e277e15462b387addd1b208d',
- license = 'jsch',
-)
-
-maven_jar(
- name = 'servlet-api-3_1',
- id = 'org.apache.tomcat:tomcat-servlet-api:8.0.24',
- sha1 = '5d9e2e895e3111622720157d0aa540066d5fce3a',
- license = 'Apache2.0',
- exclude = ['META-INF/NOTICE', 'META-INF/LICENSE'],
-)
-
-maven_jar(
- name = 'args4j',
- id = 'args4j:args4j:2.0.26',
- sha1 = '01ebb18ebb3b379a74207d5af4ea7c8338ebd78b',
- license = 'args4j',
-)
-
-maven_jar(
- name = 'mime-util',
- id = 'eu.medsea.mimeutil:mime-util:2.1.3',
- sha1 = '0c9cfae15c74f62491d4f28def0dff1dabe52a47',
- license = 'Apache2.0',
- exclude = ['LICENSE.txt', 'README.txt'],
- attach_source = False,
-)
-
-maven_jar(
- name = 'juniversalchardet',
- id = 'com.googlecode.juniversalchardet:juniversalchardet:1.0.3',
- sha1 = 'cd49678784c46aa8789c060538e0154013bb421b',
- license = 'MPL1.1',
-)
-
-maven_jar(
- name = 'automaton',
- id = 'dk.brics.automaton:automaton:1.11-8',
- sha1 = '6ebfa65eb431ff4b715a23be7a750cbc4cc96d0f',
- license = 'automaton',
-)
-
-maven_jar(
- name = 'pegdown',
- id = 'org.pegdown:pegdown:1.4.2',
- sha1 = 'd96db502ed832df867ff5d918f05b51ba3879ea7',
- license = 'Apache2.0',
- deps = [':grappa'],
-)
-
-maven_jar(
- name = 'grappa',
- id = 'com.github.parboiled1:grappa:1.0.4',
- sha1 = 'ad4b44b9c305dad7aa1e680d4b5c8eec9c4fd6f5',
- license = 'Apache2.0',
- deps = [
- ':jitescript',
- '//lib/ow2:ow2-asm',
- '//lib/ow2:ow2-asm-analysis',
- '//lib/ow2:ow2-asm-tree',
- '//lib/ow2:ow2-asm-util',
- ],
-)
-
-maven_jar(
- name = 'jitescript',
- id = 'me.qmx.jitescript:jitescript:0.4.0',
- sha1 = '2e35862b0435c1b027a21f3d6eecbe50e6e08d54',
- license = 'Apache2.0',
- visibility = ['//lib:grappa'],
-)
-
-maven_jar(
- name = 'derby',
- id = 'org.apache.derby:derby:10.11.1.1',
- sha1 = 'df4b50061e8e4c348ce243b921f53ee63ba9bbe1',
- license = 'Apache2.0',
- attach_source = False,
-)
-
-maven_jar(
- name = 'h2',
- id = 'com.h2database:h2:1.3.176',
- sha1 = 'fd369423346b2f1525c413e33f8cf95b09c92cbd',
- license = 'h2',
-)
-
-maven_jar(
- name = 'postgresql',
- id = 'org.postgresql:postgresql:9.4.1211.jre7',
- sha1 = '56b01e9e667f408818a6ef06a89598dbab80687d',
- license = 'postgresql',
- attach_source = False,
-)
-
-maven_jar(
- name = 'protobuf',
- # Must match version in gwtorm/pom.xml.
- id = 'com.google.protobuf:protobuf-java:2.5.0',
- bin_sha1 = 'a10732c76bfacdbd633a7eb0f7968b1059a65dfa',
- src_sha1 = '7a27a7fc815e481b367ead5df19b4a71ace4a419',
- license = 'protobuf',
-)
-
-# Test-only dependencies below.
-
-maven_jar(
- name = 'jimfs',
- id = 'com.google.jimfs:jimfs:1.1',
- sha1 = '8fbd0579dc68aba6186935cc1bee21d2f3e7ec1c',
- license = 'DO_NOT_DISTRIBUTE',
- deps = [':guava'],
-)
-
-maven_jar(
- name = 'junit',
- id = 'junit:junit:4.11',
- sha1 = '4e031bb61df09069aeb2bffb4019e7a5034a4ee0',
- license = 'DO_NOT_DISTRIBUTE',
- exported_deps = [':hamcrest-core'],
-)
-
-maven_jar(
- name = 'hamcrest-core',
- id = 'org.hamcrest:hamcrest-core:1.3',
- sha1 = '42a25dc3219429f0e5d060061f71acb49bf010a0',
- license = 'DO_NOT_DISTRIBUTE',
- visibility = ['//lib:junit'],
-)
-
-maven_jar(
- name = 'truth',
- id = 'com.google.truth:truth:0.30',
- sha1 = '9d591b5a66eda81f0b88cf1c748ab8853d99b18b',
- license = 'DO_NOT_DISTRIBUTE',
- exported_deps = [
- ':guava',
- ':junit',
- ],
-)
-
-maven_jar(
- name = 'tukaani-xz',
- id = 'org.tukaani:xz:1.4',
- sha1 = '18a9a2ce6abf32ea1b5fd31dae5210ad93f4e5e3',
- license = 'xz',
- attach_source = False,
- visibility = ['//gerrit-server:server'],
-)
-
-maven_jar(
- name = 'javassist',
- id = 'org.javassist:javassist:3.20.0-GA',
- sha1 = 'a9cbcdfb7e9f86fbc74d3afae65f2248bfbf82a0',
- license = 'DO_NOT_DISTRIBUTE',
-)
-
-maven_jar(
- name = 'blame-cache',
- id = 'com/google/gitiles:blame-cache:0.1-9',
- sha1 = '51d35e6f8bbc2412265066cea9653dd758c95826',
- license = 'Apache2.0',
- repository = GERRIT,
-)
-
-# Keep this version of Soy synchronized with the version used in Gitiles.
-maven_jar(
- name = 'soy',
- id = 'com.google.template:soy:2016-08-09',
- sha1 = '43d33651e95480d515fe26c10a662faafe3ad1e4',
- license = 'Apache2.0',
- deps = [
- ':args4j',
- ':guava',
- ':gson',
- ':icu4j',
- ':jsr305',
- ':protobuf',
- '//lib/guice:guice',
- '//lib/guice:guice-assistedinject',
- '//lib/guice:multibindings',
- '//lib/guice:javax-inject',
- '//lib/ow2:ow2-asm',
- '//lib/ow2:ow2-asm-analysis',
- '//lib/ow2:ow2-asm-commons',
- '//lib/ow2:ow2-asm-util',
- ],
-)
-
-maven_jar(
- name = 'icu4j',
- id = 'com.ibm.icu:icu4j:57.1',
- sha1 = '198ea005f41219f038f4291f0b0e9f3259730e92',
- license = 'icu4j',
-)
-
-maven_jar(
- name = 'errorprone',
- id = 'com.google.errorprone:error_prone_ant:2.0.15',
- sha1 = '607e3866e2ee25b74708c2898f84eac2f5452d2f',
- license = 'Apache2.0',
-)
diff --git a/lib/antlr/BUCK b/lib/antlr/BUCK
deleted file mode 100644
index edf153c..0000000
--- a/lib/antlr/BUCK
+++ /dev/null
@@ -1,48 +0,0 @@
-include_defs('//lib/maven.defs')
-
-VERSION = '3.5.2'
-
-maven_jar(
- name = 'java_runtime',
- id = 'org.antlr:antlr-runtime:' + VERSION,
- sha1 = 'cd9cd41361c155f3af0f653009dcecb08d8b4afd',
- license = 'antlr',
-)
-
-java_binary(
- name = 'antlr-tool',
- main_class = 'org.antlr.Tool',
- deps = [':tool'],
- visibility = ['PUBLIC'],
-)
-
-maven_jar(
- name = 'stringtemplate',
- id = 'org.antlr:stringtemplate:4.0.2',
- sha1 = 'e28e09e2d44d60506a7bcb004d6c23ff35c6ac08',
- license = 'antlr',
- attach_source = False,
- visibility = [],
-)
-
-maven_jar(
- name = 'tool',
- id = 'org.antlr:antlr:' + VERSION,
- sha1 = 'c4a65c950bfc3e7d04309c515b2177c00baf7764',
- license = 'antlr',
- deps = [
- ':java_runtime',
- ':stringtemplate',
- ':antlr27',
- ],
- visibility = [],
-)
-
-maven_jar(
- name = 'antlr27',
- id = 'antlr:antlr:2.7.7',
- sha1 = '83cd2cd674a217ade95a4bb83a8a14f351f48bd0',
- license = 'antlr',
- attach_source = False,
- visibility = [],
-)
diff --git a/lib/asciidoctor/BUCK b/lib/asciidoctor/BUCK
deleted file mode 100644
index 5b4cd6b..0000000
--- a/lib/asciidoctor/BUCK
+++ /dev/null
@@ -1,61 +0,0 @@
-include_defs('//lib/maven.defs')
-
-java_binary(
- name = 'asciidoc',
- main_class = 'AsciiDoctor',
- deps = [':asciidoc_lib'],
- visibility = ['PUBLIC'],
-)
-
-java_library(
- name = 'asciidoc_lib',
- srcs = ['java/AsciiDoctor.java'],
- deps = [
- ':asciidoctor',
- ':jruby',
- '//lib:args4j',
- '//lib:guava',
- '//lib/log:api',
- '//lib/log:nop',
- ],
- visibility = ['//tools/eclipse:classpath'],
-)
-
-java_binary(
- name = 'doc_indexer',
- main_class = 'DocIndexer',
- deps = [':doc_indexer_lib'],
- visibility = ['PUBLIC'],
-)
-
-java_library(
- name = 'doc_indexer_lib',
- srcs = ['java/DocIndexer.java'],
- deps = [
- ':asciidoc_lib',
- '//gerrit-server:constants',
- '//lib:args4j',
- '//lib:guava',
- '//lib/lucene:lucene-analyzers-common',
- '//lib/lucene:lucene-core-and-backward-codecs',
- ],
- visibility = ['//tools/eclipse:classpath'],
-)
-
-maven_jar(
- name = 'asciidoctor',
- id = 'org.asciidoctor:asciidoctorj:1.5.4.1',
- sha1 = 'f7ddfb2bbed2f8da3f9ad0d1a5514f04b4274a5a',
- license = 'asciidoctor',
- visibility = [],
- attach_source = False,
-)
-
-maven_jar(
- name = 'jruby',
- id = 'org.jruby:jruby-complete:9.1.5.0',
- sha1 = '00d0003e99da3c4d830b12c099691ce910c84e39',
- license = 'DO_NOT_DISTRIBUTE',
- visibility = [],
- attach_source = False,
-)
diff --git a/lib/auto/BUCK b/lib/auto/BUCK
deleted file mode 100644
index c186f87..0000000
--- a/lib/auto/BUCK
+++ /dev/null
@@ -1,9 +0,0 @@
-include_defs('//lib/maven.defs')
-
-maven_jar(
- name = 'auto-value',
- id = 'com.google.auto.value:auto-value:1.4-rc1',
- sha1 = '9347939002003a7a3c3af48271fc2c18734528a4',
- license = 'Apache2.0',
- visibility = ['PUBLIC'],
-)
diff --git a/lib/auto/auto_value.defs b/lib/auto/auto_value.defs
deleted file mode 100644
index 4405747..0000000
--- a/lib/auto/auto_value.defs
+++ /dev/null
@@ -1,21 +0,0 @@
-# NOTE: Do not use this file in your build rules; automatically supported by
-# our implementation of java_library.
-
-AUTO_VALUE_DEP = '//lib/auto:auto-value'
-
-# Annotation processor classpath requires transitive dependencies.
-# TODO(dborowitz): Clean this up when buck issue is closed and there is a
-# better supported interface:
-# https://github.com/facebook/buck/issues/85
-AUTO_VALUE_PROCESSOR_DEPS = [
- '//lib:velocity',
- '//lib/auto:auto-value',
- '//lib/commons:collections',
- '//lib/commons:lang',
- '//lib/commons:oro',
-]
-
-AUTO_VALUE_PROCESSORS = [
- 'com.google.auto.value.processor.AutoAnnotationProcessor',
- 'com.google.auto.value.processor.AutoValueProcessor',
-]
diff --git a/lib/bouncycastle/BUCK b/lib/bouncycastle/BUCK
deleted file mode 100644
index f7271b4..0000000
--- a/lib/bouncycastle/BUCK
+++ /dev/null
@@ -1,28 +0,0 @@
-include_defs('//lib/maven.defs')
-
-# This version must match the version that also appears in
-# gerrit-pgm/src/main/resources/com/google/gerrit/pgm/init/libraries.config
-VERSION = '1.56'
-
-maven_jar(
- name = 'bcprov',
- id = 'org.bouncycastle:bcprov-jdk15on:' + VERSION,
- sha1 = 'a153c6f9744a3e9dd6feab5e210e1c9861362ec7',
- license = 'DO_NOT_DISTRIBUTE', #'bouncycastle'
-)
-
-maven_jar(
- name = 'bcpg',
- id = 'org.bouncycastle:bcpg-jdk15on:' + VERSION,
- sha1 = '9c3f2e7072c8cc1152079b5c25291a9f462631f1',
- license = 'DO_NOT_DISTRIBUTE', #'bouncycastle'
- deps = [':bcprov'],
-)
-
-maven_jar(
- name = 'bcpkix',
- id = 'org.bouncycastle:bcpkix-jdk15on:' + VERSION,
- sha1 = '4648af70268b6fdb24674fb1fd7c1fcc73db1231',
- license = 'DO_NOT_DISTRIBUTE', #'bouncycastle'
- deps = [':bcprov'],
-)
diff --git a/lib/codemirror/BUCK b/lib/codemirror/BUCK
deleted file mode 100644
index 040690f..0000000
--- a/lib/codemirror/BUCK
+++ /dev/null
@@ -1,140 +0,0 @@
-include_defs('//lib/maven.defs')
-include_defs('//lib/codemirror/cm.defs')
-
-VERSION = '5.22.0'
-TOP = 'META-INF/resources/webjars/codemirror/%s' % VERSION
-TOP_MINIFIED = 'META-INF/resources/webjars/codemirror-minified/%s' % VERSION
-
-maven_jar(
- name = 'codemirror-minified',
- id = 'org.webjars.npm:codemirror-minified:' + VERSION,
- sha1 = '3e8767c9293614968176fcf66cb873d6eb8b3051',
- attach_source = False,
- license = 'codemirror-minified',
- visibility = [],
-)
-
-maven_jar(
- name = 'codemirror-original',
- id = 'org.webjars.npm:codemirror:' + VERSION,
- sha1 = '879c49085a44f062554a4e4a9ac248b7083d37cf',
- attach_source = False,
- license = 'codemirror-original',
- visibility = [],
-)
-
-DIFF_MATCH_PATCH_TOP = ('META-INF/resources/webjars/google-diff-match-patch/%s'
- % DIFF_MATCH_PATCH_VERSION)
-
-maven_jar(
- name = 'diff-match-patch',
- id = 'org.webjars:google-diff-match-patch:' + DIFF_MATCH_PATCH_VERSION,
- sha1 = '0cf1782dbcb8359d95070da9176059a5a9d37709',
- license = 'Apache2.0',
- attach_source = False,
-)
-
-for archive, suffix, top in [('codemirror-original', '', TOP), ('codemirror-minified', '_r', TOP_MINIFIED)]:
- # Main JavaScript and addons
- genrule(
- name = 'cm' + suffix,
- cmd = ';'.join([
- "echo '/** @license' >$OUT",
- 'unzip -p $(location :%s) %s/LICENSE >>$OUT' % (archive, top),
- "echo '*/' >>$OUT",
- ] +
- ['unzip -p $(location :%s) %s/%s >>$OUT' % (archive, top, n) for n in CM_JS] +
- ['unzip -p $(location :%s) %s/addon/%s >>$OUT' % (archive, top, n)
- for n in CM_ADDONS]
- ),
- out = 'cm%s.js' % suffix,
- )
-
- # Main CSS
- genrule(
- name = 'css' + suffix,
- cmd = ';'.join([
- "echo '/** @license' >$OUT",
- 'unzip -p $(location :%s) %s/LICENSE >>$OUT' % (archive, top),
- "echo '*/' >>$OUT",
- ] +
- ['unzip -p $(location :%s) %s/%s >>$OUT' % (archive, top, n)
- for n in CM_CSS]
- ),
- out = 'cm%s.css' % suffix,
- )
-
- # Modes
- for n in CM_MODES:
- genrule (
- name = 'mode_%s%s' % (n, suffix),
- cmd = ';'.join([
- "echo '/** @license' >$OUT",
- 'unzip -p $(location :%s) %s/LICENSE >>$OUT' % (archive, top),
- "echo '*/' >>$OUT",
- 'unzip -p $(location :%s) %s/mode/%s/%s.js >>$OUT' % (archive, top, n, n),
- ]
- ),
- out = 'mode_%s%s.js' % (n, suffix),
- )
-
- # Themes
- for n in CM_THEMES:
- genrule(
- name = 'theme_%s%s' % (n, suffix),
- cmd = ';'.join([
- "echo '/** @license' >$OUT",
- 'unzip -p $(location :%s) %s/LICENSE >>$OUT' % (archive, top),
- "echo '*/' >>$OUT",
- 'unzip -p $(location :%s) %s/theme/%s.css >>$OUT' % (archive, top, n)
- ]
- ),
- out = 'theme_%s%s.css' % (n, suffix),
- )
-
- # Merge Addon bundled with diff-match-patch
- genrule(
- name = 'addon_merge_with_diff_match_patch%s' % suffix,
- cmd = ';'.join([
- "echo '/** @license' >$OUT",
- 'unzip -p $(location :%s) %s/LICENSE >>$OUT' % (archive, top),
- "echo '*/\n' >>$OUT",
- "echo '// The google-diff-match-patch library is from https://repo1.maven.org/maven2/org/webjars/google-diff-match-patch/%s/google-diff-match-patch-%s.jar\n' >> $OUT" % (DIFF_MATCH_PATCH_VERSION, DIFF_MATCH_PATCH_VERSION),
- "echo '/** @license' >>$OUT",
- 'cat $(location //lib:LICENSE-Apache2.0) >>$OUT',
- "echo '*/' >>$OUT",
- 'unzip -p $(location :diff-match-patch) %s/diff_match_patch.js >>$OUT' % DIFF_MATCH_PATCH_TOP,
- "echo ';' >> $OUT",
- 'unzip -p $(location :%s) %s/addon/merge/merge.js >>$OUT' % (archive, top)
- ]
- ),
- out = 'addon_merge_with_diff_match_patch%s.js' % suffix,
- )
-
- # Jar packaging
- genrule(
- name = 'jar' + suffix,
- cmd = ';'.join([
- 'cd $TMP',
- 'mkdir -p net/codemirror/{addon,lib,mode,theme}',
- 'cp $(location :css%s) net/codemirror/lib/cm.css' % suffix,
- 'cp $(location :cm%s) net/codemirror/lib/cm.js' % suffix]
- + ['cp $(location :mode_%s%s) net/codemirror/mode/%s.js' % (n, suffix, n)
- for n in CM_MODES]
- + ['cp $(location :theme_%s%s) net/codemirror/theme/%s.css' % (n, suffix, n)
- for n in CM_THEMES]
- + ['cp $(location :addon_merge_with_diff_match_patch%s) net/codemirror/addon/merge_bundled.js' % suffix]
- + ['zip -qr $OUT net/codemirror/{addon,lib,mode,theme}']),
- out = 'codemirror%s.jar' % suffix,
- )
-
- prebuilt_jar(
- name = 'codemirror' + suffix,
- binary_jar = ':jar%s' % suffix,
- deps = [
- ':jar' + suffix,
- '//lib:LICENSE-' + archive,
- ],
- visibility = ['PUBLIC'],
- )
-
diff --git a/lib/codemirror/cm.defs b/lib/codemirror/cm.defs
deleted file mode 100644
index bfb4f7a..0000000
--- a/lib/codemirror/cm.defs
+++ /dev/null
@@ -1,215 +0,0 @@
-CM_CSS = [
- 'lib/codemirror.css',
- 'addon/dialog/dialog.css',
- 'addon/merge/merge.css',
- 'addon/scroll/simplescrollbars.css',
- 'addon/search/matchesonscrollbar.css',
- 'addon/lint/lint.css',
-]
-
-CM_JS = [
- 'lib/codemirror.js',
- 'mode/meta.js',
- 'keymap/emacs.js',
- 'keymap/sublime.js',
- 'keymap/vim.js',
-]
-
-CM_ADDONS = [
- 'dialog/dialog.js',
- 'edit/closebrackets.js',
- 'edit/matchbrackets.js',
- 'edit/trailingspace.js',
- 'scroll/annotatescrollbar.js',
- 'scroll/simplescrollbars.js',
- 'search/jump-to-line.js',
- 'search/matchesonscrollbar.js',
- 'search/searchcursor.js',
- 'search/search.js',
- 'selection/mark-selection.js',
- 'mode/multiplex.js',
- 'mode/overlay.js',
- 'mode/simple.js',
- 'lint/lint.js',
-]
-
-# Available themes must be enumerated here,
-# in gerrit-extension-api/src/main/java/com/google/gerrit/extensions/common/Theme.java,
-# in gerrit-gwtui/src/main/java/net/codemirror/theme/Themes.java
-CM_THEMES = [
- '3024-day',
- '3024-night',
- 'abcdef',
- 'ambiance',
- 'base16-dark',
- 'base16-light',
- 'bespin',
- 'blackboard',
- 'cobalt',
- 'colorforth',
- 'dracula',
- 'duotone-dark',
- 'duotone-light',
- 'eclipse',
- 'elegant',
- 'erlang-dark',
- 'hopscotch',
- 'icecoder',
- 'isotope',
- 'lesser-dark',
- 'liquibyte',
- 'material',
- 'mbo',
- 'mdn-like',
- 'midnight',
- 'monokai',
- 'neat',
- 'neo',
- 'night',
- 'paraiso-dark',
- 'paraiso-light',
- 'pastel-on-dark',
- 'railscasts',
- 'rubyblue',
- 'seti',
- 'solarized',
- 'the-matrix',
- 'tomorrow-night-bright',
- 'tomorrow-night-eighties',
- 'ttcn',
- 'twilight',
- 'vibrant-ink',
- 'xq-dark',
- 'xq-light',
- 'yeti',
- 'zenburn',
-]
-
-# Available modes must be enumerated here,
-# in gerrit-gwtui/src/main/java/net/codemirror/mode/Modes.java,
-# gerrit-gwtui/src/main/java/net/codemirror/mode/ModeInfo.java,
-# and in CodeMirror's own mode/meta.js script.
-CM_MODES = [
- 'apl',
- 'asciiarmor',
- 'asn.1',
- 'asterisk',
- 'brainfuck',
- 'clike',
- 'clojure',
- 'cmake',
- 'cobol',
- 'coffeescript',
- 'commonlisp',
- 'crystal',
- 'css',
- 'cypher',
- 'd',
- 'dart',
- 'diff',
- 'django',
- 'dockerfile',
- 'dtd',
- 'dylan',
- 'ebnf',
- 'ecl',
- 'eiffel',
- 'elm',
- 'erlang',
- 'factor',
- 'fcl',
- 'forth',
- 'fortran',
- 'gas',
- 'gfm',
- 'gherkin',
- 'go',
- 'groovy',
- 'haml',
- 'handlebars',
- 'haskell-literate',
- 'haskell',
- 'haxe',
- 'htmlembedded',
- 'htmlmixed',
- 'http',
- 'idl',
- 'javascript',
- 'jinja2',
- 'jsx',
- 'julia',
- 'livescript',
- 'lua',
- 'markdown',
- 'mathematica',
- 'mbox',
- 'mirc',
- 'mllike',
- 'modelica',
- 'mscgen',
- 'mumps',
- 'nginx',
- 'nsis',
- 'ntriples',
- 'octave',
- 'oz',
- 'pascal',
- 'pegjs',
- 'perl',
- 'php',
- 'pig',
- 'powershell',
- 'properties',
- 'protobuf',
- 'pug',
- 'puppet',
- 'python',
- 'q',
- 'r',
- 'rpm',
- 'rst',
- 'ruby',
- 'rust',
- 'sas',
- 'sass',
- 'scheme',
- 'shell',
- 'sieve',
- 'slim',
- 'smalltalk',
- 'smarty',
- 'solr',
- 'soy',
- 'sparql',
- 'spreadsheet',
- 'sql',
- 'stex',
- 'stylus',
- 'swift',
- 'tcl',
- 'textile',
- 'tiddlywiki',
- 'tiki',
- 'toml',
- 'tornado',
- 'troff',
- 'ttcn-cfg',
- 'ttcn',
- 'turtle',
- 'twig',
- 'vb',
- 'vbscript',
- 'velocity',
- 'verilog',
- 'vhdl',
- 'vue',
- 'webidl',
- 'xml',
- 'xquery',
- 'yacas',
- 'yaml-frontmatter',
- 'yaml',
- 'z80',
-]
-
-DIFF_MATCH_PATCH_VERSION = "20121119-1"
diff --git a/lib/commons/BUCK b/lib/commons/BUCK
deleted file mode 100644
index 5c2e9b2..0000000
--- a/lib/commons/BUCK
+++ /dev/null
@@ -1,93 +0,0 @@
-include_defs('//lib/maven.defs')
-
-maven_jar(
- name = 'codec',
- id = 'commons-codec:commons-codec:1.4',
- sha1 = '4216af16d38465bbab0f3dff8efa14204f7a399a',
- license = 'Apache2.0',
- exclude = ['META-INF/LICENSE.txt', 'META-INF/NOTICE.txt'],
-)
-
-maven_jar(
- name = 'collections',
- id = 'commons-collections:commons-collections:3.2.2',
- sha1 = '8ad72fe39fa8c91eaaf12aadb21e0c3661fe26d5',
- license = 'Apache2.0',
- exclude = ['META-INF/LICENSE.txt', 'META-INF/NOTICE.txt'],
- attach_source = False,
-)
-
-maven_jar(
- name = 'compress',
- id = 'org.apache.commons:commons-compress:1.12',
- sha1 = '84caa68576e345eb5e7ae61a0e5a9229eb100d7b',
- license = 'Apache2.0',
- exclude = ['META-INF/LICENSE.txt', 'META-INF/NOTICE.txt'],
-)
-
-maven_jar(
- name = 'dbcp',
- id = 'commons-dbcp:commons-dbcp:1.4',
- sha1 = '30be73c965cc990b153a100aaaaafcf239f82d39',
- license = 'Apache2.0',
- deps = [':pool'],
- exclude = [
- 'META-INF/LICENSE.txt',
- 'META-INF/NOTICE.txt',
- 'testpool.jocl'
- ],
-)
-
-maven_jar(
- name = 'lang',
- id = 'commons-lang:commons-lang:2.6',
- sha1 = '0ce1edb914c94ebc388f086c6827e8bdeec71ac2',
- license = 'Apache2.0',
- exclude = ['META-INF/LICENSE.txt', 'META-INF/NOTICE.txt'],
-)
-
-maven_jar(
- name = 'lang3',
- id = 'org.apache.commons:commons-lang3:3.3.2',
- sha1 = '90a3822c38ec8c996e84c16a3477ef632cbc87a3',
- license = 'Apache2.0',
-)
-
-maven_jar(
- name = 'net',
- id = 'commons-net:commons-net:3.5',
- sha1 = '342fc284019f590e1308056990fdb24a08f06318',
- license = 'Apache2.0',
- exclude = ['META-INF/LICENSE.txt', 'META-INF/NOTICE.txt'],
-)
-
-maven_jar(
- name = 'pool',
- id = 'commons-pool:commons-pool:1.5.5',
- sha1 = '7d8ffbdc47aa0c5a8afe5dc2aaf512f369f1d19b',
- license = 'Apache2.0',
- attach_source = False,
- exclude = ['META-INF/LICENSE.txt', 'META-INF/NOTICE.txt'],
-)
-
-maven_jar(
- name = 'oro',
- id = 'oro:oro:2.0.8',
- sha1 = '5592374f834645c4ae250f4c9fbb314c9369d698',
- license = 'Apache1.1',
- attach_source = False,
- exclude = ['META-INF/LICENSE'],
-)
-
-# When updating the version of commons-validator, also update the
-# list of supported TLDs in:
-# gerrit-server/src/test/resources/com/google/gerrit/server/mail/tlds-alpha-by-domain.txt
-# from:
-# http://data.iana.org/TLD/tlds-alpha-by-domain.txt
-maven_jar(
- name = 'validator',
- id = 'commons-validator:commons-validator:1.5.1',
- sha1 = '86d05a46e8f064b300657f751b5a98c62807e2a0',
- license = 'Apache2.0',
-)
-
diff --git a/lib/dropwizard/BUCK b/lib/dropwizard/BUCK
deleted file mode 100644
index de73e13..0000000
--- a/lib/dropwizard/BUCK
+++ /dev/null
@@ -1,8 +0,0 @@
-include_defs('//lib/maven.defs')
-
-maven_jar(
- name = 'dropwizard-core',
- id = 'io.dropwizard.metrics:metrics-core:3.1.2',
- sha1 = '224f03afd2521c6c94632f566beb1bb5ee32cf07',
- license = 'Apache2.0',
-)
diff --git a/lib/easymock/BUCK b/lib/easymock/BUCK
deleted file mode 100644
index cabd62e..0000000
--- a/lib/easymock/BUCK
+++ /dev/null
@@ -1,31 +0,0 @@
-include_defs('//lib/maven.defs')
-
-maven_jar(
- name = 'easymock',
- id = 'org.easymock:easymock:3.1', # When bumping the version
- # number, make sure to also move powermock to a compatible version
- sha1 = '3e127311a86fc2e8f550ef8ee4abe094bbcf7e7e',
- license = 'DO_NOT_DISTRIBUTE',
- deps = [
- ':cglib-3_2',
- ':objenesis',
- ],
-)
-
-maven_jar(
- name = 'cglib-3_2',
- id = 'cglib:cglib-nodep:3.2.0',
- sha1 = 'cf1ca207c15b04ace918270b6cb3f5601160cdfd',
- license = 'DO_NOT_DISTRIBUTE',
- attach_source = False,
-)
-
-maven_jar(
- name = 'objenesis',
- id = 'org.objenesis:objenesis:1.3',
- sha1 = 'dc13ae4faca6df981fc7aeb5a522d9db446d5d50',
- license = 'DO_NOT_DISTRIBUTE',
- visibility = ['//lib/powermock:powermock-reflect'],
- attach_source = False,
-)
-
diff --git a/lib/elasticsearch/BUCK b/lib/elasticsearch/BUCK
deleted file mode 100644
index 373f4d2..0000000
--- a/lib/elasticsearch/BUCK
+++ /dev/null
@@ -1,104 +0,0 @@
-include_defs('//lib/maven.defs')
-
-# Java client library for Elasticsearch.
-maven_jar(
- name = 'elasticsearch',
- id = 'org.elasticsearch:elasticsearch:2.4.0',
- sha1 = 'aeb9704a76fa8654c348f38fcbb993a952a7ab07',
- attach_source = True,
- repository = MAVEN_CENTRAL,
- license = 'Apache2.0',
- deps = [
- ':jna',
- ':hppc',
- ':jsr166e',
- ':netty',
- ':t-digest',
- ':compress-lzf',
- '//lib/joda:joda-time',
- '//lib/lucene:lucene-codecs',
- '//lib/lucene:lucene-highlighter',
- '//lib/lucene:lucene-join',
- '//lib/lucene:lucene-memory',
- '//lib/lucene:lucene-sandbox',
- '//lib/lucene:lucene-suggest',
- '//lib/lucene:lucene-queries',
- '//lib/lucene:lucene-spatial',
- '//lib/jackson:jackson-core',
- '//lib/jackson:jackson-dataformat-cbor',
- '//lib/jackson:jackson-dataformat-smile',
- ]
-)
-
-# Java REST client for Elasticsearch.
-VERSION = '2.0.3'
-
-maven_jar(
- name = 'jest-common',
- id = 'io.searchbox:jest-common:' + VERSION,
- sha1 = 'f304c66894aaf2f6c17a886bc826f09c7a161cf9',
- license = 'Apache2.0',
-)
-
-maven_jar(
- name = 'jest',
- id = 'io.searchbox:jest:' + VERSION,
- sha1 = 'b8f9ed1423489b361804e47f640515ea9f1fa08d',
- license = 'Apache2.0',
- deps = [
- ':elasticsearch',
- ':jest-common',
- '//lib/commons:lang3',
- '//lib/httpcomponents:httpasyncclient',
- '//lib/httpcomponents:httpclient',
- '//lib/httpcomponents:httpcore-nio',
- '//lib/httpcomponents:httpcore-niossl',
- ],
-)
-
-maven_jar(
- name = 'compress-lzf',
- id = 'com.ning:compress-lzf:1.0.2',
- sha1 = '62896e6fca184c79cc01a14d143f3ae2b4f4b4ae',
- license = 'Apache2.0',
- visibility = ['//lib/elasticsearch:elasticsearch'],
-)
-
-maven_jar(
- name = 'hppc',
- id = 'com.carrotsearch:hppc:0.7.1',
- sha1 = '8b5057f74ea378c0150a1860874a3ebdcb713767',
- license = 'Apache2.0',
- visibility = ['//lib/elasticsearch:elasticsearch'],
-)
-
-maven_jar(
- name = 'jsr166e',
- id = 'com.twitter:jsr166e:1.1.0',
- sha1 = '233098147123ee5ddcd39ffc57ff648be4b7e5b2',
- license = 'Apache2.0',
- visibility = ['//lib/elasticsearch:elasticsearch'],
-)
-
-maven_jar(
- name = 'netty',
- id = 'io.netty:netty:3.10.0.Final',
- sha1 = 'ad61cd1bba067e6634ddd3e160edf0727391ac30',
- license = 'Apache2.0',
- visibility = ['//lib/elasticsearch:elasticsearch'],
-)
-
-maven_jar(
- name = 't-digest',
- id = 'com.tdunning:t-digest:3.0',
- sha1 = '84ccf145ac2215e6bfa63baa3101c0af41017cfc',
- license = 'Apache2.0',
- visibility = ['//lib/elasticsearch:elasticsearch'],
-)
-
-maven_jar(
- name = 'jna',
- id = 'net.java.dev.jna:jna:4.1.0',
- sha1 = '1c12d070e602efd8021891cdd7fd18bc129372d4',
- license = 'Apache2.0',
-)
diff --git a/lib/fonts/BUCK b/lib/fonts/BUCK
deleted file mode 100644
index 7b64cf2..0000000
--- a/lib/fonts/BUCK
+++ /dev/null
@@ -1,13 +0,0 @@
-# Source Code Pro. Version 2.010 Roman / 1.030 Italics
-# https://github.com/adobe-fonts/source-code-pro/releases/tag/2.010R-ro%2F1.030R-it
-genrule(
- name = 'sourcecodepro',
- cmd = 'zip -rq $OUT .',
- srcs = [
- 'SourceCodePro-Regular.woff',
- 'SourceCodePro-Regular.woff2'
- ],
- out = 'sourcecodepro.zip',
- license = 'OFL1.1',
- visibility = ['PUBLIC'],
-)
diff --git a/lib/greenmail/BUCK b/lib/greenmail/BUCK
deleted file mode 100644
index 6fdf806..0000000
--- a/lib/greenmail/BUCK
+++ /dev/null
@@ -1,13 +0,0 @@
-include_defs('//lib/maven.defs')
-
-VERSION = '1.5.2'
-
-maven_jar(
- name = 'greenmail',
- id = 'com.icegreen:greenmail:' + VERSION,
- sha1 = '6b4862a09f8642da58c109117b24ccc19a4a6d39',
- license = 'Apache2.0',
- exclude_java_sources = True,
- visibility = ['PUBLIC'],
-)
-
diff --git a/lib/guice/BUCK b/lib/guice/BUCK
deleted file mode 100644
index 8022ac8..0000000
--- a/lib/guice/BUCK
+++ /dev/null
@@ -1,79 +0,0 @@
-include_defs('//lib/maven.defs')
-
-VERSION = '4.1.0'
-EXCLUDE = [
- 'META-INF/DEPENDENCIES',
- 'META-INF/LICENSE',
- 'META-INF/NOTICE',
-]
-
-java_library(
- name = 'guice',
- exported_deps = [
- ':guice_library',
- ':javax-inject',
- ':multibindings',
- ],
- visibility = ['PUBLIC'],
-)
-
-maven_jar(
- name = 'guice_library',
- id = 'com.google.inject:guice:' + VERSION,
- sha1 = 'eeb69005da379a10071aa4948c48d89250febb07',
- license = 'Apache2.0',
- deps = [':aopalliance'],
- exclude_java_sources = True,
- exclude = EXCLUDE + [
- 'META-INF/maven/com.google.guava/guava/pom.properties',
- 'META-INF/maven/com.google.guava/guava/pom.xml',
- ],
- visibility = ['PUBLIC'],
-)
-
-maven_jar(
- name = 'guice-assistedinject',
- id = 'com.google.inject.extensions:guice-assistedinject:' + VERSION,
- sha1 = 'af799dd7e23e6fe8c988da12314582072b07edcb',
- license = 'Apache2.0',
- deps = [':guice'],
- exclude = EXCLUDE,
-)
-
-maven_jar(
- name = 'guice-servlet',
- id = 'com.google.inject.extensions:guice-servlet:' + VERSION,
- sha1 = '90ac2db772d9b85e2b05417b74f7464bcc061dcb',
- license = 'Apache2.0',
- deps = [':guice'],
- exclude = EXCLUDE,
-)
-
-maven_jar(
- name = 'aopalliance',
- id = 'aopalliance:aopalliance:1.0',
- sha1 = '0235ba8b489512805ac13a8f9ea77a1ca5ebe3e8',
- license = 'PublicDomain',
- visibility = ['//lib/guice:guice'],
-)
-
-maven_jar(
- name = 'javax-inject',
- id = 'javax.inject:javax.inject:1',
- sha1 = '6975da39a7040257bd51d21a231b76c915872d38',
- license = 'Apache2.0',
- visibility = ['PUBLIC'],
-)
-
-maven_jar(
- name = 'multibindings',
- id = 'com.google.inject.extensions:guice-multibindings:' + VERSION,
- sha1 = '3b27257997ac51b0f8d19676f1ea170427e86d51',
- exclude_java_sources = True,
- exclude = EXCLUDE + [
- 'META-INF/maven/com.google.guava/guava/pom.properties',
- 'META-INF/maven/com.google.guava/guava/pom.xml',
- ],
- license = 'Apache2.0',
- visibility = ['PUBLIC']
-)
diff --git a/lib/gwt/BUCK b/lib/gwt/BUCK
deleted file mode 100644
index 6e8b8d1..0000000
--- a/lib/gwt/BUCK
+++ /dev/null
@@ -1,73 +0,0 @@
-include_defs('//lib/maven.defs')
-
-VERSION = '2.8.0'
-
-maven_jar(
- name = 'user',
- id = 'com.google.gwt:gwt-user:' + VERSION,
- sha1 = '518579870499e15531f454f35dca0772d7fa31f7',
- license = 'Apache2.0',
- attach_source = False,
-)
-
-maven_jar(
- name = 'dev',
- id = 'com.google.gwt:gwt-dev:' + VERSION,
- sha1 = 'f160a61272c5ebe805cd2d3d3256ed3ecf14893f',
- license = 'Apache2.0',
- attach_source = False,
-)
-
-maven_jar(
- name = 'javax-validation',
- id = 'javax.validation:validation-api:1.0.0.GA',
- bin_sha1 = 'b6bd7f9d78f6fdaa3c37dae18a4bd298915f328e',
- src_sha1 = '7a561191db2203550fbfa40d534d4997624cd369',
- license = 'Apache2.0',
- visibility = ['PUBLIC'],
-)
-
-maven_jar(
- name = 'jsinterop-annotations',
- id = 'com.google.jsinterop:jsinterop-annotations:1.0.0',
- bin_sha1 = '23c3a3c060ffe4817e67673cc8294e154b0a4a95',
- src_sha1 = '5d7c478efbfccc191430d7c118d7bd2635e43750',
- license = 'Apache2.0',
- visibility = ['PUBLIC'],
-)
-
-maven_jar(
- name = 'ant',
- id = 'ant:ant:1.6.5',
- bin_sha1 = '7d18faf23df1a5c3a43613952e0e8a182664564b',
- src_sha1 = '9e0a847494563f35f9b02846a1c1eb4aa2ee5a9a',
- license = 'Apache2.0',
- visibility = ['PUBLIC'],
-)
-
-maven_jar(
- name = 'colt',
- id = 'colt:colt:1.2.0',
- attach_source = False,
- bin_sha1 = '0abc984f3adc760684d49e0f11ddf167ba516d4f',
- license = 'DO_NOT_DISTRIBUTE',
- visibility = ['PUBLIC'],
-)
-
-maven_jar(
- name = 'tapestry',
- id = 'tapestry:tapestry:4.0.2',
- attach_source = False,
- bin_sha1 = 'e855a807425d522e958cbce8697f21e9d679b1f7',
- license = 'Apache2.0',
- visibility = ['PUBLIC'],
-)
-
-maven_jar(
- name = 'w3c-css-sac',
- id = 'org.w3c.css:sac:1.3',
- attach_source = False,
- bin_sha1 = 'cdb2dcb4e22b83d6b32b93095f644c3462739e82',
- license = 'DO_NOT_DISTRIBUTE',
- visibility = ['PUBLIC'],
-)
diff --git a/lib/highlightjs/BUCK b/lib/highlightjs/BUCK
deleted file mode 100644
index 9940136..0000000
--- a/lib/highlightjs/BUCK
+++ /dev/null
@@ -1,5 +0,0 @@
-export_file(
- name = 'highlightjs',
- src = 'highlight.min.js',
- visibility = ['PUBLIC'],
-)
diff --git a/lib/httpcomponents/BUCK b/lib/httpcomponents/BUCK
deleted file mode 100644
index 1e56f94..0000000
--- a/lib/httpcomponents/BUCK
+++ /dev/null
@@ -1,63 +0,0 @@
-include_defs('//lib/maven.defs')
-
-VERSION = '4.4.1'
-
-maven_jar(
- name = 'fluent-hc',
- id = 'org.apache.httpcomponents:fluent-hc:' + VERSION,
- bin_sha1 = '96fb842b68a44cc640c661186828b60590c71261',
- src_sha1 = '702515612b2b94ce3374ed5b579d38cbd308eb4f',
- license = 'Apache2.0',
- deps = [':httpclient']
-)
-
-maven_jar(
- name = 'httpclient',
- id = 'org.apache.httpcomponents:httpclient:' + VERSION,
- bin_sha1 = '016d0bc512222f1253ee6b64d389c84e22f697f0',
- src_sha1 = '30cb4791019c7280227e027b01814f4964a02482',
- license = 'Apache2.0',
- deps = [
- '//lib/commons:codec',
- ':httpcore',
- '//lib/log:jcl-over-slf4j',
- ],
-)
-
-maven_jar(
- name = 'httpcore',
- id = 'org.apache.httpcomponents:httpcore:' + VERSION,
- bin_sha1 = 'f5aa318bda4c6c8d688c9d00b90681dcd82ce636',
- src_sha1 = '9700be0d0a331691654a8e901943c9a74e33c5fc',
- license = 'Apache2.0',
-)
-
-maven_jar(
- name = 'httpmime',
- id = 'org.apache.httpcomponents:httpmime:' + VERSION,
- bin_sha1 = '2f8757f5ac5e38f46c794e5229d1f3c522e9b1df',
- src_sha1 = '5394d3715181a87009032335a55b0a9789f6e26f',
- license = 'Apache2.0',
-)
-
-maven_jar(
- name = 'httpasyncclient',
- id = 'org.apache.httpcomponents:httpasyncclient:4.1.2',
- sha1 = '95aa3e6fb520191a0970a73cf09f62948ee614be',
- license = 'Apache2.0',
-)
-
-maven_jar(
- name = 'httpcore-nio',
- id = 'org.apache.httpcomponents:httpcore-nio:' + VERSION,
- sha1 = 'a8c5e3c3bfea5ce23fb647c335897e415eb442e3',
- license = 'Apache2.0',
-)
-
-maven_jar(
- name = 'httpcore-niossl',
- id = 'org.apache.httpcomponents:httpcore-niossl:4.0-alpha6',
- sha1 = '9c662e7247ca8ceb1de5de629f685c9ef3e4ab58',
- license = 'Apache2.0',
- attach_source = False,
-)
diff --git a/lib/jackson/BUCK b/lib/jackson/BUCK
deleted file mode 100644
index 46056b5..0000000
--- a/lib/jackson/BUCK
+++ /dev/null
@@ -1,26 +0,0 @@
-include_defs('//lib/maven.defs')
-
-VERSION = '2.6.6'
-
-maven_jar(
- name = 'jackson-core',
- id = 'com.fasterxml.jackson.core:jackson-core:' + VERSION,
- sha1 = '02eb801df67aacaf5b1deb4ac626e1964508e47b',
- license = 'Apache2.0',
-)
-
-maven_jar(
- name = 'jackson-dataformat-smile',
- id = 'com.fasterxml.jackson.dataformat:jackson-dataformat-smile:' + VERSION,
- sha1 = 'ccbfc948748ed2754a58c1af9e0a02b5cc1aed69',
- license = 'Apache2.0',
-)
-
-maven_jar(
- name = 'jackson-dataformat-cbor',
- id = 'com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:' + VERSION,
- sha1 = '34c7b7ff495fc6b049612bdc9db0900a68e112f8',
- license = 'Apache2.0'
-)
-
-
diff --git a/lib/jetty/BUCK b/lib/jetty/BUCK
deleted file mode 100644
index e24cfe5..0000000
--- a/lib/jetty/BUCK
+++ /dev/null
@@ -1,95 +0,0 @@
-include_defs('//lib/maven.defs')
-
-VERSION = '9.3.11.v20160721'
-EXCLUDE = ['about.html']
-
-maven_jar(
- name = 'servlet',
- id = 'org.eclipse.jetty:jetty-servlet:' + VERSION,
- sha1 = 'd550147b85c73ea81084a4ac7915ba7f609021c5',
- license = 'Apache2.0',
- deps = [':security'],
- exclude = EXCLUDE,
-)
-
-maven_jar(
- name = 'security',
- id = 'org.eclipse.jetty:jetty-security:' + VERSION,
- sha1 = '1cbefc5d1196b9e1ca6f4cc36738998a6ebde8bf',
- license = 'Apache2.0',
- deps = [':server'],
- exclude = EXCLUDE,
- visibility = [],
-)
-
-maven_jar(
- name = 'servlets',
- id = 'org.eclipse.jetty:jetty-servlets:' + VERSION,
- sha1 = 'a9f7a43977151a463aa21a9b0e882aa3d25452ef',
- license = 'Apache2.0',
- exclude = EXCLUDE,
- visibility = [
- '//tools/eclipse:classpath',
- '//gerrit-gwtdebug:gwtdebug',
- ],
-)
-
-maven_jar(
- name = 'server',
- id = 'org.eclipse.jetty:jetty-server:' + VERSION,
- sha1 = 'd932e0dc1e9bd4839ae446754615163d60271a66',
- license = 'Apache2.0',
- exported_deps = [
- ':continuation',
- ':http',
- ],
- exclude = EXCLUDE,
-)
-
-maven_jar(
- name = 'jmx',
- id = 'org.eclipse.jetty:jetty-jmx:' + VERSION,
- sha1 = '21a658d2f5eb87c23eef4911966625ea95f66d32',
- license = 'Apache2.0',
- exported_deps = [
- ':continuation',
- ':http',
- ],
- exclude = EXCLUDE,
-)
-
-maven_jar(
- name = 'continuation',
- id = 'org.eclipse.jetty:jetty-continuation:' + VERSION,
- sha1 = '92a91c0dcc5f5d779a1c9f94038332be3f46c9df',
- license = 'Apache2.0',
- exclude = EXCLUDE,
-)
-
-maven_jar(
- name = 'http',
- id = 'org.eclipse.jetty:jetty-http:' + VERSION,
- sha1 = 'dcfb95e5b886a981bb76467b911c5b706117f9cf',
- license = 'Apache2.0',
- exported_deps = [':io'],
- exclude = EXCLUDE,
-)
-
-maven_jar(
- name = 'io',
- id = 'org.eclipse.jetty:jetty-io:' + VERSION,
- sha1 = 'db5f4f481159894a4b670072a34917b5414d0c98',
- license = 'Apache2.0',
- exported_deps = [':util'],
- exclude = EXCLUDE,
- visibility = [],
-)
-
-maven_jar(
- name = 'util',
- id = 'org.eclipse.jetty:jetty-util:' + VERSION,
- sha1 = '1812ffd5a04698051180d582c146ca807760c808',
- license = 'Apache2.0',
- exclude = EXCLUDE,
- visibility = [],
-)
diff --git a/lib/jgit/org.eclipse.jgit.archive/BUCK b/lib/jgit/org.eclipse.jgit.archive/BUCK
deleted file mode 100644
index f96bf4c..0000000
--- a/lib/jgit/org.eclipse.jgit.archive/BUCK
+++ /dev/null
@@ -1,16 +0,0 @@
-include_defs('//lib/maven.defs')
-include_defs('//lib/JGIT_VERSION')
-
-maven_jar(
- name = 'jgit-archive',
- id = 'org.eclipse.jgit:org.eclipse.jgit.archive:' + JGIT_VERS,
- sha1 = 'a728cf277396f1227c5a8dffcf5dee0188fc0821',
- license = 'jgit',
- repository = REPO,
- deps = ['//lib/jgit/org.eclipse.jgit:jgit'],
- unsign = True,
- exclude = [
- 'about.html',
- 'plugin.properties',
- ],
- )
diff --git a/lib/jgit/org.eclipse.jgit.http.server/BUCK b/lib/jgit/org.eclipse.jgit.http.server/BUCK
deleted file mode 100644
index c31de70..0000000
--- a/lib/jgit/org.eclipse.jgit.http.server/BUCK
+++ /dev/null
@@ -1,16 +0,0 @@
-include_defs('//lib/maven.defs')
-include_defs('//lib/JGIT_VERSION')
-
-maven_jar(
- name = 'jgit-servlet',
- id = 'org.eclipse.jgit:org.eclipse.jgit.http.server:' + JGIT_VERS,
- sha1 = 'd3aa54bd610db9a5c246aa8fef13989982c98628',
- license = 'jgit',
- repository = REPO,
- deps = ['//lib/jgit/org.eclipse.jgit:jgit'],
- unsign = True,
- exclude = [
- 'about.html',
- 'plugin.properties',
- ],
-)
diff --git a/lib/jgit/org.eclipse.jgit.junit/BUCK b/lib/jgit/org.eclipse.jgit.junit/BUCK
deleted file mode 100644
index 6073fa0..0000000
--- a/lib/jgit/org.eclipse.jgit.junit/BUCK
+++ /dev/null
@@ -1,12 +0,0 @@
-include_defs('//lib/maven.defs')
-include_defs('//lib/JGIT_VERSION')
-
-maven_jar(
- name = 'junit',
- id = 'org.eclipse.jgit:org.eclipse.jgit.junit:' + JGIT_VERS,
- sha1 = '6c2b2f192c95d25a2e1576aee5d1169dd8bd2266',
- license = 'DO_NOT_DISTRIBUTE',
- repository = REPO,
- unsign = True,
- deps = ['//lib/jgit/org.eclipse.jgit:jgit'],
-)
diff --git a/lib/jgit/org.eclipse.jgit/BUCK b/lib/jgit/org.eclipse.jgit/BUCK
deleted file mode 100644
index a1e14a5..0000000
--- a/lib/jgit/org.eclipse.jgit/BUCK
+++ /dev/null
@@ -1,25 +0,0 @@
-include_defs('//lib/maven.defs')
-include_defs('//lib/JGIT_VERSION')
-
-maven_jar(
- name = 'jgit',
- id = 'org.eclipse.jgit:org.eclipse.jgit:' + JGIT_VERS,
- bin_sha1 = 'a2b5970b853f8fee64589fc1103c0ceb7677ba63',
- src_sha1 = '765f955774c36c226aa41fba7c20119451de2db7',
- license = 'jgit',
- repository = REPO,
- unsign = True,
- deps = [':javaewah'],
- exclude = [
- 'META-INF/eclipse.inf',
- 'about.html',
- 'plugin.properties',
- ],
-)
-
-maven_jar(
- name = 'javaewah',
- id = 'com.googlecode.javaewah:JavaEWAH:1.1.6',
- sha1 = '94ad16d728b374d65bd897625f3fbb3da223a2b6',
- license = 'Apache2.0',
-)
diff --git a/lib/joda/BUCK b/lib/joda/BUCK
deleted file mode 100644
index d78c456..0000000
--- a/lib/joda/BUCK
+++ /dev/null
@@ -1,25 +0,0 @@
-include_defs('//lib/maven.defs')
-
-EXCLUDE = [
- 'META-INF/LICENSE.txt',
- 'META-INF/NOTICE.txt',
-]
-
-maven_jar(
- name = 'joda-time',
- id = 'joda-time:joda-time:2.9.4',
- sha1 = '1c295b462f16702ebe720bbb08f62e1ba80da41b',
- deps = [':joda-convert'],
- license = 'Apache2.0',
- exclude = EXCLUDE,
- visibility = ['PUBLIC'],
-)
-
-maven_jar(
- name = 'joda-convert',
- id = 'org.joda:joda-convert:1.8.1',
- sha1 = '675642ac208e0b741bc9118dcbcae44c271b992a',
- license = 'Apache2.0',
- exclude = EXCLUDE,
- visibility = ['//lib/joda:joda-time'],
-)
diff --git a/lib/js.defs b/lib/js.defs
deleted file mode 100644
index f215de9..0000000
--- a/lib/js.defs
+++ /dev/null
@@ -1,172 +0,0 @@
-# Copyright (C) 2015 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-NPMJS = 'NPMJS'
-GERRIT = 'GERRIT'
-
-# NOTE: npm_binary rules do not get their licenses checked by gen_licenses.py,
-# as we would have to cut too many edges. DO NOT include these binaries in
-# build outputs. Using them in the build _process_ is ok.
-def npm_binary(
- name,
- version,
- sha1 = '',
- repository = NPMJS,
- visibility = ['PUBLIC']):
-
- dir = '%s-%s' % (name, version)
- filename = '%s.tgz' % dir
- dest = '%s@%s.npm_binary.tgz' % (name, version)
- if repository == GERRIT:
- url = 'http://gerrit-maven.storage.googleapis.com/npm-packages/%s' % filename
- elif repository == NPMJS:
- url = 'http://registry.npmjs.org/%s/-/%s' % (name, filename)
- else:
- raise ValueError('invalid repository: %s' % repository)
- cmd = ['$(exe //tools:download_file)', '-o', '$OUT', '-u', url]
- if sha1:
- cmd.extend(['-v', sha1])
- genrule(
- name = name,
- cmd = ' '.join(cmd),
- out = dest,
- visibility = visibility,
- )
-
-
-def run_npm_binary(target):
- return '$(location //tools/js:run_npm_binary) $(location %s)' % target
-
-
-def bower_component(
- name,
- package,
- version,
- license,
- deps = [],
- semver = None,
- sha1 = '',
- visibility = ['PUBLIC']):
- download_name = '%s__download_bower' % name
- genrule(
- name = download_name,
- cmd = ' '.join([
- '$(exe //tools/js:download_bower)',
- '-b', '"%s"' % run_npm_binary('//lib/js:bower'),
- '-n', name,
- '-p', package,
- '-v', version,
- '-s', sha1,
- '-o', '$OUT',
- ]),
- out = '%s.zip' % download_name,
- license = license,
- visibility = [],
- )
-
- renamed_name = '%s__renamed' % name
- genrule(
- name = renamed_name,
- cmd = ' && '.join([
- 'cd $TMP',
- 'mkdir bower_components',
- 'cd bower_components',
- 'unzip $(location :%s)' % download_name,
- 'cd ..',
- 'zip -r $OUT bower_components',
- ]),
- out = '%s.zip' % renamed_name,
- visibility = [],
- )
-
- genrule(
- name = name,
- cmd = _combine_components([':%s' % renamed_name] + deps),
- out = '%s-%s.zip' % (name, version),
- visibility = visibility,
- )
-
- version_name = '%s__bower_version' % name
- dep_version = semver if semver is not None else version
- deps_json = '{"%s": "%s#%s"}' % (name, package, dep_version)
- genrule(
- name = version_name,
- cmd = "echo '%s' > $OUT" % deps_json,
- out = version_name,
- visibility = visibility,
- )
-
-
-def bower_components(
- name,
- deps,
- visibility = ['PUBLIC']):
- genrule(
- name = name,
- cmd = _combine_components(deps),
- out = '%s.bower_components.zip' % name,
- visibility = visibility,
- )
-
-
-def _combine_components(deps):
- cmds = ['cd $TMP']
- for d in deps:
- cmds.append('unzip -qo $(location %s)' % d)
- cmds.append("find bower_components -exec touch -t 198001010000 '{}' ';'")
- cmds.append('zip -r $OUT bower_components/*')
- return ' && '.join(cmds)
-
-
-VULCANIZE_FLAGS = [
- '--inline-scripts',
- '--inline-css',
- '--strip-comments',
-]
-
-def vulcanize(
- name,
- app,
- srcs,
- components,
- extra_flags = [],
- visibility = ['PUBLIC']):
- genrule(
- name = '%s__vulcanized' % name,
- cmd = ' '.join([
- 'unzip', '-qd', '$TMP', '$(location %s)' % components,
- '&&', 'rm', '-rf', '$SRCDIR/bower_components',
- '&&', 'ln', '-s', '-f', '$TMP/bower_components', '.',
- '&&', run_npm_binary('//lib/js:vulcanize')
- ] + VULCANIZE_FLAGS + extra_flags + [
- '--out-html', '$OUT',
- '$SRCDIR/%s' % app,
- ]),
- srcs = srcs,
- out = '%s.vulcanized.html' % name,
- visibility = visibility,
- )
-
- genrule(
- name = name,
- cmd = ' '.join([
- 'cd', '$TMP',
- '&&', run_npm_binary('//lib/js:crisper'), '--always-write-script',
- '--source', '$(location :%s__vulcanized)' % name,
- '--html', '%s.html' % name,
- '--js', '%s.js' % name,
- '&&', 'zip', '$OUT', '%s.html' % name, '%s.js' % name,
- ]),
- out = '%s.vulcanized.zip' % name,
- )
diff --git a/lib/js/BUCK b/lib/js/BUCK
deleted file mode 100644
index bb31b94..0000000
--- a/lib/js/BUCK
+++ /dev/null
@@ -1,427 +0,0 @@
-include_defs('//lib/js.defs')
-
-# WHEN REVIEWING NEW NPM_BINARY RULES:
-#
-# You must check licenses in the transitive closure of dependencies to ensure
-# they can be used by Gerrit. (npm binaries are not distributed with Gerrit
-# releases, so we are less restrictive in our selection of licenses, but we
-# still need to do a sanity check.)
-#
-# To do this:
-# npm install -g license-checker
-# mkdir /tmp/npmtmp
-# cd /tmp/npmtmp
-# npm install <package>@<version>
-# license-checker
-# (Piping to grep -o 'licenses:.*' and/or sort -u may make the output saner.)
-
-npm_binary(
- name = 'bower',
- version = '1.7.9',
- sha1 = 'b7296c2393e0d75edaa6ca39648132dd255812b0',
-)
-
-npm_binary(
- name = 'crisper',
- version = '2.0.2',
- sha1 = '7183c58cea33632fb036c91cefd1b43e390d22a2',
- repository = GERRIT,
-)
-
-npm_binary(
- name = 'vulcanize',
- version = '1.14.8',
- sha1 = '679107f251c19ab7539529b1e3fdd40829e6fc63',
- repository = GERRIT,
-)
-
-# ## Adding Bower component dependencies
-#
-# 1. Add a dummy bower_component rule to this file, specifying the semantic
-# version you want to use. The actual version will be filled in by Bower,
-# after evaluating the full dependency tree.
-#
-# bower_component(
-# name = 'somepackage',
-# package = 'someauthor/somepackage',
-# version = 'TODO',
-# semver = '~1.0.0',
-# license = 'DO_NOT_DISTRIBUTE'
-# )
-#
-# 2. Add your bower_component as a dep to a bower_components rule.
-#
-# bower_components(
-# name = 'polygerrit_components',
-# deps = [
-# '//lib/js:foo',
-# '//lib/js:somepackage', # NEW
-# ],
-# )
-#
-# 3. Run bower2buck.py.
-#
-# buck run //tools/js:bower2buck -- -o /tmp/newbuck
-#
-# 4. Use your favorite diff tool to merge the output in newbuck with this file.
-# bower2buck reevaluates semantic versions and may upgrade some packages, so
-# you may need to make changes beyond the new component that was added.
-#
-# meld /tmp/newbuck lib/js/BUCK
-#
-#
-# ## Updating Bower component dependencies
-#
-# Use the same procedure as for adding dependencies, except just change the
-# version number of the existing bower_component rather than adding a new rule.
-
-bower_component(
- name = 'accessibility-developer-tools',
- package = 'accessibility-developer-tools',
- version = '2.10.0',
- license = 'DO_NOT_DISTRIBUTE',
- sha1 = 'bc1a5e56ff1bed7a7a6ef22a4b4e8300e4822aa5',
-)
-
-bower_component(
- name = 'async',
- package = 'async',
- version = '1.5.2',
- license = 'DO_NOT_DISTRIBUTE',
- sha1 = '1ec975d3b3834646a7e3d4b7e68118b90ed72508',
-)
-
-bower_component(
- name = 'chai',
- package = 'chai',
- version = '3.5.0',
- license = 'DO_NOT_DISTRIBUTE',
- sha1 = '849ad3ee7c77506548b7b5db603a4e150b9431aa',
-)
-
-bower_component(
- name = 'es6-promise',
- package = 'stefanpenner/es6-promise',
- version = '3.3.0',
- license = 'es6-promise',
- sha1 = 'a3a797bb22132f1ef75f9a2556173f81870c2e53',
-)
-
-bower_component(
- name = 'fetch',
- package = 'fetch',
- version = '1.0.0',
- license = 'fetch',
- sha1 = '1b05a2bb40c73232c2909dc196de7519fe4db7a9',
-)
-
-bower_component(
- name = 'iron-a11y-announcer',
- package = 'polymerelements/iron-a11y-announcer',
- version = '1.0.4',
- deps = [':polymer'],
- license = 'polymer',
- sha1 = '9a915711b35092fa2f86ff6e904c4f3e43aa5234',
-)
-
-bower_component(
- name = 'iron-a11y-keys-behavior',
- package = 'polymerelements/iron-a11y-keys-behavior',
- version = '1.1.2',
- deps = [':polymer'],
- license = 'polymer',
- sha1 = '57fd39ee153ce37ed719ba3f7a405afb987d54f9',
-)
-
-bower_component(
- name = 'iron-autogrow-textarea',
- package = 'polymerelements/iron-autogrow-textarea',
- version = '1.0.12',
- deps = [
- ':iron-behaviors',
- ':iron-flex-layout',
- ':iron-form-element-behavior',
- ':iron-validatable-behavior',
- ':polymer',
- ],
- license = 'polymer',
- sha1 = 'b9b6874c9a2b5be435557a827ff8bd6661672ee3',
-)
-
-bower_component(
- name = 'iron-behaviors',
- package = 'polymerelements/iron-behaviors',
- version = '1.0.16',
- deps = [
- ':iron-a11y-keys-behavior',
- ':polymer',
- ],
- license = 'polymer',
- sha1 = 'bd70636a2c0a78c50d1a76f9b8ca1ffd815478a3',
-)
-
-bower_component(
- name = 'iron-dropdown',
- package = 'polymerelements/iron-dropdown',
- version = '1.4.0',
- deps = [
- ':iron-a11y-keys-behavior',
- ':iron-behaviors',
- ':iron-overlay-behavior',
- ':iron-resizable-behavior',
- ':neon-animation',
- ':polymer',
- ],
- license = 'polymer',
- sha1 = '63e3d669a09edaa31c4f05afc76b53b919ef0595',
-)
-
-bower_component(
- name = 'iron-fit-behavior',
- package = 'polymerelements/iron-fit-behavior',
- version = '1.2.2',
- deps = [':polymer'],
- license = 'polymer',
- sha1 = 'bc53e9bab36b21f086ab8fac8c53cc7214aa1890',
-)
-
-bower_component(
- name = 'iron-flex-layout',
- package = 'polymerelements/iron-flex-layout',
- version = '1.3.1',
- deps = [':polymer'],
- license = 'polymer',
- sha1 = 'ba696394abff5e799fc06eb11bff4720129a1b52',
-)
-
-bower_component(
- name = 'iron-form-element-behavior',
- package = 'polymerelements/iron-form-element-behavior',
- version = '1.0.6',
- deps = [':polymer'],
- license = 'polymer',
- sha1 = '8d9e6530edc1b99bec1a5c34853911fba3701220',
-)
-
-bower_component(
- name = 'iron-input',
- package = 'polymerelements/iron-input',
- version = '1.0.10',
- deps = [
- ':iron-a11y-announcer',
- ':iron-validatable-behavior',
- ':polymer',
- ],
- license = 'polymer',
- sha1 = '9bc0c8e81de2527125383cbcf74dd9f27e7fa9ac',
-)
-
-bower_component(
- name = 'iron-meta',
- package = 'polymerelements/iron-meta',
- version = '1.1.1',
- deps = [':polymer'],
- license = 'polymer',
- sha1 = 'e06281b6ddb3355ceca44975a167381b1fd72ce5',
-)
-
-bower_component(
- name = 'iron-overlay-behavior',
- package = 'polymerelements/iron-overlay-behavior',
- version = '1.7.6',
- deps = [
- ':iron-a11y-keys-behavior',
- ':iron-fit-behavior',
- ':iron-resizable-behavior',
- ':polymer',
- ],
- license = 'polymer',
- sha1 = '83181085fda59446ce74fd0d5ca30c223f38ee4a',
-)
-
-bower_component(
- name = 'iron-resizable-behavior',
- package = 'polymerelements/iron-resizable-behavior',
- version = '1.0.3',
- deps = [':polymer'],
- license = 'polymer',
- sha1 = '5982a3e19af7ed3e3de276a9b7bd266b3a144002',
-)
-
-bower_component(
- name = 'iron-selector',
- package = 'polymerelements/iron-selector',
- version = '1.5.2',
- deps = [':polymer'],
- license = 'polymer',
- sha1 = 'c57235dfda7fbb987c20ad0e97aac70babf1a1bf',
-)
-
-bower_component(
- name = 'iron-test-helpers',
- package = 'polymerelements/iron-test-helpers',
- version = '1.2.5',
- deps = [':polymer'],
- license = 'DO_NOT_DISTRIBUTE',
- sha1 = '433b03b106f5ff32049b84150cd70938e18b67ac',
-)
-
-bower_component(
- name = 'iron-validatable-behavior',
- package = 'polymerelements/iron-validatable-behavior',
- version = '1.1.1',
- deps = [
- ':iron-meta',
- ':polymer',
- ],
- license = 'polymer',
- sha1 = '480423380be0536f948735d91bc472f6e7ced5b4',
-)
-
-bower_component(
- name = 'lodash',
- package = 'lodash',
- version = '3.10.1',
- license = 'DO_NOT_DISTRIBUTE',
- sha1 = '2f207a8293c4c554bf6cf071241f7a00dc513d3a',
-)
-
-bower_component(
- name = 'mocha',
- package = 'mocha',
- version = '2.5.1',
- license = 'DO_NOT_DISTRIBUTE',
- sha1 = 'cb29bdd1047cfd9304659ecf10ec263f9c888c99',
-)
-
-bower_component(
- name = 'moment',
- package = 'moment/moment',
- version = '2.13.0',
- license = 'moment',
- sha1 = 'fc8ce2c799bab21f6ced7aff928244f4ca8880aa',
-)
-
-bower_component(
- name = 'neon-animation',
- package = 'polymerelements/neon-animation',
- version = '1.2.3',
- deps = [
- ':iron-meta',
- ':iron-resizable-behavior',
- ':iron-selector',
- ':polymer',
- ':web-animations-js',
- ],
- license = 'polymer',
- sha1 = '71cc0d3e0afdf8b8563e87d2ff03a6fa19183bd9',
-)
-
-bower_component(
- name = 'page',
- package = 'visionmedia/page.js',
- version = '1.7.1',
- license = 'page.js',
- sha1 = '51a05428dd4f68fae1df5f12d0e2b61ba67f7757',
-)
-
-bower_component(
- name = 'polymer',
- package = 'polymer/polymer',
- version = '1.7.0',
- deps = [':webcomponentsjs'],
- license = 'polymer',
- sha1 = 'e70caa58fdee0ce51c805d548f544f74cc27d143',
-)
-
-bower_component(
- name = 'promise-polyfill',
- package = 'polymerlabs/promise-polyfill',
- version = '1.0.0',
- deps = [':polymer'],
- license = 'promise-polyfill',
- sha1 = 'a3b598c06cbd7f441402e666ff748326030905d6',
-)
-
-bower_component(
- name = 'sinon-chai',
- package = 'sinon-chai',
- version = '2.8.0',
- license = 'DO_NOT_DISTRIBUTE',
- sha1 = '0464b5d944fdf8116bb23e0b02ecfbac945b3517',
-)
-
-bower_component(
- name = 'sinonjs',
- package = 'sinonjs',
- version = '1.17.1',
- license = 'DO_NOT_DISTRIBUTE',
- sha1 = 'a26a6aab7358807de52ba738770f6ac709afd240',
-)
-
-bower_component(
- name = 'stacky',
- package = 'stacky',
- version = '1.3.2',
- license = 'DO_NOT_DISTRIBUTE',
- sha1 = 'd6c07a0112ab2e9677fe085933744466a89232fb',
-)
-
-bower_component(
- name = 'test-fixture',
- package = 'polymerelements/test-fixture',
- version = '1.1.1',
- license = 'DO_NOT_DISTRIBUTE',
- sha1 = 'e373bd21c069163c3a754e234d52c07c77b20d3c',
-)
-
-bower_component(
- name = 'web-animations-js',
- package = 'web-animations/web-animations-js',
- version = '2.2.1',
- license = 'Apache2.0',
- sha1 = '0e73b263a86aa6764ad35c273eb12055f83d7eda',
-)
-
-bower_component(
- name = 'web-component-tester',
- package = 'web-component-tester',
- version = '4.2.2',
- deps = [
- ':accessibility-developer-tools',
- ':async',
- ':chai',
- ':lodash',
- ':mocha',
- ':sinon-chai',
- ':sinonjs',
- ':stacky',
- ':test-fixture',
- ],
- license = 'DO_NOT_DISTRIBUTE',
- sha1 = '54556000c33d9ed7949aa546c1b4a1531491a5f0',
-)
-
-bower_component(
- name = 'webcomponentsjs',
- package = 'webcomponentsjs',
- version = '0.7.22',
- license = 'polymer',
- sha1 = '8ba97a4a279ec6973a19b171c462a7b5cf454fb9',
-)
-
-# Zip highlightjs so that it can be imported as though it were a
-# bower_component and also attach the library license to the Buck dependency
-# graph.
-HLJS_DIR = 'bower_components/highlightjs'
-genrule(
- name = 'highlightjs',
- cmd = ' && '.join([
- 'mkdir -p %s' % HLJS_DIR,
- 'cp $(location //lib/highlightjs:highlightjs) %s/highlight.min.js' % HLJS_DIR,
- 'zip -r $OUT bower_components',
- ]),
- out = 'highlightjs.zip',
- license = 'highlightjs',
- visibility = ['PUBLIC'],
-)
diff --git a/lib/log/BUCK b/lib/log/BUCK
deleted file mode 100644
index a5201f3..0000000
--- a/lib/log/BUCK
+++ /dev/null
@@ -1,56 +0,0 @@
-include_defs('//lib/maven.defs')
-
-VER = '1.7.7'
-
-maven_jar(
- name = 'api',
- id = 'org.slf4j:slf4j-api:' + VER,
- sha1 = '2b8019b6249bb05d81d3a3094e468753e2b21311',
- license = 'slf4j',
-)
-
-maven_jar(
- name = 'nop',
- id = 'org.slf4j:slf4j-nop:' + VER,
- sha1 = '6cca9a3b999ff28b7a35ca762b3197cd7e4c2ad1',
- license = 'slf4j',
- deps = [':api'],
-)
-
-maven_jar(
- name = 'impl_log4j',
- id = 'org.slf4j:slf4j-log4j12:' + VER,
- sha1 = '58f588119ffd1702c77ccab6acb54bfb41bed8bd',
- license = 'slf4j',
- deps = [':log4j'],
-)
-
-maven_jar(
- name = 'jcl-over-slf4j',
- id = 'org.slf4j:jcl-over-slf4j:' + VER,
- sha1 = '56003dcd0a31deea6391b9e2ef2f2dc90b205a92',
- license = 'slf4j',
-)
-
-maven_jar(
- name = 'log4j',
- id = 'log4j:log4j:1.2.17',
- sha1 = '5af35056b4d257e4b64b9e8069c0746e8b08629f',
- license = 'Apache2.0',
- exclude = ['META-INF/LICENSE', 'META-INF/NOTICE'],
-)
-
-maven_jar(
- name = 'jsonevent-layout',
- id = 'net.logstash.log4j:jsonevent-layout:1.7',
- sha1 = '507713504f0ddb75ba512f62763519c43cf46fde',
- license = 'Apache2.0',
- deps = [':json-smart', '//lib/commons:lang']
-)
-
-maven_jar(
- name = 'json-smart',
- id = 'net.minidev:json-smart:1.1.1',
- sha1 = '24a2f903d25e004de30ac602c5b47f2d4e420a59',
- license = 'Apache2.0',
-)
diff --git a/lib/lucene/BUCK b/lib/lucene/BUCK
deleted file mode 100644
index 8f2efa2..0000000
--- a/lib/lucene/BUCK
+++ /dev/null
@@ -1,163 +0,0 @@
-include_defs('//lib/maven.defs')
-
-VERSION = '5.5.2'
-
-# core and backward-codecs both provide
-# META-INF/services/org.apache.lucene.codecs.Codec, so they must be merged.
-merge_maven_jars(
- name = 'lucene-core-and-backward-codecs',
- srcs = [
- ':backward-codecs_jar',
- ':lucene-core',
- ],
- visibility = ['PUBLIC'],
-)
-
-maven_jar(
- name = 'lucene-codecs',
- id = 'org.apache.lucene:lucene-codecs:' + VERSION,
- sha1 = 'e01fe463d9490bb1b4a6a168e771f7b7255a50b1',
- license = 'Apache2.0',
- exclude = [
- 'META-INF/LICENSE.txt',
- 'META-INF/NOTICE.txt',
- ],
-)
-
-maven_jar(
- name = 'lucene-core',
- id = 'org.apache.lucene:lucene-core:' + VERSION,
- sha1 = 'de5e5c3161ea01e89f2a09a14391f9b7ed66cdbb',
- license = 'Apache2.0',
- exclude = [
- 'META-INF/LICENSE.txt',
- 'META-INF/NOTICE.txt',
- ],
- visibility = ['//gerrit-elasticsearch:elasticsearch'],
-)
-
-maven_jar(
- name = 'lucene-analyzers-common',
- id = 'org.apache.lucene:lucene-analyzers-common:' + VERSION,
- sha1 = 'f0bc3114a6b43f8e64a33c471d5b9e8ddc51564d',
- license = 'Apache2.0',
- deps = [':lucene-core-and-backward-codecs'],
- exclude = [
- 'META-INF/LICENSE.txt',
- 'META-INF/NOTICE.txt',
- ],
-)
-
-maven_jar(
- name = 'backward-codecs_jar',
- id = 'org.apache.lucene:lucene-backward-codecs:' + VERSION,
- sha1 = 'c5cfcd7a8cf48a0144b61fb991c8e50a0bf868d5',
- license = 'Apache2.0',
- deps = [':lucene-core'],
- exclude = [
- 'META-INF/LICENSE.txt',
- 'META-INF/NOTICE.txt',
- ],
- visibility = [],
-)
-
-maven_jar(
- name = 'lucene-highlighter',
- id = 'org.apache.lucene:lucene-highlighter:' + VERSION,
- sha1 = 'd127ac514e9df965ab0b57d92bbe0c68d3d145b8',
- license = 'Apache2.0',
- exclude = [
- 'META-INF/LICENSE.txt',
- 'META-INF/NOTICE.txt',
- ],
-)
-
-maven_jar(
- name = 'lucene-join',
- id = 'org.apache.lucene:lucene-join:'+ VERSION,
- sha1 = 'dac1b322508f3f2696ecc49a97311d34d8382054',
- license = 'Apache2.0',
- exclude = [
- 'META-INF/LICENSE.txt',
- 'META-INF/NOTICE.txt',
- ],
-)
-
-maven_jar(
- name = 'lucene-memory',
- id = 'org.apache.lucene:lucene-memory:' + VERSION,
- sha1 = '7409db9863d8fbc265c27793c6cc7511304182c2',
- license = 'Apache2.0',
- exclude = [
- 'META-INF/LICENSE.txt',
- 'META-INF/NOTICE.txt',
- ],
-)
-
-maven_jar(
- name = 'lucene-misc',
- id = 'org.apache.lucene:lucene-misc:' + VERSION,
- sha1 = '37bbe5a2fb429499dfbe75d750d1778881fff45d',
- license = 'Apache2.0',
- deps = [':lucene-core-and-backward-codecs'],
- exclude = [
- 'META-INF/LICENSE.txt',
- 'META-INF/NOTICE.txt',
- ],
-)
-
-maven_jar(
- name = 'lucene-sandbox',
- id = 'org.apache.lucene:lucene-sandbox:' + VERSION,
- sha1 = '30a91f120706ba66732d5a974b56c6971b3c8a16',
- license = 'Apache2.0',
- exclude = [
- 'META-INF/LICENSE.txt',
- 'META-INF/NOTICE.txt',
- ],
-)
-
-maven_jar(
- name = 'lucene-spatial',
- id = 'org.apache.lucene:lucene-spatial:' + VERSION,
- sha1 = '8ed7a9a43d78222038573dd1c295a61f3c0bb0db',
- license = 'Apache2.0',
- exclude = [
- 'META-INF/LICENSE.txt',
- 'META-INF/NOTICE.txt',
- ],
-)
-maven_jar(
- name = 'lucene-suggest',
- id = 'org.apache.lucene:lucene-suggest:' + VERSION,
- sha1 = 'e8316b37dddcf2092a54dab2ce6aad0d5ad78585',
- license = 'Apache2.0',
- exclude = [
- 'META-INF/LICENSE.txt',
- 'META-INF/NOTICE.txt',
- ],
-)
-
-maven_jar(
- name = 'lucene-queries',
- id = 'org.apache.lucene:lucene-queries:' + VERSION,
- sha1 = '692f1ad887cf4e006a23f45019e6de30f3312d3f',
- license = 'Apache2.0',
- exclude = [
- 'META-INF/LICENSE.txt',
- 'META-INF/NOTICE.txt',
- ],
-)
-
-maven_jar(
- name = 'lucene-queryparser',
- id = 'org.apache.lucene:lucene-queryparser:' + VERSION,
- sha1 = '8ac921563e744463605284c6d9d2d95e1be5b87c',
- license = 'Apache2.0',
- deps = [':lucene-core-and-backward-codecs'],
- exclude = [
- 'META-INF/LICENSE.txt',
- 'META-INF/NOTICE.txt',
- ],
-)
-
diff --git a/lib/mail/BUCK b/lib/mail/BUCK
deleted file mode 100644
index 3243ff5..0000000
--- a/lib/mail/BUCK
+++ /dev/null
@@ -1,13 +0,0 @@
-include_defs('//lib/maven.defs')
-
-VERSION = '1.5.6'
-
-maven_jar(
- name = 'mail',
- id = 'com.sun.mail:javax.mail:' + VERSION,
- sha1 = 'ab5daef2f881c42c8e280cbe918ec4d7fdfd7efe',
- license = 'DO_NOT_DISTRIBUTE',
- exclude_java_sources = True,
- visibility = ['PUBLIC'],
-)
-
diff --git a/lib/maven.defs b/lib/maven.defs
deleted file mode 100644
index 913be35..0000000
--- a/lib/maven.defs
+++ /dev/null
@@ -1,188 +0,0 @@
-# Copyright (C) 2013 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-GERRIT = 'GERRIT:'
-GERRIT_API = 'GERRIT_API:'
-MAVEN_CENTRAL = 'MAVEN_CENTRAL:'
-MAVEN_LOCAL = 'MAVEN_LOCAL:'
-MAVEN_SNAPSHOT = 'MAVEN_SNAPSHOT:'
-
-def define_license(name):
- n = 'LICENSE-' + name
- genrule(
- name = n,
- cmd = 'ln -s $SRCS $OUT',
- srcs = [n],
- out = n,
- visibility = ['PUBLIC'],
- )
-
-def maven_jar(
- name,
- id,
- license,
- exclude = [],
- exclude_java_sources = False,
- unsign = False,
- deps = [],
- exported_deps = [],
- sha1 = '', bin_sha1 = '', src_sha1 = '',
- repository = MAVEN_CENTRAL,
- attach_source = True,
- visibility = ['PUBLIC'],
- local_license = False):
- from os import path
-
- def maven_snapshot(parts):
- if len(parts) != 4:
- raise NameError('%s:\nexpected id="groupId:artifactId:version:snapshot]"'
- % id)
- group, artifact, version, snapshot = parts
- jar = path.join(name,
- version + '-SNAPSHOT',
- '-'.join([artifact.lower(), version, snapshot]))
- url = '/'.join([
- repository,
- group.replace('.', '/'),
- artifact,
- version + '-SNAPSHOT',
- '-'.join([artifact.lower(), version, snapshot])])
- return jar, url
-
- def maven_release(parts):
- if len(parts) not in [3, 4]:
- raise NameError('%s:\nexpected id="groupId:artifactId:version[:classifier]"'
- % id)
- if len(parts) == 4:
- group, artifact, version, classifier = parts
- file_version = version + '-' + classifier
- else:
- group, artifact, version = parts
- file_version = version
-
- jar = path.join(name, artifact.lower() + '-' + file_version)
- url = '/'.join([
- repository,
- group.replace('.', '/'),
- artifact,
- version,
- artifact + '-' + file_version])
-
- return jar, url
-
- parts = id.split(':')
- if repository.startswith(MAVEN_SNAPSHOT):
- jar, url = maven_snapshot(parts)
- else:
- jar, url = maven_release(parts)
-
- binjar = jar + '.jar'
- binurl = url + '.jar'
-
- srcjar = jar + '-src.jar'
- srcurl = url + '-sources.jar'
-
- cmd = ['$(exe //tools:download_file)', '-o', '$OUT', '-u', binurl]
- if sha1:
- cmd.extend(['-v', sha1])
- elif bin_sha1:
- cmd.extend(['-v', bin_sha1])
- for x in exclude:
- cmd.extend(['-x', x])
- if exclude_java_sources:
- cmd.append('--exclude_java_sources')
- if unsign:
- cmd.append('--unsign')
-
- genrule(
- name = '%s__download_bin' % name,
- cmd = ' '.join(cmd),
- out = binjar,
- )
- license = ':LICENSE-' + license
- if not local_license:
- license = '//lib' + license
- license = [license]
-
- if src_sha1 or attach_source:
- cmd = ['$(exe //tools:download_file)', '-o', '$OUT', '-u', srcurl]
- if src_sha1:
- cmd.extend(['-v', src_sha1])
- genrule(
- name = '%s__download_src' % name,
- cmd = ' '.join(cmd),
- out = srcjar,
- )
- prebuilt_jar(
- name = '%s_src' % name,
- binary_jar = ':%s__download_src' % name,
- deps = license,
- visibility = visibility,
- )
- else:
- srcjar = None
- genrule(
- name = '%s_src' % name,
- cmd = ':>$OUT',
- out = '__%s__no_src' % name,
- )
-
- if exported_deps:
- prebuilt_jar(
- name = '%s__jar' % name,
- deps = deps + license,
- binary_jar = ':%s__download_bin' % name,
- source_jar = ':%s__download_src' % name if srcjar else None,
- )
- java_library(
- name = name,
- exported_deps = exported_deps + [':' + name + '__jar'],
- visibility = visibility,
- )
- else:
- prebuilt_jar(
- name = name,
- deps = deps + license,
- binary_jar = ':%s__download_bin' % name,
- source_jar = ':%s__download_src' % name if srcjar else None,
- visibility = visibility,
- )
-
-
-def merge_maven_jars(
- name,
- srcs,
- visibility = []):
-
- def cmd(jars):
- return ('$(location //tools:merge_jars) $OUT '
- + ' '.join(['$(location %s)' % j for j in jars]))
-
- genrule(
- name = '%s__merged_bin' % name,
- cmd = cmd(['%s__download_bin' % s for s in srcs]),
- out = '%s__merged.jar' % name,
- )
- genrule(
- name = '%s__merged_src' % name,
- cmd = cmd(['%s__download_src' % s for s in srcs]),
- # tools/eclipse/project.py requires -src.jar suffix.
- out = '%s__merged-src.jar' % name,
- )
- prebuilt_jar(
- name = name,
- binary_jar = ':%s__merged_bin' % name,
- source_jar = ':%s__merged_src' % name,
- visibility = visibility,
- )
diff --git a/lib/mime4j/BUCK b/lib/mime4j/BUCK
deleted file mode 100644
index 08fa903..0000000
--- a/lib/mime4j/BUCK
+++ /dev/null
@@ -1,19 +0,0 @@
-include_defs('//lib/maven.defs')
-
-VERSION = '0.8.0'
-
-maven_jar(
- name = 'core',
- id = 'org.apache.james:apache-mime4j-core:' + VERSION,
- sha1 = 'd54f45fca44a2f210569656b4ca3574b42911c95',
- license = 'Apache2.0',
- visibility = ['PUBLIC'],
-)
-
-maven_jar(
- name = 'dom',
- id = 'org.apache.james:apache-mime4j-dom:' + VERSION,
- sha1 = '6720c93d14225c3e12c4a69768a0370c80e376a3',
- license = 'Apache2.0',
- visibility = ['PUBLIC'],
-)
diff --git a/lib/mina/BUCK b/lib/mina/BUCK
deleted file mode 100644
index f22a710..0000000
--- a/lib/mina/BUCK
+++ /dev/null
@@ -1,26 +0,0 @@
-include_defs('//lib/maven.defs')
-
-EXCLUDE = [
- 'META-INF/DEPENDENCIES',
- 'META-INF/LICENSE',
- 'META-INF/NOTICE',
-]
-
-maven_jar(
- name = 'sshd',
- id = 'org.apache.sshd:sshd-core:1.2.0',
- sha1 = '4bc24a8228ba83dac832680366cf219da71dae8e',
- src_sha1 = '490e3f03d7628ecf1cbb8317563fdbf06e68e29f',
- license = 'Apache2.0',
- deps = [':core'],
- exclude = EXCLUDE,
-)
-
-maven_jar(
- name = 'core',
- id = 'org.apache.mina:mina-core:2.0.10',
- sha1 = 'a1cb1136b104219d6238de886bf5a3ea4554eb58',
- src_sha1 = 'b70ff94ba379b4e825caca1af4ec83193fac4b10',
- license = 'Apache2.0',
- exclude = EXCLUDE,
-)
diff --git a/lib/openid/BUCK b/lib/openid/BUCK
deleted file mode 100644
index 728698b..0000000
--- a/lib/openid/BUCK
+++ /dev/null
@@ -1,35 +0,0 @@
-include_defs('//lib/maven.defs')
-
-maven_jar(
- name = 'consumer',
- id = 'org.openid4java:openid4java:0.9.8',
- sha1 = 'de4f1b33d3b0f0b2ab1d32834ec1190b39db4160',
- license = 'Apache2.0',
- deps = [
- ':nekohtml',
- ':xerces',
- '//lib/httpcomponents:httpclient',
- '//lib/log:jcl-over-slf4j',
- '//lib/guice:guice',
- ],
- visibility = ['PUBLIC'],
-)
-
-maven_jar(
- name = 'nekohtml',
- id = 'net.sourceforge.nekohtml:nekohtml:1.9.10',
- sha1 = '14052461031a7054aa094f5573792feb6686d3de',
- license = 'Apache2.0',
- deps = [':xerces'],
- attach_source = False,
- visibility = [],
-)
-
-maven_jar(
- name = 'xerces',
- id = 'xerces:xercesImpl:2.8.1',
- sha1 = '25101e37ec0c907db6f0612cbf106ee519c1aef1',
- license = 'Apache2.0',
- attach_source = False,
- visibility = [],
-)
diff --git a/lib/ow2/BUCK b/lib/ow2/BUCK
deleted file mode 100644
index 653bd2b..0000000
--- a/lib/ow2/BUCK
+++ /dev/null
@@ -1,39 +0,0 @@
-include_defs('//lib/maven.defs')
-
-VERSION = '5.1'
-
-maven_jar(
- name = 'ow2-asm',
- id = 'org.ow2.asm:asm:' + VERSION,
- sha1 = '5ef31c4fe953b1fd00b8a88fa1d6820e8785bb45',
- license = 'ow2',
-)
-
-maven_jar(
- name = 'ow2-asm-analysis',
- id = 'org.ow2.asm:asm-analysis:' + VERSION,
- sha1 = '6d1bf8989fc7901f868bee3863c44f21aa63d110',
- license = 'ow2',
-)
-
-maven_jar(
- name = 'ow2-asm-commons',
- id = 'org.ow2.asm:asm-commons:' + VERSION,
- sha1 = '25d8a575034dd9cfcb375a39b5334f0ba9c8474e',
- deps = [':ow2-asm-tree'],
- license = 'ow2',
-)
-
-maven_jar(
- name = 'ow2-asm-tree',
- id = 'org.ow2.asm:asm-tree:' + VERSION,
- sha1 = '87b38c12a0ea645791ead9d3e74ae5268d1d6c34',
- license = 'ow2',
-)
-
-maven_jar(
- name = 'ow2-asm-util',
- id = 'org.ow2.asm:asm-util:' + VERSION,
- sha1 = 'b60e33a6bd0d71831e0c249816d01e6c1dd90a47',
- license = 'ow2',
-)
diff --git a/lib/powermock/BUCK b/lib/powermock/BUCK
deleted file mode 100644
index d469a85..0000000
--- a/lib/powermock/BUCK
+++ /dev/null
@@ -1,73 +0,0 @@
-include_defs('//lib/maven.defs')
-
-VERSION = '1.6.1' # When bumping VERSION, make sure to also move
-# easymock to a compatible version
-
-maven_jar(
- name = 'powermock-module-junit4',
- id = 'org.powermock:powermock-module-junit4:' + VERSION,
- sha1 = 'ea8530b2848542624f110a393513af397b37b9cf',
- license = 'DO_NOT_DISTRIBUTE',
- deps = [
- ':powermock-module-junit4-common',
- '//lib:junit',
- ],
-)
-
-maven_jar(
- name = 'powermock-module-junit4-common',
- id = 'org.powermock:powermock-module-junit4-common:' + VERSION,
- sha1 = '7222ced54dabc310895d02e45c5428ca05193cda',
- license = 'DO_NOT_DISTRIBUTE',
- deps = [
- ':powermock-reflect',
- '//lib:junit',
- ],
-)
-
-maven_jar(
- name = 'powermock-reflect',
- id = 'org.powermock:powermock-reflect:' + VERSION,
- sha1 = '97d25eda8275c11161bcddda6ef8beabd534c878',
- license = 'DO_NOT_DISTRIBUTE',
- deps = [
- '//lib:junit',
- '//lib/easymock:objenesis',
- ],
-)
-
-maven_jar(
- name = 'powermock-api-easymock',
- id = 'org.powermock:powermock-api-easymock:' + VERSION,
- sha1 = 'aa740ecf89a2f64d410b3d93ef8cd6833009ef00',
- license = 'DO_NOT_DISTRIBUTE',
- deps = [
- ':powermock-api-support',
- '//lib/easymock:easymock',
- ],
-)
-
-maven_jar(
- name = 'powermock-api-support',
- id = 'org.powermock:powermock-api-support:' + VERSION,
- sha1 = '592ee6d929c324109d3469501222e0c76ccf0869',
- license = 'DO_NOT_DISTRIBUTE',
- deps = [
- ':powermock-core',
- ':powermock-reflect',
- '//lib:junit',
- ],
-)
-
-maven_jar(
- name = 'powermock-core',
- id = 'org.powermock:powermock-core:' + VERSION,
- sha1 = '5afc1efce8d44ed76b30af939657bd598e45d962',
- license = 'DO_NOT_DISTRIBUTE',
- deps = [
- ':powermock-reflect',
- '//lib:javassist',
- '//lib:junit',
- ],
-)
-
diff --git a/lib/powermock/BUILD b/lib/powermock/BUILD
index d0cab9b..7353b56 100644
--- a/lib/powermock/BUILD
+++ b/lib/powermock/BUILD
@@ -62,5 +62,6 @@
":powermock-reflect",
"//lib:javassist",
"//lib:junit",
+ "@powermock_core//jar",
],
)
diff --git a/lib/prolog/BUCK b/lib/prolog/BUCK
deleted file mode 100644
index 854b0f7..0000000
--- a/lib/prolog/BUCK
+++ /dev/null
@@ -1,64 +0,0 @@
-include_defs('//lib/maven.defs')
-
-VERSION = '1.4.2'
-REPO = GERRIT
-
-maven_jar(
- name = 'runtime',
- id = 'com.googlecode.prolog-cafe:prolog-runtime:' + VERSION,
- sha1 = '4421b4806b6e3a318680f6ab1d57569e857169c6',
- license = 'prologcafe',
- repository = REPO,
-)
-
-maven_jar(
- name = 'compiler',
- id = 'com.googlecode.prolog-cafe:prolog-compiler:' + VERSION,
- sha1 = '7e5a7ca5efe7db7f69e015cf492f8f04665244d8',
- license = 'prologcafe',
- repository = REPO,
- deps = [
- ':io',
- ':runtime',
- ],
-)
-
-maven_jar(
- name = 'io',
- id = 'com.googlecode.prolog-cafe:prolog-io:' + VERSION,
- sha1 = 'd177f6211d1013e0f31a507127f5c87a7f6941f3',
- license = 'prologcafe',
- repository = REPO,
- deps = [':runtime'],
- visibility = [],
-)
-
-maven_jar(
- name = 'cafeteria',
- id = 'com.googlecode.prolog-cafe:prolog-cafeteria:' + VERSION,
- sha1 = '11f396cb2588b65e6a78070488aaa58d12bf000e',
- license = 'prologcafe',
- repository = REPO,
- deps = [
- ':io',
- ':runtime',
- ],
- visibility = ['//gerrit-pgm:'],
-)
-
-java_binary(
- name = 'compiler_bin',
- main_class = 'BuckPrologCompiler',
- deps = [':compiler_lib'],
- visibility = ['PUBLIC'],
-)
-
-java_library(
- name = 'compiler_lib',
- srcs = ['java/BuckPrologCompiler.java'],
- deps = [
- ':compiler',
- ':runtime',
- ],
- visibility = ['//tools/eclipse:classpath'],
-)
diff --git a/lib/prolog/prolog.defs b/lib/prolog/prolog.defs
deleted file mode 100644
index e74c21d..0000000
--- a/lib/prolog/prolog.defs
+++ /dev/null
@@ -1,42 +0,0 @@
-# Copyright (C) 2013 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-def prolog_cafe_library(
- name,
- srcs,
- deps = [],
- visibility = []):
- genrule(
- name = name + '__pl2j',
- cmd = '$(exe //lib/prolog:compiler_bin)' +
- ' $TMP $OUT ' +
- ' '.join(srcs),
- srcs = srcs,
- out = name + '.src.zip',
- )
- java_library(
- name = name + '__lib',
- srcs = [':' + name + '__pl2j'],
- deps = ['//lib/prolog:runtime'] + deps,
- )
- genrule(
- name = name + '__ln',
- cmd = 'ln -s $(location :%s__lib) $OUT' % name,
- out = name + '.jar',
- )
- prebuilt_jar(
- name = name,
- binary_jar = ':%s__ln' % name,
- visibility = visibility,
- )
diff --git a/plugins/BUCK b/plugins/BUCK
deleted file mode 100644
index c6bb7f1..0000000
--- a/plugins/BUCK
+++ /dev/null
@@ -1,42 +0,0 @@
-BASE = get_base_path()
-CORE = [
- 'commit-message-length-validator',
- 'download-commands',
- 'hooks',
- 'replication',
- 'reviewnotes',
- 'singleusergroup'
-]
-CUSTOM = [
- # Add custom core plugins here
-]
-
-# buck audit parses and resolves all deps even if not reachable
-# from the root(s) passed to audit. Filter dependencies to only
-# the ones that currently exist to allow buck to parse cleanly.
-# TODO(sop): buck should more lazily resolve deps
-def core_plugins(names):
- from os import path
- h, n = [], []
- for p in names:
- if path.exists(path.join(BASE, p, 'BUCK')):
- h.append(p)
- else:
- n.append(p)
- return h, n
-HAVE, NEED = core_plugins(CORE + CUSTOM)
-
-genrule(
- name = 'core',
- cmd = '' +
- ';'.join(['echo >&2 plugins/'+n+' is required.' for n in NEED]) +
- (';echo >&2;exit 1;' if NEED else '') +
- 'mkdir -p $TMP/WEB-INF/plugins;' +
- 'for s in ' +
- ' '.join(['$(location //%s/%s:%s)' % (BASE, n, n) for n in HAVE]) +
- ';do ln -s $s $TMP/WEB-INF/plugins;done;' +
- 'cd $TMP;' +
- 'zip -qr $OUT .',
- out = 'core.zip',
- visibility = ['//:release'],
-)
diff --git a/plugins/cookbook-plugin b/plugins/cookbook-plugin
index da18513..b9b67ac 160000
--- a/plugins/cookbook-plugin
+++ b/plugins/cookbook-plugin
@@ -1 +1 @@
-Subproject commit da185134efc5f1f45f7a0cfd4cb68110312fd216
+Subproject commit b9b67ac2938795413b0768387d6014b45a455f26
diff --git a/plugins/download-commands b/plugins/download-commands
index 29b2516..46a8f7c 160000
--- a/plugins/download-commands
+++ b/plugins/download-commands
@@ -1 +1 @@
-Subproject commit 29b2516f2caef184e0d4441f88344d2a69a938ba
+Subproject commit 46a8f7c67d190beabd9cbe6399d6bf85c304f7ee
diff --git a/plugins/external_plugin_deps.bzl b/plugins/external_plugin_deps.bzl
new file mode 100644
index 0000000..391f920
--- /dev/null
+++ b/plugins/external_plugin_deps.bzl
@@ -0,0 +1,2 @@
+def external_plugin_deps():
+ pass
\ No newline at end of file
diff --git a/plugins/hooks b/plugins/hooks
index e5b687e..c0be9e0 160000
--- a/plugins/hooks
+++ b/plugins/hooks
@@ -1 +1 @@
-Subproject commit e5b687e9fc1c1f67de83873ed26b295f52fe77d9
+Subproject commit c0be9e0e6931eee98a1d9dd69b8abd5c26d4be51
diff --git a/plugins/replication b/plugins/replication
index 66f08f2..43bcff7 160000
--- a/plugins/replication
+++ b/plugins/replication
@@ -1 +1 @@
-Subproject commit 66f08f2460ba89b6827f4e456be1c1a948a718aa
+Subproject commit 43bcff79216014f822d26491345dd3137e887bc1
diff --git a/plugins/reviewnotes b/plugins/reviewnotes
index a4586ed..a333627 160000
--- a/plugins/reviewnotes
+++ b/plugins/reviewnotes
@@ -1 +1 @@
-Subproject commit a4586ed9cf38ffbbe1f890abe3bc6ac4a873a3ed
+Subproject commit a3336277c828d70c88de615e6f135018e1cd5e21
diff --git a/plugins/singleusergroup b/plugins/singleusergroup
index d0d51ea..69a0553 160000
--- a/plugins/singleusergroup
+++ b/plugins/singleusergroup
@@ -1 +1 @@
-Subproject commit d0d51ea46e9e3220c1d22fda241a50ac341df5de
+Subproject commit 69a0553ee0608f3057ec4e3dd17eb93401203181
diff --git a/polygerrit-ui/BUCK b/polygerrit-ui/BUCK
deleted file mode 100644
index b5dee99..0000000
--- a/polygerrit-ui/BUCK
+++ /dev/null
@@ -1,35 +0,0 @@
-include_defs('//lib/js.defs')
-
-bower_components(
- name = 'polygerrit_components',
- deps = [
- '//lib/js:es6-promise',
- '//lib/js:fetch',
- '//lib/js:highlightjs',
- '//lib/js:iron-a11y-keys-behavior',
- '//lib/js:iron-autogrow-textarea',
- '//lib/js:iron-dropdown',
- '//lib/js:iron-input',
- '//lib/js:iron-overlay-behavior',
- '//lib/js:iron-selector',
- '//lib/js:moment',
- '//lib/js:page',
- '//lib/js:polymer',
- '//lib/js:promise-polyfill',
- ],
-)
-
-genrule(
- name = 'fonts',
- cmd = ' && '.join([
- 'cd $TMP',
- 'mkdir fonts',
- 'for file in $SRCS; do echo `pwd` > /tmp/log.log; unzip -qd fonts/ $file; done',
- 'zip -qr $OUT fonts',
- ]),
- srcs = [
- '//lib/fonts:sourcecodepro',
- ],
- out = 'fonts.zip',
- visibility = ['PUBLIC'],
-)
diff --git a/polygerrit-ui/README.md b/polygerrit-ui/README.md
index 28d028b..76979f1 100644
--- a/polygerrit-ui/README.md
+++ b/polygerrit-ui/README.md
@@ -13,11 +13,11 @@
All other platforms: [download from
nodejs.org](https://nodejs.org/en/download/).
-## Installing [Buck](https://buckbuild.com/)
+## Installing [Bazel](https://bazel.build/)
Follow the instructions
-[here](https://gerrit-review.googlesource.com/Documentation/dev-buck.html#_installation)
-to get and install Buck.
+[here](https://gerrit-review.googlesource.com/Documentation/dev-bazel.html#_installation)
+to get and install Bazel.
## Local UI, Production Data
@@ -59,7 +59,7 @@
One-time setup:
-1. [Build Gerrit](https://gerrit-review.googlesource.com/Documentation/dev-buck.html#_gerrit_development_war_file)
+1. [Build Gerrit](https://gerrit-review.googlesource.com/Documentation/dev-bazel.html#_gerrit_development_war_file)
2. Set up a local test site. Docs
[here](https://gerrit-review.googlesource.com/Documentation/install-quick.html) and
[here](https://gerrit-review.googlesource.com/Documentation/dev-readme.html#init).
@@ -68,8 +68,8 @@
that serves PolyGerrit:
```sh
-buck build polygerrit && \
-java -jar buck-out/gen/polygerrit/polygerrit.war daemon --polygerrit-dev \
+bazel build polygerrit && \
+java -jar bazel-bin/polygerrit.war daemon --polygerrit-dev \
-d ../gerrit_testsite --console-log --show-stack-trace
```
@@ -91,16 +91,13 @@
Run all web tests:
```sh
-buck test --no-results-cache --include web
+./polygerrit-ui/app/run_test.sh
```
-The `--no-results-cache` flag prevents flaky test failures from being
-cached.
-
If you need to pass additional arguments to `wct`:
```sh
-WCT_ARGS='-p --some-flag="foo bar"' buck test --no-results-cache --include web
+WCT_ARGS='-p --some-flag="foo bar"' ./polygerrit-ui/app/run_test.sh
```
For interactively working on a single test file, do the following:
@@ -111,14 +108,6 @@
Then visit http://localhost:8081/elements/foo/bar_test.html
-## Running tests (bazel)
-
-Run
-
-```sh
-WCT_ARGS='--some-flag' sh polygerrit-ui/app/run_test.sh
-```
-
## Style guide
We follow the [Google JavaScript Style Guide](https://google.github.io/styleguide/javascriptguide.xml)
diff --git a/polygerrit-ui/app/BUCK b/polygerrit-ui/app/BUCK
deleted file mode 100644
index 5d4f06d..0000000
--- a/polygerrit-ui/app/BUCK
+++ /dev/null
@@ -1,99 +0,0 @@
-include_defs('//lib/js.defs')
-
-WCT_TEST_PATTERNS = [
- 'test/*.js',
- 'test/*.html',
- '**/*_test.html',
-]
-PY_TEST_PATTERNS = ['polygerrit_wct_tests.py']
-APP_SRCS = glob(
- ['**'],
- excludes = [
- 'BUCK',
- 'BUILD',
- 'index.html',
- 'test/**',
- ] + WCT_TEST_PATTERNS + PY_TEST_PATTERNS)
-
-# List libraries to be copied statically into the build. (i.e. Libraries not
-# expected to be Vulcanized.)
-WEB_JS_LIBS = [
- ('bower_components/webcomponentsjs', 'webcomponents-lite.js'),
- ('bower_components/highlightjs', 'highlight.min.js'),
-]
-
-# Map the static libraries to commands for the polygerrit_ui rule.
-JS_LIBS_MKDIR_CMDS = []
-JS_LIBS_UNZIP_CMDS = []
-for lib in WEB_JS_LIBS:
- JS_LIBS_MKDIR_CMDS.append('mkdir -p ' + lib[0])
- path = lib[0] + '/' + lib[1]
- cmd = 'unzip -p $(location //polygerrit-ui:polygerrit_components) %s>%s' % (path, path)
- JS_LIBS_UNZIP_CMDS.append(cmd)
-
-# TODO(dborowitz): Putting these rules in this package avoids having to handle
-# the app/ prefix like we would have to if this were in the parent directory.
-# The only reason for the app subdirectory in the first place was convenience
-# when witing server.go; when that goes away, we can just move all the files and
-# these rules up one directory.
-genrule(
- name = 'polygerrit_ui',
- cmd = ' && '.join([
- 'mkdir $TMP/polygerrit_ui',
- 'cd $TMP/polygerrit_ui',
- 'mkdir -p {fonts,elements}',
- ' && '.join(JS_LIBS_MKDIR_CMDS),
- 'unzip -qd . $(location //polygerrit-ui:fonts)',
- 'unzip -qd elements $(location :gr-app)',
- 'cp -rp $SRCDIR/* .',
- ' && '.join(JS_LIBS_UNZIP_CMDS),
- 'cd $TMP',
- 'zip -9qr $OUT .',
- ]),
- srcs = glob([
- 'favicon.ico',
- 'index.html',
- 'styles/**/*.css'
- ]),
- out = 'polygerrit_ui.zip',
- visibility = ['PUBLIC'],
-)
-
-vulcanize(
- name = 'gr-app',
- app = 'elements/gr-app.html',
- srcs = APP_SRCS,
- components = '//polygerrit-ui:polygerrit_components',
-)
-
-bower_components(
- name = 'test_components',
- deps = [
- '//polygerrit-ui:polygerrit_components',
- '//lib/js:iron-test-helpers',
- '//lib/js:test-fixture',
- '//lib/js:web-component-tester',
- ],
-)
-
-genrule(
- name = 'test_resources',
- cmd = ' && '.join([
- 'cd $TMP',
- 'unzip -q $(location :test_components)',
- 'cp -r $SRCDIR/* .',
- 'zip -r $OUT .',
- ]),
- srcs = APP_SRCS + glob(WCT_TEST_PATTERNS),
- out = 'test_resources.zip',
-)
-
-python_test(
- name = 'polygerrit_tests',
- srcs = glob(PY_TEST_PATTERNS),
- resources = [':test_resources'],
- labels = [
- 'manual',
- 'web',
- ],
-)
diff --git a/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item.html b/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item.html
index 202b1dd..0df017b 100644
--- a/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item.html
+++ b/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item.html
@@ -26,7 +26,7 @@
<template>
<style>
:host {
- display: flex;
+ display: table-row;
border-bottom: 1px solid #eee;
}
:host([selected]) {
@@ -42,7 +42,6 @@
background-color: #fcfaa6;
}
.cell {
- flex-shrink: 0;
padding: .3em .5em;
}
a {
@@ -71,6 +70,11 @@
.u-gray-background {
background-color: #F5F5F5;
}
+ @media only screen and (max-width: 50em) {
+ :host {
+ display: flex;
+ }
+ }
</style>
<style include="gr-change-list-styles"></style>
<td class="cell keyboard">
diff --git a/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list.html b/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list.html
index 9dcf54f..c9a8d64 100644
--- a/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list.html
+++ b/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list.html
@@ -25,16 +25,11 @@
<dom-module id="gr-change-list">
<template>
<style>
- :host {
- display: flex;
- flex-direction: column;
- }
#changeList {
border-collapse: collapse;
width: 100%;
}
.cell {
- flex-shrink: 0;
padding: .3em .5em;
}
th {
@@ -63,24 +58,30 @@
index-as="groupIndex">
<template is="dom-if" if="[[_groupTitle(groupIndex)]]">
<tr class="groupHeader">
- <td class="cell">[[_groupTitle(groupIndex)]]</td>
+ <td class="cell"
+ colspan$="[[_computeColspan(changeTableColumns, labelNames)]]">
+ [[_groupTitle(groupIndex)]]
+ </td>
</tr>
</template>
<template is="dom-if" if="[[!changeGroup.length]]">
- <tr class="noChanges"><td class="cell">No changes</td></tr>
+ <tr class="noChanges">
+ <td class="cell"
+ colspan$="[[_computeColspan(changeTableColumns, labelNames)]]">
+ No changes
+ </td>
+ </tr>
</template>
<template is="dom-repeat" items="[[changeGroup]]" as="change">
- <tr>
- <gr-change-list-item
- selected$="[[_computeItemSelected(index, groupIndex, selectedIndex)]]"
- assigned$="[[_computeItemAssigned(account, change)]]"
- needs-review$="[[_computeItemNeedsReview(account, change, showReviewedState)]]"
- change="[[change]]"
- visible-change-table-columns="[[visibleChangeTableColumns]]"
- show-number="[[showNumber]]"
- show-star="[[showStar]]"
- label-names="[[labelNames]]"></gr-change-list-item>
- </tr>
+ <gr-change-list-item
+ selected$="[[_computeItemSelected(index, groupIndex, selectedIndex)]]"
+ assigned$="[[_computeItemAssigned(account, change)]]"
+ needs-review$="[[_computeItemNeedsReview(account, change, showReviewedState)]]"
+ change="[[change]]"
+ visible-change-table-columns="[[visibleChangeTableColumns]]"
+ show-number="[[showNumber]]"
+ show-star="[[showStar]]"
+ label-names="[[labelNames]]"></gr-change-list-item>
</template>
</template>
</table>
diff --git a/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list.js b/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list.js
index eaa8527..9f943dc 100644
--- a/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list.js
+++ b/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list.js
@@ -14,6 +14,8 @@
(function() {
'use strict';
+ var NUMBER_FIXED_COLUMNS = 3;
+
Polymer({
is: 'gr-change-list',
@@ -133,6 +135,11 @@
return this.$.restAPI.getPreferences();
},
+ _computeColspan: function(changeTableColumns, labelNames) {
+ return changeTableColumns.length + labelNames.length +
+ NUMBER_FIXED_COLUMNS;
+ },
+
_computeLabelNames: function(groups) {
if (!groups) { return []; }
var labels = [];
diff --git a/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list_test.html b/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list_test.html
index 7742e48..0ac850c 100644
--- a/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list_test.html
+++ b/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list_test.html
@@ -117,6 +117,16 @@
'Some-Special-Label-7'), 'SSL7');
});
+ test('colspans', function() {
+ var thItemCount = Polymer.dom(element.root).querySelectorAll(
+ 'th').length;
+
+ var changeTableColumns = [];
+ var labelNames = [];
+ assert.equal(thItemCount, element._computeColspan(
+ changeTableColumns, labelNames));
+ });
+
test('keyboard shortcuts', function(done) {
element.selectedIndex = 0;
element.changes = [
diff --git a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.html b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.html
index b7a76a2..f54cfc9 100644
--- a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.html
+++ b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.html
@@ -19,6 +19,7 @@
<link rel="import" href="../../../behaviors/rest-client-behavior.html">
<link rel="import" href="../../shared/gr-button/gr-button.html">
+<link rel="import" href="../../shared/gr-dropdown/gr-dropdown.html">
<link rel="import" href="../../shared/gr-js-api-interface/gr-js-api-interface.html">
<link rel="import" href="../../shared/gr-overlay/gr-overlay.html">
<link rel="import" href="../../shared/gr-rest-api-interface/gr-rest-api-interface.html">
@@ -38,7 +39,8 @@
section {
display: inline-block;
}
- gr-button {
+ gr-button,
+ gr-dropdown {
margin-left: .5em;
}
gr-button:before {
@@ -63,29 +65,29 @@
}
</style>
<div>
- <section hidden$="[[_shouldHideActions(actions.*, _additionalActions.*, _loading)]]">
- <template is="dom-repeat" items="[[_changeActionValues]]" as="action">
+ <gr-dropdown
+ id="moreActions"
+ down-arrow
+ vertical-offset="32"
+ horizontal-align="right"
+ on-tap-item-abandon="_handleAbandonTap"
+ on-tap-item-cherrypick="_handleCherrypickTap"
+ on-tap-item-delete="_handleDeleteTap"
+ hidden$="[[_shouldHideActions(_menuActions.*, _loading)]]"
+ items="[[_menuActions]]">More</gr-dropdown>
+ <section hidden$="[[_shouldHideActions(_topLevelActions.*, _loading)]]">
+ <template
+ is="dom-repeat"
+ items="[[_topLevelActions]]"
+ as="action">
<gr-button title$="[[action.title]]"
- hidden$="[[_computeActionHidden(action.__key, _hiddenChangeActions.*)]]"
+ hidden$="[[_computeActionHidden(action.__key, _hiddenActions.*)]]"
primary$="[[action.__primary]]"
- hidden$="[[!action.enabled]]"
data-action-key$="[[action.__key]]"
data-action-type$="[[action.__type]]"
data-label$="[[action.label]]"
data-loading-label$="[[_computeLoadingLabel(action.__key)]]"
- on-tap="_handleActionTap"></gr-button>
- </template>
- </section>
- <section hidden$="[[_shouldHideActions(revisionActions.*, _additionalActions.*, _loading)]]">
- <template is="dom-repeat" items="[[_revisionActionValues]]" as="action">
- <gr-button title$="[[action.title]]"
- hidden$="[[_computeActionHidden(action.__key, _hiddenRevisionActions.*)]]"
- primary$="[[action.__primary]]"
disabled$="[[!action.enabled]]"
- data-action-key$="[[action.__key]]"
- data-action-type$="[[action.__type]]"
- data-label$="[[action.label]]"
- data-loading-label$="[[_computeLoadingLabel(action.__key)]]"
on-tap="_handleActionTap"></gr-button>
</template>
</section>
diff --git a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.js b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.js
index 6fdc3ad..331c3c5 100644
--- a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.js
+++ b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.js
@@ -87,6 +87,16 @@
method: 'POST',
};
+ /**
+ * Keys for actions to appear in the overflow menu rather than the top-level
+ * set of action buttons.
+ */
+ var MENU_ACTION_KEYS = [
+ 'abandon',
+ 'cherrypick',
+ '/', // '/' is the key for the delete action.
+ ];
+
Polymer({
is: 'gr-change-actions',
@@ -96,6 +106,12 @@
* @event reload-change
*/
+ /**
+ * Fired when an action is tapped.
+ *
+ * @event <action key>-tap
+ */
+
properties: {
change: Object,
actions: {
@@ -129,25 +145,26 @@
type: Boolean,
value: true,
},
- _revisionActionValues: {
+
+ _allActionValues: {
type: Array,
- computed: '_computeRevisionActionValues(revisionActions.*, ' +
- 'primaryActionKeys.*, _additionalActions.*)',
- },
- _changeActionValues: {
- type: Array,
- computed: '_computeChangeActionValues(actions.*, ' +
+ computed: '_computeAllActions(actions.*, revisionActions.*,' +
'primaryActionKeys.*, _additionalActions.*, change)',
},
+ _topLevelActions: {
+ type: Array,
+ computed: '_computeTopLevelActions(_allActionValues.*)',
+ },
+ _menuActions: {
+ type: Array,
+ computed: '_computeMenuActions(_allActionValues.*, _hiddenActions.*)',
+ },
+
_additionalActions: {
type: Array,
value: function() { return []; },
},
- _hiddenChangeActions: {
- type: Array,
- value: function() { return []; },
- },
- _hiddenRevisionActions: {
+ _hiddenActions: {
type: Array,
value: function() { return []; },
},
@@ -220,20 +237,15 @@
},
setActionHidden: function(type, key, hidden) {
- var path;
- if (type === ActionType.CHANGE) {
- path = '_hiddenChangeActions';
- } else if (type === ActionType.REVISION) {
- path = '_hiddenRevisionActions';
- } else {
+ if (type !== ActionType.CHANGE && type !== ActionType.REVISION) {
throw Error('Invalid action type given: ' + type);
}
- var idx = this.get(path).indexOf(key);
+ var idx = this._hiddenActions.indexOf(key);
if (hidden && idx === -1) {
- this.push(path, key);
+ this.push('_hiddenActions', key);
} else if (!hidden && idx !== -1) {
- this.splice(path, idx, 1);
+ this.splice('_hiddenActions', idx, 1);
}
},
@@ -251,16 +263,8 @@
this.patchNum);
},
- _shouldHideActions: function(actionsRecord, additionalActionsRecord,
- loading) {
- if (loading) { return true; }
- return !this._actionCount(actionsRecord, additionalActionsRecord);
- },
-
- _actionCount: function(actionsRecord, additionalActionsRecord) {
- var additionalActions = (additionalActionsRecord &&
- additionalActionsRecord.base) || [];
- return this._keyCount(actionsRecord) + additionalActions.length;
+ _shouldHideActions: function(actions, loading) {
+ return loading || !actions || !actions.base || !actions.base.length;
},
_keyCount: function(changeRecord) {
@@ -282,24 +286,6 @@
});
},
- _computeRevisionActionValues: function(actionsChangeRecord,
- primariesChangeRecord, additionalActionsChangeRecord) {
- return this._getActionValues(actionsChangeRecord, primariesChangeRecord,
- additionalActionsChangeRecord, ActionType.REVISION);
- },
-
- _computeChangeActionValues: function(actionsChangeRecord,
- primariesChangeRecord, additionalActionsChangeRecord, change) {
- var actions = this._getActionValues(
- actionsChangeRecord, primariesChangeRecord,
- additionalActionsChangeRecord, ActionType.CHANGE, change);
- var quickApprove = this._getQuickApproveAction();
- if (quickApprove) {
- actions.unshift(quickApprove);
- }
- return actions;
- },
-
_getLabelStatus: function(label) {
if (label.approved) {
return LabelStatus.OK;
@@ -466,14 +452,10 @@
var type = el.getAttribute('data-action-type');
if (type === ActionType.REVISION) {
this._handleRevisionAction(key);
- } else if (key === ChangeActions.DELETE) {
- this._showActionDialog(this.$.confirmDeleteDialog);
} else if (key === ChangeActions.REVERT) {
this.showRevertDialog();
- } else if (key === ChangeActions.ABANDON) {
- this._showActionDialog(this.$.confirmAbandonDialog);
} else if (key === QUICK_APPROVE_ACTION.key) {
- var action = this._changeActionValues.find(function(o) {
+ var action = this._allActionValues.find(function(o) {
return o.key === key;
});
this._fireAction(
@@ -488,10 +470,6 @@
case RevisionActions.REBASE:
this._showActionDialog(this.$.confirmRebase);
break;
- case RevisionActions.CHERRYPICK:
- this.$.confirmCherrypick.branch = '';
- this._showActionDialog(this.$.confirmCherrypick);
- break;
case RevisionActions.SUBMIT:
if (!this._canSubmitChange()) {
return;
@@ -664,5 +642,92 @@
return response;
}.bind(this)).then(this._handleResponseError.bind(this));
},
+
+ _handleAbandonTap: function() {
+ this._showActionDialog(this.$.confirmAbandonDialog);
+ },
+
+ _handleCherrypickTap: function() {
+ this.$.confirmCherrypick.branch = '';
+ this._showActionDialog(this.$.confirmCherrypick);
+ },
+
+ _handleDeleteTap: function() {
+ this._showActionDialog(this.$.confirmDeleteDialog);
+ },
+
+ /**
+ * Merge sources of change actions into a single ordered array of action
+ * values.
+ * @param {splices} changeActionsRecord
+ * @param {splices} revisionActionsRecord
+ * @param {splices} primariesRecord
+ * @param {splices} additionalActionsRecord
+ * @param {Object} change The change object.
+ * @return {Array}
+ */
+ _computeAllActions: function(changeActionsRecord, revisionActionsRecord,
+ primariesRecord, additionalActionsRecord, change) {
+ var revisionActionValues = this._getActionValues(revisionActionsRecord,
+ primariesRecord, additionalActionsRecord, ActionType.REVISION);
+ var changeActionValues = this._getActionValues(changeActionsRecord,
+ primariesRecord, additionalActionsRecord, ActionType.CHANGE, change);
+ var quickApprove = this._getQuickApproveAction();
+ if (quickApprove) {
+ changeActionValues.unshift(quickApprove);
+ }
+ return revisionActionValues
+ .concat(changeActionValues)
+ .sort(this._actionComparator);
+ },
+
+ /**
+ * Sort comparator to define the order of change actions.
+ */
+ _actionComparator: function(actionA, actionB) {
+ // The code review action always appears first.
+ if (actionA.__key === 'review') {
+ return -1;
+ } else if (actionB.__key === 'review') {
+ return 1;
+ }
+
+ // Primary actions always appear last.
+ if (actionA.__primary) {
+ return 1;
+ } else if (actionB.__primary) {
+ return -1;
+ }
+
+ // Change actions appear before revision actions.
+ if (actionA.__type === 'change' && actionB.__type === 'revision') {
+ return -1;
+ } else if (actionA.__type === 'revision' && actionB.__type === 'change') {
+ return 1;
+ }
+
+ // Otherwise, sort by the button label.
+ return actionA.label > actionB.label ? 1 : -1;
+ },
+
+ _computeTopLevelActions: function(actionRecord) {
+ return actionRecord.base.filter(function(a) {
+ return MENU_ACTION_KEYS.indexOf(a.__key) === -1;
+ });
+ },
+
+ _computeMenuActions: function(actionRecord, hiddenActionsRecord) {
+ var hiddenActions = hiddenActionsRecord.base || [];
+ return actionRecord.base
+ .filter(function(a) {
+ return MENU_ACTION_KEYS.indexOf(a.__key) !== -1 &&
+ hiddenActions.indexOf(a.__key) === -1;
+ })
+ .map(function(action) {
+ var key = action.__key;
+ if (key === '/') { key = 'delete'; }
+ return {name: action.label, id: key, };
+ });
+ },
});
})();
diff --git a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_test.html b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_test.html
index 7dbd903..dbdf00f 100644
--- a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_test.html
+++ b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_test.html
@@ -99,11 +99,9 @@
});
test('_shouldHideActions', function() {
- assert.isTrue(element._shouldHideActions(undefined, undefined, true));
- assert.isTrue(element._shouldHideActions({base: {}},
- {base: []}, false));
- assert.isFalse(element._shouldHideActions({base: { test: 'test' }},
- {base: ['test']}, false));
+ assert.isTrue(element._shouldHideActions(undefined, true));
+ assert.isTrue(element._shouldHideActions({base: {}}, false));
+ assert.isFalse(element._shouldHideActions({base: ['test']}, false));
});
test('hide revision action', function(done) {
@@ -114,10 +112,10 @@
assert.throws(element.setActionHidden.bind(element, 'invalid type'));
element.setActionHidden(element.ActionType.REVISION,
element.RevisionActions.SUBMIT, true);
- assert.lengthOf(element._hiddenRevisionActions, 1);
+ assert.lengthOf(element._hiddenActions, 1);
element.setActionHidden(element.ActionType.REVISION,
element.RevisionActions.SUBMIT, true);
- assert.lengthOf(element._hiddenRevisionActions, 1);
+ assert.lengthOf(element._hiddenActions, 1);
flush(function() {
var buttonEl = element.$$('[data-action-key="submit"]');
assert.isOk(buttonEl);
@@ -135,29 +133,26 @@
});
});
- test('hide change action', function(done) {
+ test('hide menu action', function(done) {
flush(function() {
- var buttonEl = element.$$('[data-action-key="/"]');
+ var buttonEl = element.$.moreActions.$$('span[data-id="delete"]');
assert.isOk(buttonEl);
- assert.isFalse(buttonEl.hasAttribute('hidden'));
assert.throws(element.setActionHidden.bind(element, 'invalid type'));
element.setActionHidden(element.ActionType.CHANGE,
element.ChangeActions.DELETE, true);
- assert.lengthOf(element._hiddenChangeActions, 1);
+ assert.lengthOf(element._hiddenActions, 1);
element.setActionHidden(element.ActionType.CHANGE,
element.ChangeActions.DELETE, true);
- assert.lengthOf(element._hiddenChangeActions, 1);
+ assert.lengthOf(element._hiddenActions, 1);
flush(function() {
- var buttonEl = element.$$('[data-action-key="/"]');
- assert.isOk(buttonEl);
- assert.isTrue(buttonEl.hasAttribute('hidden'));
+ var buttonEl = element.$.moreActions.$$('span[data-id="delete"]');
+ assert.isNotOk(buttonEl);
element.setActionHidden(element.ActionType.CHANGE,
element.RevisionActions.DELETE, false);
flush(function() {
- var buttonEl = element.$$('[data-action-key="/"]');
+ var buttonEl = element.$.moreActions.$$('span[data-id="delete"]');
assert.isOk(buttonEl);
- assert.isFalse(buttonEl.hasAttribute('hidden'));
done();
});
});
@@ -169,7 +164,8 @@
flush(function() {
var buttonEls = Polymer.dom(element.root)
.querySelectorAll('gr-button');
- assert.equal(buttonEls.length, 6);
+ var menuItems = element.$.moreActions.items;
+ assert.equal(buttonEls.length + menuItems.length, 6);
assert.isFalse(element.hidden);
done();
});
@@ -177,18 +173,18 @@
test('delete buttons have explicit labels', function(done) {
flush(function() {
- var buttonEls =
- Polymer.dom(element.root).querySelectorAll('[data-action-key="/"]');
- assert.equal(buttonEls.length, 2);
- assert.notEqual(buttonEls[0].getAttribute('data-label'),
- buttonEls[1].getAttribute['data-label']);
+ var deleteItems = element.$.moreActions.items.filter(function(item) {
+ return item.id === 'delete';
+ });
+ assert.equal(deleteItems.length, 2);
+ assert.notEqual(deleteItems[0].name, deleteItems[1].name)
assert.isTrue(
- buttonEls[0].getAttribute('data-label') === 'Delete Revision' ||
- buttonEls[0].getAttribute('data-label') === 'Delete Change'
+ deleteItems[0].name === 'Delete Revision' ||
+ deleteItems[0].name === 'Delete Change'
);
assert.isTrue(
- buttonEls[1].getAttribute('data-label') === 'Delete Revision' ||
- buttonEls[1].getAttribute('data-label') === 'Delete Change'
+ deleteItems[1].name === 'Delete Revision' ||
+ deleteItems[1].name === 'Delete Change'
);
done();
});
@@ -205,6 +201,18 @@
assert.deepEqual(element._getRevision(change, '2'), revObj);
});
+ test('_actionComparator sort order', function() {
+ var actions = [
+ {label: '123', type: 'change', __key: 'review'},
+ {label: 'abc',type: 'revision'},
+ {label: 'abc',type: 'change'},
+ {label: 'def', type: 'change'},
+ {label: 'def', type: 'change',__primary: true},
+ ];
+ var result = actions.slice().sort(element._actionComparator);
+ assert.deepEqual(result, actions);
+ });
+
test('submit change', function(done) {
element.change = {
revisions: {
@@ -285,10 +293,7 @@
flushAsynchronousOperations();
assert.isFalse(element.$.confirmRebase.hidden);
- var cherryPickButton =
- element.$$('gr-button[data-action-key="cherrypick"]');
- assert.ok(cherryPickButton);
- MockInteractions.tap(cherryPickButton);
+ element._handleCherrypickTap();
flushAsynchronousOperations();
assert.isTrue(element.$.confirmRebase.hidden);
assert.isFalse(element.$.confirmCherrypick.hidden);
@@ -311,9 +316,7 @@
});
test('works', function() {
- var cherryPickButton =
- element.$$('gr-button[data-action-key="cherrypick"]');
- MockInteractions.tap(cherryPickButton);
+ element._handleCherrypickTap();
var action = {
__key: 'cherrypick',
__type: 'revision',
@@ -350,12 +353,10 @@
});
test('branch name cleared when re-open cherrypick', function() {
- var cherryPickButton =
- element.$$('gr-button[data-action-key="cherrypick"]');
var emptyBranchName = '';
element.$.confirmCherrypick.branch = 'master';
- MockInteractions.tap(cherryPickButton);
+ element._handleCherrypickTap();
assert.equal(element.$.confirmCherrypick.branch, emptyBranchName);
});
});
@@ -457,12 +458,6 @@
var fireActionStub;
var deleteAction;
- var tapDeleteAction = function() {
- var deleteButton = element.$$('gr-button[data-action-key=\'/\']');
- MockInteractions.tap(deleteButton);
- flushAsynchronousOperations();
- };
-
setup(function() {
fireActionStub = sinon.stub(element, '_fireAction');
element.change = {
@@ -484,12 +479,12 @@
});
test('does not delete on action', function() {
- tapDeleteAction();
+ element._handleDeleteTap();
assert.isFalse(fireActionStub.called);
});
test('shows confirm dialog', function() {
- tapDeleteAction();
+ element._handleDeleteTap();
assert.isFalse(element.$$('#confirmDeleteDialog').hidden);
MockInteractions.tap(
element.$$('#confirmDeleteDialog').$$('gr-button[primary]'));
@@ -498,7 +493,7 @@
});
test('hides delete confirm on cancel', function() {
- tapDeleteAction();
+ element._handleDeleteTap();
MockInteractions.tap(
element.$$('#confirmDeleteDialog').$$('gr-button:not([primary])'));
flushAsynchronousOperations();
diff --git a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.html b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.html
index 18dfdc0..873acddc 100644
--- a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.html
+++ b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.html
@@ -255,12 +255,14 @@
<a href$="[[_computeChangePermalink(_change._number)]]">[[_change._number]]</a><!--
--><template is="dom-if" if="[[_changeStatus]]">
([[_changeStatus]]<!--
- --><template is="dom-if" if="[[_computeShowCommitInfo(_changeStatus)]]">
+ --><template
+ is="dom-if"
+ if="[[_computeShowCommitInfo(_changeStatus, _change.current_revision)]]">
as
<gr-commit-info
- change="[[_change]]"
- commit-info="[[_computeMergedCommitInfo(_change.current_revision, _change.revisions)]]"
- server-config="[[serverConfig]]"></gr-commit-info><!--
+ change="[[_change]]"
+ commit-info="[[_computeMergedCommitInfo(_change.current_revision, _change.revisions)]]"
+ server-config="[[serverConfig]]"></gr-commit-info><!--
--></template><!--
-->)<!--
--></template><!--
diff --git a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.js b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.js
index d66917c..9c7ce99 100644
--- a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.js
+++ b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.js
@@ -563,8 +563,8 @@
return statusString || '';
},
- _computeShowCommitInfo: function(changeStatus) {
- return changeStatus === 'Merged';
+ _computeShowCommitInfo: function(changeStatus, current_revision) {
+ return changeStatus === 'Merged' && current_revision;
},
_computeMergedCommitInfo: function(current_revision, revisions) {
diff --git a/polygerrit-ui/app/elements/change/gr-messages-list/gr-messages-list.js b/polygerrit-ui/app/elements/change/gr-messages-list/gr-messages-list.js
index 4dd9625..c1b5de2 100644
--- a/polygerrit-ui/app/elements/change/gr-messages-list/gr-messages-list.js
+++ b/polygerrit-ui/app/elements/change/gr-messages-list/gr-messages-list.js
@@ -146,7 +146,7 @@
},
_computeAutomatedToggleText: function(hideAutomated) {
- return hideAutomated ? 'Show automated' : 'Hide automated';
+ return hideAutomated ? 'Show all messages' : 'Show comments only';
},
/**
diff --git a/polygerrit-ui/app/elements/core/gr-account-dropdown/gr-account-dropdown.html b/polygerrit-ui/app/elements/core/gr-account-dropdown/gr-account-dropdown.html
index cead416..07c922a 100644
--- a/polygerrit-ui/app/elements/core/gr-account-dropdown/gr-account-dropdown.html
+++ b/polygerrit-ui/app/elements/core/gr-account-dropdown/gr-account-dropdown.html
@@ -34,7 +34,10 @@
vertical-align: middle;
}
</style>
- <gr-dropdown items=[[links]] top-content=[[topContent]]
+ <gr-dropdown
+ link
+ items=[[links]]
+ top-content=[[topContent]]
horizontal-align="right">
<span hidden$="[[_hasAvatars]]" hidden>[[account.name]]</span>
<gr-avatar account="[[account]]" hidden$="[[!_hasAvatars]]" hidden
diff --git a/polygerrit-ui/app/elements/core/gr-keyboard-shortcuts-dialog/gr-keyboard-shortcuts-dialog.html b/polygerrit-ui/app/elements/core/gr-keyboard-shortcuts-dialog/gr-keyboard-shortcuts-dialog.html
index 7ab74a5..94e15b6 100644
--- a/polygerrit-ui/app/elements/core/gr-keyboard-shortcuts-dialog/gr-keyboard-shortcuts-dialog.html
+++ b/polygerrit-ui/app/elements/core/gr-keyboard-shortcuts-dialog/gr-keyboard-shortcuts-dialog.html
@@ -134,8 +134,8 @@
</table>
<table>
- <!-- Change List and Dashboard -->
- <tbody hidden$="[[!_computeInChangeListView(view)]]" hidden>
+ <!-- Change List -->
+ <tbody hidden$="[[!_computeInView(view, 'gr-change-list-view')]]" hidden>
<tr>
<td></td><td class="header">Change list</td>
</tr>
@@ -148,6 +148,35 @@
<td>Show previous change</td>
</tr>
<tr>
+ <td><span class="key">n</span> or <span class="key">]</span></td>
+ <td>Go to next page</td>
+ </tr>
+ <tr>
+ <td><span class="key">p</span> or <span class="key">[</span></td>
+ <td>Go to previous page</td>
+ </tr>
+ <tr>
+ <td>
+ <span class="key">Enter</span> or
+ <span class="key">o</span>
+ </td>
+ <td>Show selected change</td>
+ </tr>
+ </tbody>
+ <!-- Dashboard -->
+ <tbody hidden$="[[!_computeInView(view, 'gr-dashboard-view')]]" hidden>
+ <tr>
+ <td></td><td class="header">Dashboard</td>
+ </tr>
+ <tr>
+ <td><span class="key">j</span></td>
+ <td>Select next change</td>
+ </tr>
+ <tr>
+ <td><span class="key">k</span></td>
+ <td>Show previous change</td>
+ </tr>
+ <tr>
<td>
<span class="key">Enter</span> or
<span class="key">o</span>
diff --git a/polygerrit-ui/app/elements/core/gr-keyboard-shortcuts-dialog/gr-keyboard-shortcuts-dialog.js b/polygerrit-ui/app/elements/core/gr-keyboard-shortcuts-dialog/gr-keyboard-shortcuts-dialog.js
index 7ed5012..1a286c7 100644
--- a/polygerrit-ui/app/elements/core/gr-keyboard-shortcuts-dialog/gr-keyboard-shortcuts-dialog.js
+++ b/polygerrit-ui/app/elements/core/gr-keyboard-shortcuts-dialog/gr-keyboard-shortcuts-dialog.js
@@ -32,12 +32,7 @@
},
_computeInView: function(currentView, view) {
- return view == currentView;
- },
-
- _computeInChangeListView: function(currentView) {
- return currentView == 'gr-change-list-view' ||
- currentView == 'gr-dashboard-view';
+ return view === currentView;
},
_handleCloseTap: function(e) {
diff --git a/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header.html b/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header.html
index c3d9b16..74dc9e7 100644
--- a/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header.html
+++ b/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header.html
@@ -52,23 +52,8 @@
.linksTitle {
color: black;
display: inline-block;
- padding-right: 1em;
position: relative;
}
- .downArrow {
- border-left: .36em solid transparent;
- border-right: .36em solid transparent;
- border-top: .36em solid #ccc;
- height: 0;
- position: absolute;
- right: 0;
- top: calc(50% - .05em);
- transition: border-top-color 200ms;
- width: 0;
- }
- .links li:hover .downArrow {
- border-top-color: #666;
- }
.rightItems {
align-items: center;
display: flex;
@@ -119,10 +104,12 @@
<template is="dom-repeat" items="[[_links]]" as="linkGroup">
<li>
<gr-dropdown
+ link
+ down-arrow
items = [[linkGroup.links]]
horizontal-align="left">
<span class="linksTitle" id="[[linkGroup.title]]">
- [[linkGroup.title]] <i class="downArrow"></i>
+ [[linkGroup.title]]
</span>
</gr-dropdown>
</li>
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-comment/gr-diff-comment.html b/polygerrit-ui/app/elements/diff/gr-diff-comment/gr-diff-comment.html
index 1a0ba99..ceedf73 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-comment/gr-diff-comment.html
+++ b/polygerrit-ui/app/elements/diff/gr-diff-comment/gr-diff-comment.html
@@ -241,10 +241,12 @@
<gr-button class="action cancel hideOnPublished"
on-tap="_handleCancel" hidden>Cancel</gr-button>
<div class="action resolve hideOnPublished">
- <input type="checkbox"
- checked$="[[resolved]]"
- on-change="_handleToggleResolved">
- <label>Resolved</label>
+ <label>
+ <input type="checkbox"
+ checked$="[[resolved]]"
+ on-change="_handleToggleResolved">
+ Resolved
+ </label>
</div>
<div class="danger">
<gr-button class="action discard hideOnPublished"
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-selection/gr-diff-selection.js b/polygerrit-ui/app/elements/diff/gr-diff-selection/gr-diff-selection.js
index f0f2c3b..10f04c6 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-selection/gr-diff-selection.js
+++ b/polygerrit-ui/app/elements/diff/gr-diff-selection/gr-diff-selection.js
@@ -113,7 +113,7 @@
var commentSelected = false;
var target = this._getCopyEventTarget(e);
if (target.type === 'textarea') { return; }
- if (!this._elementDescendedFromClass(target, 'content')) { return; }
+ if (!this._elementDescendedFromClass(target, 'diff-row')) { return; }
if (this.classList.contains(SelectionClass.COMMENT)) {
commentSelected = true;
}
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-selection/gr-diff-selection_test.html b/polygerrit-ui/app/elements/diff/gr-diff-selection/gr-diff-selection_test.html
index 76bf4ec..d517a80 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-selection/gr-diff-selection_test.html
+++ b/polygerrit-ui/app/elements/diff/gr-diff-selection/gr-diff-selection_test.html
@@ -28,7 +28,7 @@
<template>
<gr-diff-selection>
<table id="diffTable" class="side-by-side">
- <tr>
+ <tr class="diff-row">
<td class="lineNum left" data-value="1">1</td>
<td class="content">
<div class="contentText" data-side="left">ba ba</div>
@@ -45,7 +45,7 @@
<div class="contentText" data-side="right">some other text</div>
</td>
</tr>
- <tr>
+ <tr class="diff-row">
<td class="lineNum left" data-value="2">2</td>
<td class="content">
<div class="contentText" data-side="left">zin</div>
@@ -62,7 +62,7 @@
</div>
</td>
</tr>
- <tr>
+ <tr class="diff-row">
<td class="lineNum left" data-value="3">3</td>
<td class="content">
<div class="contentText" data-side="left">ga ga</div>
@@ -75,11 +75,8 @@
</div>
</td>
<td class="lineNum right" data-value="3">3</td>
- <td class="other">
- <div class="contentText" data-side="right">some other text</div>
- </td>
</tr>
- <tr>
+ <tr class="diff-row">
<td class="lineNum left" data-value="4">4</td>
<td class="content">
<div class="contentText" data-side="left">ga ga</div>
@@ -91,6 +88,11 @@
</td>
<td class="lineNum right" data-value="4">4</td>
</tr>
+ <tr class="not-diff-row">
+ <td class="other">
+ <div class="contentText" data-side="right">some other text</div>
+ </td>
+ </tr>
</table>
</gr-diff-selection>
</template>
@@ -168,7 +170,7 @@
test('ignores copy for non-content Element', function() {
sandbox.stub(element, '_getSelectedText');
- emulateCopyOn(element.querySelector('.other'));
+ emulateCopyOn(element.querySelector('.not-diff-row'));
assert.isFalse(element._getSelectedText.called);
});
diff --git a/polygerrit-ui/app/elements/shared/gr-button/gr-button.html b/polygerrit-ui/app/elements/shared/gr-button/gr-button.html
index 5c12381..b69d369 100644
--- a/polygerrit-ui/app/elements/shared/gr-button/gr-button.html
+++ b/polygerrit-ui/app/elements/shared/gr-button/gr-button.html
@@ -80,8 +80,8 @@
:host([loading][disabled]) {
cursor: wait;
}
- :host(:focus:not([primary]):not([secondary]):not([disabled])),
- :host(:hover:not([primary]):not([secondary]):not([disabled])) {
+ :host:focus:not([link]),
+ :host:hover:not([link]) {
background-color: #f8f8f8;
border-color: #aaa;
}
@@ -97,6 +97,7 @@
}
:host([primary]:focus) {
box-shadow: 0 0 1px #00f;
+ background-color: #4d90fe;
}
:host([primary]:not([disabled]):hover) {
background-color: #4d90fe;
@@ -111,6 +112,7 @@
}
:host([secondary]:focus) {
box-shadow: 0 0 1px #f00;
+ background-color: #d14836;
}
:host([secondary]:not([disabled]):hover) {
background-color: #c53727;
diff --git a/polygerrit-ui/app/elements/shared/gr-button/gr-button.js b/polygerrit-ui/app/elements/shared/gr-button/gr-button.js
index 7e91b0e..800b1df 100644
--- a/polygerrit-ui/app/elements/shared/gr-button/gr-button.js
+++ b/polygerrit-ui/app/elements/shared/gr-button/gr-button.js
@@ -18,6 +18,10 @@
is: 'gr-button',
properties: {
+ link: {
+ type: Boolean,
+ reflectToAttribute: true,
+ },
disabled: {
type: Boolean,
observer: '_disabledChanged',
diff --git a/polygerrit-ui/app/elements/shared/gr-cursor-manager/gr-cursor-manager.js b/polygerrit-ui/app/elements/shared/gr-cursor-manager/gr-cursor-manager.js
index 704cef2..f2392a9 100644
--- a/polygerrit-ui/app/elements/shared/gr-cursor-manager/gr-cursor-manager.js
+++ b/polygerrit-ui/app/elements/shared/gr-cursor-manager/gr-cursor-manager.js
@@ -186,6 +186,11 @@
// If we failed to satisfy the condition:
if (opt_condition && !opt_condition(this.stops[newIndex])) {
+ if (delta > 0) {
+ return this.stops.length - 1;
+ } else if (delta < 0) {
+ return 0;
+ }
return this.index;
}
@@ -207,26 +212,36 @@
},
/**
- * @return {boolean}
+ * Calculate where the element is relative to the window.
+ * @param {object} target Target to scroll to.
+ * @return {number} Distance to top of the target.
*/
- _targetIsVisible: function() {
- // Calculate where the element is relative to the window.
- var top = this.target.offsetTop;
- for (var offsetParent = this.target.offsetParent;
+ _getTop: function(target) {
+ var top = target.offsetTop;
+ for (var offsetParent = target.offsetParent;
offsetParent;
offsetParent = offsetParent.offsetParent) {
top += offsetParent.offsetTop;
}
+ return top;
+ },
+ /**
+ * @return {boolean}
+ */
+ _targetIsVisible: function(top) {
return this.scrollBehavior === ScrollBehavior.KEEP_VISIBLE &&
top > window.pageYOffset &&
top < window.pageYOffset + window.innerHeight;
},
_scrollToTarget: function() {
- if (!this.target ||
- this.scrollBehavior === ScrollBehavior.NEVER ||
- this._targetIsVisible()) {
+ if (!this.target || this.scrollBehavior === ScrollBehavior.NEVER) {
+ return;
+ }
+
+ var top = this._getTop(this.target);
+ if (this._targetIsVisible(top)) {
return;
}
diff --git a/polygerrit-ui/app/elements/shared/gr-cursor-manager/gr-cursor-manager_test.html b/polygerrit-ui/app/elements/shared/gr-cursor-manager/gr-cursor-manager_test.html
index 884c01d..e0a3c0a 100644
--- a/polygerrit-ui/app/elements/shared/gr-cursor-manager/gr-cursor-manager_test.html
+++ b/polygerrit-ui/app/elements/shared/gr-cursor-manager/gr-cursor-manager_test.html
@@ -137,5 +137,33 @@
element.setCursorAtIndex(2);
assert.isTrue(scrollStub.called);
});
+
+ test('_getNextindex', function() {
+ var isLetterB = function(row) {
+ return row.textContent === 'B';
+ };
+ element.stops = list.querySelectorAll('li');
+ // Start cursor at the first stop.
+ element.setCursor(list.children[0]);
+
+ // Move forward to meet the next condition.
+ assert.equal(element._getNextindex(1, isLetterB), 1);
+ element.index = 1;
+
+ // Nothing else meets the condition, should be at last stop.
+ assert.equal(element._getNextindex(1, isLetterB), 3);
+ element.index = 3;
+
+ // Should stay at last stop if try to proceed.
+ assert.equal(element._getNextindex(1, isLetterB), 3);
+
+ // Go back to the previous condition met. Should be back at.
+ // stop 1.
+ assert.equal(element._getNextindex(-1, isLetterB), 1);
+ element.index = 1;
+
+ // Go back. No more meet the condition. Should be at stop 0.
+ assert.equal(element._getNextindex(-1, isLetterB), 0);
+ });
});
</script>
diff --git a/polygerrit-ui/app/elements/shared/gr-dropdown/gr-dropdown.html b/polygerrit-ui/app/elements/shared/gr-dropdown/gr-dropdown.html
index 95b03fc..f640dd6 100644
--- a/polygerrit-ui/app/elements/shared/gr-dropdown/gr-dropdown.html
+++ b/polygerrit-ui/app/elements/shared/gr-dropdown/gr-dropdown.html
@@ -38,6 +38,9 @@
font: inherit;
padding: .3em 0;
}
+ :host[down-arrow] .dropdown-trigger {
+ padding-right: 1.4em;
+ }
gr-avatar {
height: 2em;
width: 2em;
@@ -46,11 +49,6 @@
gr-button[link] {
padding: 1em 0;
}
- gr-button:focus:not([primary]):not([secondary]),
- gr-button:hover:not([primary]):not([secondary]) {
- background-color: transparent;
- border-color: transparent;
- }
ul {
list-style: none;
}
@@ -58,16 +56,17 @@
font-weight: bold;
}
li .accountInfo,
- li a {
+ li .itemAction {
+ cursor: pointer;
display: block;
padding: .85em 1em;
}
- li a:link,
- li a:visited {
+ li .itemAction:link,
+ li .itemAction:visited {
color: #00e;
text-decoration: none;
}
- li a:hover {
+ li .itemAction:hover {
background-color: #6B82D6;
color: #fff;
}
@@ -78,14 +77,30 @@
.bold-text {
font-weight: bold;
}
+ :host:not([down-arrow]) .downArrow { display: none; }
+ :host[down-arrow] .downArrow {
+ border-left: .36em solid transparent;
+ border-right: .36em solid transparent;
+ border-top: .36em solid #ccc;
+ height: 0;
+ position: absolute;
+ right: .3em;
+ top: calc(50% - .05em);
+ transition: border-top-color 200ms;
+ width: 0;
+ }
+ .dropdown-trigger:hover .downArrow {
+ border-top-color: #666;
+ }
</style>
- <gr-button link class="dropdown-trigger" id="trigger"
+ <gr-button link="[[link]]" class="dropdown-trigger" id="trigger"
on-tap="_showDropdownTapHandler">
<content></content>
+ <i class="downArrow"></i>
</gr-button>
<iron-dropdown id="dropdown"
vertical-align="top"
- vertical-offset="40"
+ vertical-offset="[[verticalOffset]]"
allow-outside-scroll="true"
horizontal-align="[[horizontalAlign]]"
on-tap="_handleDropdownTap">
@@ -109,7 +124,16 @@
items="[[items]]"
as="link"
initial-count="75">
- <li><a href$="[[_computeRelativeURL(link.url)]]">[[link.name]]</a>
+ <li>
+ <span
+ class="itemAction"
+ data-id$="[[link.id]]"
+ on-tap="_handleItemTap"
+ hidden$="[[link.url]]">[[link.name]]</span>
+ <a
+ class="itemAction"
+ href$="[[_computeRelativeURL(link.url)]]"
+ hidden$="[[!link.url]]">[[link.name]]</a>
</li>
</template>
</ul>
diff --git a/polygerrit-ui/app/elements/shared/gr-dropdown/gr-dropdown.js b/polygerrit-ui/app/elements/shared/gr-dropdown/gr-dropdown.js
index d10d219..d1fae7f 100644
--- a/polygerrit-ui/app/elements/shared/gr-dropdown/gr-dropdown.js
+++ b/polygerrit-ui/app/elements/shared/gr-dropdown/gr-dropdown.js
@@ -17,6 +17,12 @@
Polymer({
is: 'gr-dropdown',
+ /**
+ * Fired when a non-link dropdown item with the given ID is tapped.
+ *
+ * @event tap-item-<id>
+ */
+
properties: {
items: Array,
topContent: Object,
@@ -24,6 +30,20 @@
type: String,
value: 'left',
},
+
+ /**
+ * Style the dropdown trigger as a link (rather than a button).
+ */
+ link: {
+ type: Boolean,
+ value: false,
+ },
+
+ verticalOffset: {
+ type: Number,
+ value: 40,
+ },
+
_hasAvatars: String,
},
@@ -53,5 +73,10 @@
var host = window.location.host;
return this._computeURLHelper(host, path);
},
+
+ _handleItemTap: function(e) {
+ var id = e.target.getAttribute('data-id');
+ if (id) { this.dispatchEvent(new CustomEvent('tap-item-' + id)); }
+ },
});
})();
diff --git a/polygerrit-ui/app/elements/shared/gr-dropdown/gr-dropdown_test.html b/polygerrit-ui/app/elements/shared/gr-dropdown/gr-dropdown_test.html
index b2f2d21..2794caf 100644
--- a/polygerrit-ui/app/elements/shared/gr-dropdown/gr-dropdown_test.html
+++ b/polygerrit-ui/app/elements/shared/gr-dropdown/gr-dropdown_test.html
@@ -70,5 +70,15 @@
assert.isTrue(topItems[0].classList.contains('bold-text'));
assert.isFalse(topItems[1].classList.contains('bold-text'));
});
+
+ test('non link items', function() {
+ element.items = [
+ {name: 'item one', id: 'foo'}, {name: 'item two', id: 'bar'}];
+ var stub = sinon.stub();
+ element.addEventListener('tap-item-foo', stub);
+ flushAsynchronousOperations();
+ MockInteractions.tap(element.$$('.itemAction'));
+ assert.isTrue(stub.called);
+ });
});
</script>
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-change-actions-js-api_test.html b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-change-actions-js-api_test.html
index 93e676c..c02583a 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-change-actions-js-api_test.html
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-change-actions-js-api_test.html
@@ -49,6 +49,7 @@
setup(function() {
element = fixture('basic');
+ element.change = {};
var plugin;
Gerrit.install(function(p) { plugin = p; }, '0.1',
'http://test.com/plugins/testplugin/static/test.js');
diff --git a/polygerrit-ui/app/polygerrit_wct_tests.py b/polygerrit-ui/app/polygerrit_wct_tests.py
deleted file mode 100644
index eb34fef..0000000
--- a/polygerrit-ui/app/polygerrit_wct_tests.py
+++ /dev/null
@@ -1,118 +0,0 @@
-# Copyright (C) 2015 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-from __future__ import print_function
-
-import atexit
-from distutils import spawn
-import json
-import os
-import pkg_resources
-import shlex
-import shutil
-import subprocess
-import sys
-import tempfile
-import unittest
-import zipfile
-
-
-def _write_wct_conf(root, exports):
- with open(os.path.join(root, 'wct.conf.js'), 'w') as f:
- f.write('module.exports = %s;\n' % json.dumps(exports))
-
-
-def _wct_cmd():
- return ['wct'] + shlex.split(os.environ.get('WCT_ARGS', ''))
-
-
-class PolyGerritWctTests(unittest.TestCase):
-
- # Should really be setUpClass/tearDownClass, but Buck's test runner doesn't
- # produce sane stack traces from those methods. There's only one test method
- # anyway, so just use setUp.
-
- def _check_wct(self):
- self.assertTrue(
- spawn.find_executable('wct'),
- msg='wct not found; try `npm install -g web-component-tester`')
-
- def _extract_resources(self):
- tmpdir = tempfile.mkdtemp()
- atexit.register(lambda: shutil.rmtree(tmpdir))
- root = os.path.join(tmpdir, 'polygerrit')
- os.mkdir(root)
-
- tr = 'test_resources.zip'
- zip_path = os.path.join(tmpdir, tr)
- s = pkg_resources.resource_stream(__name__, tr)
- with open(zip_path, 'w') as f:
- shutil.copyfileobj(s, f)
-
- with zipfile.ZipFile(zip_path, 'r') as z:
- z.extractall(root)
-
- return tmpdir, root
-
- def test_wct(self):
- self._check_wct()
- tmpdir, root = self._extract_resources()
-
- cmd = _wct_cmd()
- print('Running %s in %s' % (cmd, root), file=sys.stderr)
-
- _write_wct_conf(root, {
- 'suites': ['test'],
- 'webserver': {
- 'pathMappings': [
- {'/components/bower_components': 'bower_components'},
- ],
- },
- 'plugins': {
- 'local': {
- # For some reason wct tries to install selenium into its node_modules
- # directory on first run. If you've installed into /usr/local and
- # aren't running wct as root, you're screwed. Turning this option off
- # seems to still work, so there's that.
- 'skipSeleniumInstall': True,
- },
- 'sauce': {
- # Disabled by default in order to run local tests only.
- # Run it with (saucelabs.com account required; free for open source):
- # WCT_ARGS='--plugin sauce' buck test --no-results-cache --include web
- 'disabled': True,
- 'browsers': [
- 'OS X 10.11/chrome',
- 'Windows 10/chrome',
- 'Linux/firefox',
- 'OS X 10.11/safari',
- 'Windows 10/microsoftedge',
- ],
- },
- },
- })
-
- p = subprocess.Popen(cmd, cwd=root,
- stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- out, err = p.communicate()
- sys.stdout.write(out)
- sys.stderr.write(err)
- self.assertEquals(0, p.returncode)
-
- # Only remove tmpdir if successful, to allow debugging.
- shutil.rmtree(tmpdir)
-
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/polygerrit-ui/app/styles/gr-change-list-styles.html b/polygerrit-ui/app/styles/gr-change-list-styles.html
index 1257046..544aed8 100644
--- a/polygerrit-ui/app/styles/gr-change-list-styles.html
+++ b/polygerrit-ui/app/styles/gr-change-list-styles.html
@@ -19,9 +19,6 @@
:host {
font-size: 13px;
}
- .headerRow {
- display: flex;
- }
.topHeader,
.groupHeader {
border-bottom: 1px solid #eee;
@@ -30,7 +27,6 @@
}
.topHeader {
background-color: #ddd;
- flex-shrink: 0;
}
.noChanges {
border-bottom: 1px solid #eee;
@@ -38,28 +34,22 @@
}
.keyboard,
.star {
- align-items: center;
- display: flex;
- justify-content: center;
padding: 0;
- width: 2em;
}
- .star {
- padding-top: .05em;
+ gr-change-star {
+ vertical-align: middle;
}
.number {
- width: 4em;
+ max-width: 4em;
}
.subject {
- flex-grow: 1;
- flex-shrink: 1;
word-break: break-word;
}
.status {
- width: 9em;
+ max-width: 9em;
}
.owner {
- width: 15em;
+ max-width: 15em;
}
.project,
.branch {
@@ -68,21 +58,21 @@
text-overflow: ellipsis;
}
.project {
- width: 10em;
+ max-width: 10em;
}
.branch {
- width: 7em;
+ max-width: 7em;
}
.updated {
- width: 9em;
+ max-width: 9em;
text-align: right;
}
.size {
- width: 9em;
+ max-width: 9em;
text-align: right;
}
.label {
- width: 2.6em;
+ max-width: 2.6em;
text-align: center;
}
@media only screen and (max-width: 50em) {
@@ -107,9 +97,8 @@
display: none;
}
.star {
- align-items: flex-start;
padding-left: .35em;
- padding-top: .4em;
+ padding-top: .25em;
}
.subject {
margin-bottom: .25em;
diff --git a/polygerrit-ui/app/styles/main.css b/polygerrit-ui/app/styles/main.css
index 39be0ff..6e48ae5 100644
--- a/polygerrit-ui/app/styles/main.css
+++ b/polygerrit-ui/app/styles/main.css
@@ -35,6 +35,6 @@
* Work around this using font-size and font-family.
*/
font-size: 13px;
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
line-height: 1.4;
}
diff --git a/polygerrit-ui/app/wct_test.sh b/polygerrit-ui/app/wct_test.sh
index 10de424..e6f3e0e 100755
--- a/polygerrit-ui/app/wct_test.sh
+++ b/polygerrit-ui/app/wct_test.sh
@@ -19,8 +19,7 @@
# Sauce tests are disabled by default in order to run local tests
# only. Run it with (saucelabs.com account required; free for open
-# source): WCT_ARGS='--plugin sauce' buck test --no-results-cache
-# --include web
+# source): WCT_ARGS='--plugin sauce' ./polygerrit-ui/app/run_test.sh
cat <<EOF > $t/wct.conf.js
module.exports = {
diff --git a/polygerrit-ui/run-server.sh b/polygerrit-ui/run-server.sh
index e6d782f..603d34a 100755
--- a/polygerrit-ui/run-server.sh
+++ b/polygerrit-ui/run-server.sh
@@ -15,22 +15,22 @@
set -eu
-while [[ ! -f .buckconfig && "$PWD" != / ]]; do
+while [[ ! -f WORKSPACE && "$PWD" != / ]]; do
cd ..
done
-if [[ ! -f .buckconfig ]]; then
+if [[ ! -f WORKSPACE ]]; then
echo "$(basename "$0"): must be run from a gerrit checkout" 1>&2
exit 1
fi
-buck build \
+bazel build \
//polygerrit-ui/app:test_components \
- //polygerrit-ui:fonts
+ //polygerrit-ui:fonts.zip
cd polygerrit-ui/app
rm -rf bower_components
-unzip -q ../../buck-out/gen/polygerrit-ui/app/test_components/test_components.bower_components.zip
+unzip -q ../../bazel-bin/polygerrit-ui/app/test_components.zip
rm -rf fonts
-unzip -q ../../buck-out/gen/polygerrit-ui/fonts/fonts.zip -d fonts
+unzip -q ../../bazel-bin/polygerrit-ui/fonts.zip -d fonts
cd ..
exec go run server.go "$@"
diff --git a/tools/BUCK b/tools/BUCK
deleted file mode 100644
index 489dffc..0000000
--- a/tools/BUCK
+++ /dev/null
@@ -1,51 +0,0 @@
-python_binary(
- name = 'download_file',
- main = 'download_file.py',
- deps = [':util'],
- visibility = ['PUBLIC'],
-)
-
-python_binary(
- name = 'merge_jars',
- main = 'merge_jars.py',
- visibility = ['PUBLIC'],
-)
-
-python_binary(
- name = 'pack_war',
- main = 'pack_war.py',
- deps = [':util'],
- visibility = ['PUBLIC'],
-)
-
-python_library(
- name = 'util',
- srcs = [
- 'util.py',
- '__init__.py'
- ],
- visibility = ['PUBLIC'],
-)
-
-python_test(
- name = 'util_test',
- srcs = ['util_test.py'],
- deps = [':util'],
- visibility = ['PUBLIC'],
-)
-
-def shquote(s):
- return s.replace("'", "'\\''")
-
-def os_path():
- from os import environ
- return environ.get('PATH')
-
-genrule(
- name = 'buck',
- cmd = 'echo buck=`which buck`>$OUT;' +
- ("echo PATH=\''%s'\' >>$OUT;" % shquote(os_path())),
- out = 'buck.properties',
- visibility = ['PUBLIC'],
-)
-
diff --git a/tools/build.defs b/tools/build.defs
deleted file mode 100644
index 3ea506c..0000000
--- a/tools/build.defs
+++ /dev/null
@@ -1,80 +0,0 @@
-# Copyright (C) 2013 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# These definitions support building a runnable version of Gerrit.
-
-DOCS_HTML = '//Documentation:html'
-DOCS_LIB = '//Documentation:index_lib'
-LIBS = [
- '//gerrit-war:log4j-config',
- '//gerrit-war:init',
- '//lib:postgresql',
- '//lib/log:impl_log4j',
-]
-PGMLIBS = ['//gerrit-pgm:pgm']
-
-def scan_plugins():
- import os
- deps = []
- for n in os.listdir('plugins'):
- if os.path.exists(os.path.join('plugins', n, 'BUCK')):
- deps.append('//plugins/%s:%s__plugin' % (n, n))
- return deps
-
-def war(
- name,
- libs = [],
- pgmlibs = [],
- context = [],
- visibility = [],
- docs = False
- ):
- cmd = ['$(exe //tools:pack_war)', '-o', '$OUT', '--tmp', '$TMP']
- for l in libs:
- cmd.extend(['--lib', '$(classpath %s)' % l])
- for l in pgmlibs:
- cmd.extend(['--pgmlib', '$(classpath %s)' % l])
-
- if docs:
- cmd.append('$(location %s)' % DOCS_HTML)
- cmd.extend(['--lib', '$(classpath %s)' % DOCS_LIB])
- if context:
- for t in context:
- cmd.append('$(location %s)' % t)
-
- genrule(
- name = name,
- cmd = ' '.join(cmd),
- out = name + '.war',
- visibility = visibility,
- )
-
-def gerrit_war(name, ui = 'ui_optdbg', context = [], docs = False, visibility = []):
- ui_deps = []
- if ui:
- if ui == 'polygerrit' or ui == 'ui_optdbg' or ui == 'ui_optdbg_r':
- ui_deps.append('//polygerrit-ui/app:polygerrit_ui')
- if ui != 'polygerrit':
- ui_deps.append('//gerrit-gwtui:%s' % ui)
- war(
- name = name,
- libs = LIBS + ['//gerrit-war:version'],
- pgmlibs = PGMLIBS,
- context = ui_deps + context + [
- '//gerrit-main:main_bin',
- '//gerrit-war:webapp_assets',
- ],
- docs = docs,
- visibility = visibility,
- )
diff --git a/tools/default.defs b/tools/default.defs
deleted file mode 100644
index fa1800b..0000000
--- a/tools/default.defs
+++ /dev/null
@@ -1,231 +0,0 @@
-# Copyright (C) 2013 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Rule definitions loaded by default into every BUCK file.
-
-include_defs('//lib/auto/auto_value.defs')
-include_defs('//tools/gwt-constants.defs')
-include_defs('//tools/java_doc.defs')
-include_defs('//tools/java_sources.defs')
-include_defs('//tools/git.defs')
-import copy
-import traceback
-import os
-from multiprocessing import cpu_count
-
-# Set defaults on java rules:
-# - Add AutoValue annotation processing support.
-# - Treat source files as UTF-8.
-
-_buck_java_library = java_library
-def java_library(*args, **kwargs):
- _munge_args(kwargs)
- _buck_java_library(*args, **kwargs)
-
-_buck_java_test = java_test
-def java_test(*args, **kwargs):
- _munge_args(kwargs)
- _buck_java_test(*args, **kwargs)
-
-
-# Munge kwargs to set Gerrit-specific defaults.
-def _munge_args(kwargs):
- if read_config('sanitizers', 'error_prone'):
- _set_error_prone(kwargs)
- _set_auto_value(kwargs)
- _set_extra_arguments(kwargs)
-
-def _set_error_prone(kwargs):
- kwargs['javac_jar'] = '//lib:errorprone'
- kwargs['compiler_class_name'] = 'com.google.errorprone.ErrorProneJavaCompiler'
-
-def _set_extra_arguments(kwargs):
- ext = 'extra_arguments'
- if ext not in kwargs:
- kwargs[ext] = []
- extra_args = kwargs[ext]
-
- for arg in extra_args:
- if arg.startswith('-encoding'):
- return
-
- extra_args.extend(['-encoding', 'UTF-8'])
-
-def _set_auto_value(kwargs):
- apk = 'annotation_processors'
- if apk not in kwargs:
- kwargs[apk] = []
- aps = kwargs.get(apk, [])
-
- apdk = 'annotation_processor_deps'
- if apdk not in kwargs:
- kwargs[apdk] = []
- apds = kwargs.get(apdk, [])
-
- all_deps = kwargs.get('deps', []) + kwargs.get('exported_deps', [])
- if AUTO_VALUE_DEP in all_deps:
- aps.extend(AUTO_VALUE_PROCESSORS)
- apds.extend(AUTO_VALUE_PROCESSOR_DEPS)
-
-
-# Add 'license' argument to genrule.
-_buck_genrule = genrule
-def genrule(*args, **kwargs):
- license = kwargs.pop('license', None)
- if license:
- license = '//lib:LICENSE-%s' % license
- # genrule has no deps attribute, but locations listed in the command show
- # up as deps of the target with buck audit.
- kwargs['cmd'] = 'true $(location %s); %s' % (license, kwargs['cmd'])
- _buck_genrule(*args, **kwargs)
-
-
-def genantlr(
- name,
- srcs,
- out):
- genrule(
- name = name,
- srcs = srcs,
- cmd = '$(exe //lib/antlr:antlr-tool) -o $TMP $SRCS;' +
- 'cd $TMP;' +
- 'zip -qr $OUT .',
- out = out,
- )
-
-def gwt_module(gwt_xml=None, **kwargs):
- kw = copy.deepcopy(kwargs)
- if 'resources' not in kw:
- kw['resources'] = []
- if gwt_xml:
- kw['resources'] += [gwt_xml]
- if 'srcs' in kw:
- kw['resources'] += kw['srcs']
-
- # Buck does not accept duplicate resources. Callers may have
- # included gwt_xml or srcs as part of resources, so de-dupe.
- kw['resources'] = list(set(kw['resources']))
-
- java_library(**kw)
-
-def gerrit_extension(
- name,
- deps = [],
- provided_deps = [],
- srcs = [],
- resources = [],
- manifest_file = None,
- manifest_entries = [],
- visibility = ['PUBLIC']):
- gerrit_plugin(
- name = name,
- deps = deps,
- provided_deps = provided_deps,
- srcs = srcs,
- resources = resources,
- manifest_file = manifest_file,
- manifest_entries = manifest_entries,
- type = 'extension',
- visibility = visibility,
- )
-
-def gerrit_plugin(
- name,
- deps = [],
- provided_deps = [],
- srcs = [],
- resources = [],
- gwt_module = None,
- manifest_file = None,
- manifest_entries = [],
- type = 'plugin',
- visibility = ['PUBLIC'],
- target_suffix = ''):
- tb = traceback.extract_stack()
- calling_BUCK_file = tb[-2][0]
- calling_BUCK_dir = os.path.abspath(os.path.dirname(calling_BUCK_file))
- mf_cmd = 'v=%s;' % git_describe(calling_BUCK_dir)
- if manifest_file:
- mf_src = [manifest_file]
- mf_cmd += 'sed "s:@VERSION@:$v:g" $SRCS >$OUT'
- else:
- mf_src = []
- mf_cmd += 'echo "Manifest-Version: 1.0" >$OUT;'
- mf_cmd += 'echo "Gerrit-ApiType: %s" >>$OUT;' % type
- mf_cmd += 'echo "Implementation-Version: $v" >>$OUT;'
- mf_cmd += 'echo "Implementation-Vendor: Gerrit Code Review" >>$OUT'
- for line in manifest_entries:
- line = line.replace('$', '\$')
- mf_cmd += ';echo "%s" >> $OUT' % line
- genrule(
- name = name + '__manifest',
- cmd = mf_cmd,
- srcs = mf_src,
- out = 'MANIFEST.MF',
- )
- static_jars = []
- if gwt_module:
- static_jars = [':%s-static-jar' % name]
- java_library(
- name = name + '__plugin',
- srcs = srcs,
- resources = resources,
- deps = deps,
- provided_deps = ['//gerrit-%s-api:lib' % type] +
- provided_deps +
- GWT_PLUGIN_DEPS,
- visibility = ['PUBLIC'],
- )
- if gwt_module:
- java_library(
- name = name + '__gwt_module',
- srcs = [],
- resources = list(set(srcs + resources)),
- deps = deps,
- provided_deps = GWT_PLUGIN_DEPS,
- visibility = ['PUBLIC'],
- )
- prebuilt_jar(
- name = '%s-static-jar' % name,
- binary_jar = ':%s-static' % name,
- )
- genrule(
- name = '%s-static' % name,
- cmd = 'mkdir -p $TMP/static' +
- ';unzip -qd $TMP/static $(location %s)' %
- ':%s__gwt_application' % name +
- ';cd $TMP' +
- ';zip -qr $OUT .',
- out = '%s-static.jar' % name,
- )
- gwt_binary(
- name = name + '__gwt_application',
- modules = [gwt_module],
- deps = GWT_PLUGIN_DEPS + GWT_TRANSITIVE_DEPS + ['//lib/gwt:dev'],
- module_deps = [':%s__gwt_module' % name],
- local_workers = cpu_count(),
- strict = True,
- experimental_args = GWT_COMPILER_ARGS,
- vm_args = GWT_JVM_ARGS,
- )
-
- java_binary(
- name = name + target_suffix,
- manifest_file = ':%s__manifest' % name,
- merge_manifests = False,
- deps = [
- ':%s__plugin' % name,
- ] + static_jars,
- visibility = visibility,
- )
diff --git a/tools/download_all.py b/tools/download_all.py
deleted file mode 100755
index 58316ca..0000000
--- a/tools/download_all.py
+++ /dev/null
@@ -1,44 +0,0 @@
-#!/usr/bin/env python
-# Copyright (C) 2013 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-from optparse import OptionParser
-import re
-from subprocess import check_call, CalledProcessError, Popen, PIPE
-
-MAIN = ['//tools/eclipse:classpath']
-PAT = re.compile(r'"(//.*?)" -> "//tools:download_file"')
-
-opts = OptionParser()
-opts.add_option('--src', action='store_true')
-args, _ = opts.parse_args()
-
-targets = set()
-
-p = Popen(['buck', 'audit', 'classpath', '--dot'] + MAIN, stdout = PIPE)
-for line in p.stdout:
- m = PAT.search(line)
- if m:
- n = m.group(1)
- if args.src and n.endswith('__download_bin'):
- n = n[:-13] + 'src'
- targets.add(n)
-r = p.wait()
-if r != 0:
- exit(r)
-
-try:
- check_call(['buck', 'build'] + sorted(targets))
-except CalledProcessError as err:
- exit(1)
diff --git a/tools/download_file.py b/tools/download_file.py
index c9c6ef0..8f5aa7c 100755
--- a/tools/download_file.py
+++ b/tools/download_file.py
@@ -25,6 +25,7 @@
from zipfile import ZipFile, BadZipfile, LargeZipFile
GERRIT_HOME = path.expanduser('~/.gerritcodereview')
+# TODO(davido): Rename in bazel-cache
CACHE_DIR = path.join(GERRIT_HOME, 'buck-cache', 'downloaded-artifacts')
LOCAL_PROPERTIES = 'local.properties'
@@ -86,7 +87,7 @@
root_dir = args.o
while root_dir and root_dir != "/":
root_dir, n = path.split(root_dir)
- if n == 'buck-out':
+ if n == 'WORKSPACE':
break
redirects = download_properties(root_dir)
diff --git a/tools/eclipse/BUCK b/tools/eclipse/BUCK
deleted file mode 100644
index a8b3f01..0000000
--- a/tools/eclipse/BUCK
+++ /dev/null
@@ -1,37 +0,0 @@
-include_defs('//tools/build.defs')
-
-java_library(
- name = 'classpath',
- deps = LIBS + PGMLIBS + [
- '//gerrit-acceptance-tests:lib',
- '//gerrit-gpg:gpg_tests',
- '//gerrit-gwtdebug:gwtdebug',
- '//gerrit-gwtui:ui_module',
- '//gerrit-gwtui:ui_tests',
- '//gerrit-httpd:httpd_tests',
- '//gerrit-main:main_lib',
- '//gerrit-patch-jgit:jgit_patch_tests',
- '//gerrit-plugin-gwtui:gwtui-api-lib',
- '//gerrit-reviewdb:client_tests',
- '//gerrit-server:server',
- '//gerrit-server:server_tests',
- '//lib/asciidoctor:asciidoc_lib',
- '//lib/asciidoctor:doc_indexer_lib',
- '//lib/auto:auto-value',
- '//lib/bouncycastle:bcprov',
- '//lib/bouncycastle:bcpg',
- '//lib/bouncycastle:bcpkix',
- '//lib/gwt:ant',
- '//lib/gwt:colt',
- '//lib/gwt:javax-validation',
- '//lib/gwt:javax-validation_src',
- '//lib/gwt:jsinterop-annotations',
- '//lib/gwt:jsinterop-annotations_src',
- '//lib/gwt:tapestry',
- '//lib/gwt:w3c-css-sac',
- '//lib/jetty:servlets',
- '//lib/prolog:compiler_lib',
- '//polygerrit-ui:polygerrit_components',
- '//Documentation:index_lib',
- ] + scan_plugins(),
-)
diff --git a/tools/eclipse/project.py b/tools/eclipse/project.py
index 46cd9fc..a7ddf6f 100755
--- a/tools/eclipse/project.py
+++ b/tools/eclipse/project.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-# Copyright (C) 2013 The Android Open Source Project
+# Copyright (C) 2016 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -16,46 +16,62 @@
# TODO(sop): Remove hack after Buck supports Eclipse
from __future__ import print_function
+# TODO(davido): use Google style for importing instead:
+# import optparse
+# ...
+# optparse.OptionParser
from optparse import OptionParser
-from os import makedirs, path
-from subprocess import Popen, PIPE, CalledProcessError, check_call
+from os import environ, path, makedirs
+from subprocess import CalledProcessError, check_call, check_output
from xml.dom import minidom
import re
import sys
-MAIN = ['//tools/eclipse:classpath']
-GWT = ['//gerrit-gwtui:ui_module']
+MAIN = '//tools/eclipse:classpath'
+GWT = '//gerrit-gwtui:ui_module'
+AUTO = '//lib/auto:auto-value'
JRE = '/'.join([
'org.eclipse.jdt.launching.JRE_CONTAINER',
'org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType',
'JavaSE-1.8',
])
+# Map of targets to corresponding classpath collector rules
+cp_targets = {
+ AUTO: '//tools/eclipse:autovalue_classpath_collect',
+ GWT: '//tools/eclipse:gwt_classpath_collect',
+ MAIN: '//tools/eclipse:main_classpath_collect',
+}
ROOT = path.abspath(__file__)
-while not path.exists(path.join(ROOT, '.buckconfig')):
+while not path.exists(path.join(ROOT, 'WORKSPACE')):
ROOT = path.dirname(ROOT)
opts = OptionParser()
-opts.add_option('--src', action='store_true',
- help='(deprecated) attach sources')
-opts.add_option('--no-src', dest='no_src', action='store_true',
- help='do not attach sources')
opts.add_option('--plugins', help='create eclipse projects for plugins',
action='store_true')
opts.add_option('--name', help='name of the generated project',
action='store', default='gerrit', dest='project_name')
args, _ = opts.parse_args()
-def _query_classpath(targets):
- deps = []
- p = Popen(['buck', 'audit', 'classpath'] + targets, stdout=PIPE)
- for line in p.stdout:
- deps.append(line.strip())
- s = p.wait()
- if s != 0:
- exit(s)
- return deps
+def retrieve_ext_location():
+ return check_output(['bazel', 'info', 'output_base']).strip()
+def gen_primary_build_tool():
+ bazel = check_output(['which', 'bazel']).strip()
+ with open(path.join(ROOT, ".primary_build_tool"), 'w') as fd:
+ fd.write("bazel=%s\n" % bazel)
+ fd.write("PATH=%s\n" % environ["PATH"])
+
+def _query_classpath(target):
+ deps = []
+ t = cp_targets[target]
+ try:
+ check_call(['bazel', 'build', t])
+ except CalledProcessError:
+ exit(1)
+ name = 'bazel-bin/tools/eclipse/' + t.split(':')[1] + '.runtime_classpath'
+ deps = [line.rstrip('\n') for line in open(name)]
+ return deps
def gen_project(name='gerrit', root=ROOT):
p = path.join(root, '.project')
@@ -63,7 +79,7 @@
print("""\
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
- <name>""" + name + """</name>
+ <name>%(name)s</name>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
@@ -73,11 +89,7 @@
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>\
-""", file=fd)
-
-def gen_primary_build_tool():
- with open(path.join(ROOT, ".primary_build_tool"), 'w') as fd:
- fd.write("buck")
+ """ % {"name": name}, file=fd)
def gen_plugin_classpath(root):
p = path.join(root, '.classpath')
@@ -97,7 +109,7 @@
<classpathentry kind="output" path="eclipse-out/classes"/>
</classpath>""" % {"testpath": testpath}, file=fd)
-def gen_classpath():
+def gen_classpath(ext):
def make_classpath():
impl = minidom.getDOMImplementation()
return impl.createDocument(None, 'classpath', None)
@@ -127,25 +139,31 @@
plugins = set()
# Classpath entries are absolute for cross-cell support
- java_library = re.compile('.*/buck-out/gen/(.*)/lib__[^/]+__output/[^/]+[.]jar$')
- srcs = re.compile('.*/(__.*__)/.*')
+ java_library = re.compile('bazel-out/local-fastbuild/bin/(.*)/[^/]+[.]jar$')
+ srcs = re.compile('(.*/external/[^/]+)/jar/(.*)[.]jar')
for p in _query_classpath(MAIN):
if p.endswith('-src.jar'):
# gwt_module() depends on -src.jar for Java to JavaScript compiles.
+ if p.startswith("external"):
+ p = path.join(ext, p)
gwt_lib.add(p)
continue
- if 'buck-out/gen/lib/gwt/' in p:
- # gwt_module() depends on huge shaded GWT JARs that import
- # incorrect versions of classes for Gerrit. Collect into
- # a private grouping for later use.
- gwt_lib.add(p)
- continue
m = java_library.match(p)
if m:
src.add(m.group(1))
+ # Exceptions: both source and lib
+ if p.endswith('libquery_parser.jar') or \
+ p.endswith('prolog/libcommon.jar'):
+ lib.add(p)
else:
+ # Don't mess up with Bazel internal test runner dependencies.
+ # When we use Eclipse we rely on it for running the tests
+ if p.endswith("external/bazel_tools/tools/jdk/TestRunner_deploy.jar"):
+ continue
+ if p.startswith("external"):
+ p = path.join(ext, p)
lib.add(p)
for p in _query_classpath(GWT):
@@ -184,24 +202,27 @@
for libs in [lib, gwt_lib]:
for j in sorted(libs):
s = None
- if j.endswith('.jar'):
- s = j[:-4] + '-src.jar'
- if not path.exists(s):
- m = srcs.match(s)
- if m:
- l = m.group(1)
- if l.endswith('__jar__'):
- s = s.replace(l, l.replace('__jar__', '_src__'))
- else:
- s = s.replace(l, l[:-1] + 'src__')
- if not path.exists(s):
- s = None
- else:
- s = None
+ m = srcs.match(j)
+ if m:
+ prefix = m.group(1)
+ suffix = m.group(2)
+ p = path.join(prefix, "jar", "%s-src.jar" % suffix)
+ if path.exists(p):
+ s = p
if args.plugins:
classpathentry('lib', j, s, exported=True)
else:
+ # Filter out the source JARs that we pull through transitive closure of
+ # GWT plugin API (we add source directories themself). Exception is
+ # libEdit-src.jar, that is needed for GWT SDM to work.
+ m = java_library.match(j)
+ if m:
+ if m.group(1).startswith("gerrit-") and \
+ j.endswith("-src.jar") and \
+ not j.endswith("libEdit-src.jar"):
+ continue
classpathentry('lib', j, s)
+
for s in sorted(gwt_src):
p = path.join(ROOT, s, 'src', 'main', 'java')
if path.exists(p):
@@ -224,12 +245,12 @@
print('error generating project for %s: %s' % (plugin, err),
file=sys.stderr)
-def gen_factorypath():
+def gen_factorypath(ext):
doc = minidom.getDOMImplementation().createDocument(None, 'factorypath', None)
- for jar in _query_classpath(['//lib/auto:auto-value']):
+ for jar in _query_classpath(AUTO):
e = doc.createElement('factorypathentry')
e.setAttribute('kind', 'EXTJAR')
- e.setAttribute('id', path.join(ROOT, jar))
+ e.setAttribute('id', path.join(ext, jar))
e.setAttribute('enabled', 'true')
e.setAttribute('runInBatchMode', 'false')
doc.documentElement.appendChild(e)
@@ -239,15 +260,10 @@
doc.writexml(fd, addindent='\t', newl='\n', encoding='UTF-8')
try:
- if not args.no_src:
- try:
- check_call([path.join(ROOT, 'tools', 'download_all.py'), '--src'])
- except CalledProcessError as err:
- exit(1)
-
+ ext_location = retrieve_ext_location()
gen_project(args.project_name)
- gen_classpath()
- gen_factorypath()
+ gen_classpath(ext_location)
+ gen_factorypath(ext_location)
gen_primary_build_tool()
# TODO(davido): Remove this when GWT gone
@@ -256,9 +272,8 @@
makedirs(path.join(ROOT, gwt_working_dir))
try:
- targets = ['//tools:buck'] + MAIN + GWT
- check_call(['buck', 'build', '--deep'] + targets)
- except CalledProcessError as err:
+ check_call(['bazel', 'build', MAIN, GWT, '//gerrit-patch-jgit:libEdit-src.jar'])
+ except CalledProcessError:
exit(1)
except KeyboardInterrupt:
print('Interrupted by user', file=sys.stderr)
diff --git a/tools/eclipse/project_bzl.py b/tools/eclipse/project_bzl.py
deleted file mode 100755
index a7ddf6f..0000000
--- a/tools/eclipse/project_bzl.py
+++ /dev/null
@@ -1,280 +0,0 @@
-#!/usr/bin/env python
-# Copyright (C) 2016 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# TODO(sop): Remove hack after Buck supports Eclipse
-
-from __future__ import print_function
-# TODO(davido): use Google style for importing instead:
-# import optparse
-# ...
-# optparse.OptionParser
-from optparse import OptionParser
-from os import environ, path, makedirs
-from subprocess import CalledProcessError, check_call, check_output
-from xml.dom import minidom
-import re
-import sys
-
-MAIN = '//tools/eclipse:classpath'
-GWT = '//gerrit-gwtui:ui_module'
-AUTO = '//lib/auto:auto-value'
-JRE = '/'.join([
- 'org.eclipse.jdt.launching.JRE_CONTAINER',
- 'org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType',
- 'JavaSE-1.8',
-])
-# Map of targets to corresponding classpath collector rules
-cp_targets = {
- AUTO: '//tools/eclipse:autovalue_classpath_collect',
- GWT: '//tools/eclipse:gwt_classpath_collect',
- MAIN: '//tools/eclipse:main_classpath_collect',
-}
-
-ROOT = path.abspath(__file__)
-while not path.exists(path.join(ROOT, 'WORKSPACE')):
- ROOT = path.dirname(ROOT)
-
-opts = OptionParser()
-opts.add_option('--plugins', help='create eclipse projects for plugins',
- action='store_true')
-opts.add_option('--name', help='name of the generated project',
- action='store', default='gerrit', dest='project_name')
-args, _ = opts.parse_args()
-
-def retrieve_ext_location():
- return check_output(['bazel', 'info', 'output_base']).strip()
-
-def gen_primary_build_tool():
- bazel = check_output(['which', 'bazel']).strip()
- with open(path.join(ROOT, ".primary_build_tool"), 'w') as fd:
- fd.write("bazel=%s\n" % bazel)
- fd.write("PATH=%s\n" % environ["PATH"])
-
-def _query_classpath(target):
- deps = []
- t = cp_targets[target]
- try:
- check_call(['bazel', 'build', t])
- except CalledProcessError:
- exit(1)
- name = 'bazel-bin/tools/eclipse/' + t.split(':')[1] + '.runtime_classpath'
- deps = [line.rstrip('\n') for line in open(name)]
- return deps
-
-def gen_project(name='gerrit', root=ROOT):
- p = path.join(root, '.project')
- with open(p, 'w') as fd:
- print("""\
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>%(name)s</name>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>\
- """ % {"name": name}, file=fd)
-
-def gen_plugin_classpath(root):
- p = path.join(root, '.classpath')
- with open(p, 'w') as fd:
- if path.exists(path.join(root, 'src', 'test', 'java')):
- testpath = """
- <classpathentry excluding="**/BUILD" kind="src" path="src/test/java"\
- out="eclipse-out/test"/>"""
- else:
- testpath = ""
- print("""\
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry excluding="**/BUILD" kind="src" path="src/main/java"/>%(testpath)s
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry combineaccessrules="false" kind="src" path="/gerrit"/>
- <classpathentry kind="output" path="eclipse-out/classes"/>
-</classpath>""" % {"testpath": testpath}, file=fd)
-
-def gen_classpath(ext):
- def make_classpath():
- impl = minidom.getDOMImplementation()
- return impl.createDocument(None, 'classpath', None)
-
- def classpathentry(kind, path, src=None, out=None, exported=None):
- e = doc.createElement('classpathentry')
- e.setAttribute('kind', kind)
- # TODO(davido): Remove this and other exclude BUILD files hack
- # when this Bazel bug is fixed:
- # https://github.com/bazelbuild/bazel/issues/1083
- if kind == 'src':
- e.setAttribute('excluding', '**/BUILD')
- e.setAttribute('path', path)
- if src:
- e.setAttribute('sourcepath', src)
- if out:
- e.setAttribute('output', out)
- if exported:
- e.setAttribute('exported', 'true')
- doc.documentElement.appendChild(e)
-
- doc = make_classpath()
- src = set()
- lib = set()
- gwt_src = set()
- gwt_lib = set()
- plugins = set()
-
- # Classpath entries are absolute for cross-cell support
- java_library = re.compile('bazel-out/local-fastbuild/bin/(.*)/[^/]+[.]jar$')
- srcs = re.compile('(.*/external/[^/]+)/jar/(.*)[.]jar')
- for p in _query_classpath(MAIN):
- if p.endswith('-src.jar'):
- # gwt_module() depends on -src.jar for Java to JavaScript compiles.
- if p.startswith("external"):
- p = path.join(ext, p)
- gwt_lib.add(p)
- continue
-
-
- m = java_library.match(p)
- if m:
- src.add(m.group(1))
- # Exceptions: both source and lib
- if p.endswith('libquery_parser.jar') or \
- p.endswith('prolog/libcommon.jar'):
- lib.add(p)
- else:
- # Don't mess up with Bazel internal test runner dependencies.
- # When we use Eclipse we rely on it for running the tests
- if p.endswith("external/bazel_tools/tools/jdk/TestRunner_deploy.jar"):
- continue
- if p.startswith("external"):
- p = path.join(ext, p)
- lib.add(p)
-
- for p in _query_classpath(GWT):
- m = java_library.match(p)
- if m:
- gwt_src.add(m.group(1))
-
- for s in sorted(src):
- out = None
-
- if s.startswith('lib/'):
- out = 'eclipse-out/lib'
- elif s.startswith('plugins/'):
- if args.plugins:
- plugins.add(s)
- continue
- out = 'eclipse-out/' + s
-
- p = path.join(s, 'java')
- if path.exists(p):
- classpathentry('src', p, out=out)
- continue
-
- for env in ['main', 'test']:
- o = None
- if out:
- o = out + '/' + env
- elif env == 'test':
- o = 'eclipse-out/test'
-
- for srctype in ['java', 'resources']:
- p = path.join(s, 'src', env, srctype)
- if path.exists(p):
- classpathentry('src', p, out=o)
-
- for libs in [lib, gwt_lib]:
- for j in sorted(libs):
- s = None
- m = srcs.match(j)
- if m:
- prefix = m.group(1)
- suffix = m.group(2)
- p = path.join(prefix, "jar", "%s-src.jar" % suffix)
- if path.exists(p):
- s = p
- if args.plugins:
- classpathentry('lib', j, s, exported=True)
- else:
- # Filter out the source JARs that we pull through transitive closure of
- # GWT plugin API (we add source directories themself). Exception is
- # libEdit-src.jar, that is needed for GWT SDM to work.
- m = java_library.match(j)
- if m:
- if m.group(1).startswith("gerrit-") and \
- j.endswith("-src.jar") and \
- not j.endswith("libEdit-src.jar"):
- continue
- classpathentry('lib', j, s)
-
- for s in sorted(gwt_src):
- p = path.join(ROOT, s, 'src', 'main', 'java')
- if path.exists(p):
- classpathentry('lib', p, out='eclipse-out/gwtsrc')
-
- classpathentry('con', JRE)
- classpathentry('output', 'eclipse-out/classes')
-
- p = path.join(ROOT, '.classpath')
- with open(p, 'w') as fd:
- doc.writexml(fd, addindent='\t', newl='\n', encoding='UTF-8')
-
- if args.plugins:
- for plugin in plugins:
- plugindir = path.join(ROOT, plugin)
- try:
- gen_project(plugin.replace('plugins/', ""), plugindir)
- gen_plugin_classpath(plugindir)
- except (IOError, OSError) as err:
- print('error generating project for %s: %s' % (plugin, err),
- file=sys.stderr)
-
-def gen_factorypath(ext):
- doc = minidom.getDOMImplementation().createDocument(None, 'factorypath', None)
- for jar in _query_classpath(AUTO):
- e = doc.createElement('factorypathentry')
- e.setAttribute('kind', 'EXTJAR')
- e.setAttribute('id', path.join(ext, jar))
- e.setAttribute('enabled', 'true')
- e.setAttribute('runInBatchMode', 'false')
- doc.documentElement.appendChild(e)
-
- p = path.join(ROOT, '.factorypath')
- with open(p, 'w') as fd:
- doc.writexml(fd, addindent='\t', newl='\n', encoding='UTF-8')
-
-try:
- ext_location = retrieve_ext_location()
- gen_project(args.project_name)
- gen_classpath(ext_location)
- gen_factorypath(ext_location)
- gen_primary_build_tool()
-
- # TODO(davido): Remove this when GWT gone
- gwt_working_dir = ".gwt_work_dir"
- if not path.isdir(gwt_working_dir):
- makedirs(path.join(ROOT, gwt_working_dir))
-
- try:
- check_call(['bazel', 'build', MAIN, GWT, '//gerrit-patch-jgit:libEdit-src.jar'])
- except CalledProcessError:
- exit(1)
-except KeyboardInterrupt:
- print('Interrupted by user', file=sys.stderr)
- exit(1)
diff --git a/tools/git.defs b/tools/git.defs
deleted file mode 100644
index 859f173..0000000
--- a/tools/git.defs
+++ /dev/null
@@ -1,26 +0,0 @@
-# Copyright (C) 2013 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-def git_describe(directory = None):
- import subprocess
- cmd = ['git', 'describe', '--always', '--match', 'v[0-9].*', '--dirty']
- if not directory:
- p = subprocess.Popen(cmd, stdout = subprocess.PIPE)
- else:
- p = subprocess.Popen(cmd, stdout = subprocess.PIPE, cwd = directory)
- v = p.communicate()[0].strip()
- r = p.returncode
- if r != 0:
- raise subprocess.CalledProcessError(r, ' '.join(cmd))
- return v
diff --git a/tools/gwt-constants.defs b/tools/gwt-constants.defs
deleted file mode 100644
index b76c04b..0000000
--- a/tools/gwt-constants.defs
+++ /dev/null
@@ -1,30 +0,0 @@
-GWT_JVM_ARGS = ['-Xmx512m']
-
-GWT_COMPILER_ARGS = [
- '-XdisableClassMetadata',
-]
-
-GWT_COMPILER_ARGS_RELEASE_MODE = GWT_COMPILER_ARGS + [
- '-XdisableCastChecking',
-]
-
-GWT_PLUGIN_DEPS = [
- '//gerrit-plugin-gwtui:gwtui-api-lib',
- '//lib/gwt:user',
-]
-
-GWT_TRANSITIVE_DEPS = [
- '//lib/gwt:ant',
- '//lib/gwt:colt',
- '//lib/gwt:javax-validation',
- '//lib/gwt:javax-validation_src',
- '//lib/gwt:jsinterop-annotations',
- '//lib/gwt:jsinterop-annotations_src',
- '//lib/gwt:tapestry',
- '//lib/gwt:w3c-css-sac',
- '//lib/ow2:ow2-asm',
- '//lib/ow2:ow2-asm-analysis',
- '//lib/ow2:ow2-asm-commons',
- '//lib/ow2:ow2-asm-tree',
- '//lib/ow2:ow2-asm-util',
-]
diff --git a/tools/java_doc.defs b/tools/java_doc.defs
deleted file mode 100644
index 583407c6..0000000
--- a/tools/java_doc.defs
+++ /dev/null
@@ -1,38 +0,0 @@
-def java_doc(
- name,
- title,
- pkgs,
- source_jar,
- srcs = [],
- deps = [],
- visibility = [],
- external_docs = [],
- ):
- # TODO(davido): Actually we shouldn't need to extract the source
- # archive, javadoc should just work with provided archive.
- external_docs.insert(0, 'http://docs.oracle.com/javase/8/docs/api')
- genrule(
- name = name,
- cmd = ' '.join([
- 'mkdir $TMP/sourcepath &&',
- 'unzip $(location %s) -d $TMP/sourcepath &&' % source_jar,
- 'javadoc',
- '-Xdoclint:-missing',
- '-quiet',
- '-protected',
- '-encoding UTF-8',
- '-charset UTF-8',
- '-notimestamp',
- '-windowtitle "' + title + '"',
- ' '.join(['-link %s' % url for url in external_docs]),
- '-subpackages ',
- ':'.join(pkgs),
- '-sourcepath $TMP/sourcepath',
- ' -classpath ',
- ':'.join(['$(classpath %s)' % n for n in deps]),
- '-d $TMP',
- ]) + ';jar cf $OUT -C $TMP .',
- srcs = srcs,
- out = name + '.jar',
- visibility = visibility,
- )
diff --git a/tools/java_sources.defs b/tools/java_sources.defs
deleted file mode 100644
index 0b3974e..0000000
--- a/tools/java_sources.defs
+++ /dev/null
@@ -1,10 +0,0 @@
-def java_sources(
- name,
- srcs,
- visibility = []
- ):
- java_library(
- name = name,
- resources = srcs,
- visibility = visibility,
- )
diff --git a/tools/js/BUCK b/tools/js/BUCK
deleted file mode 100644
index 9eb0c91..0000000
--- a/tools/js/BUCK
+++ /dev/null
@@ -1,32 +0,0 @@
-python_binary(
- name = 'bower2buck',
- main = 'bower2buck.py',
- deps = [
- '//tools:util',
- ":bowerutil",
- ],
- visibility = ['PUBLIC'],
-)
-
-python_library(
- name = 'bowerutil',
- srcs = [ 'bowerutil.py' ],
- visibility = [ 'PUBLIC' ],
-)
-
-python_binary(
- name = 'download_bower',
- main = 'download_bower.py',
- deps = [
- '//tools:util',
- ":bowerutil",
- ],
- visibility = ['PUBLIC'],
-)
-
-python_binary(
- name = 'run_npm_binary',
- main = 'run_npm_binary.py',
- deps = ['//tools:util'],
- visibility = ['PUBLIC'],
-)
diff --git a/tools/js/bower2buck.py b/tools/js/bower2buck.py
deleted file mode 100755
index d99b282..0000000
--- a/tools/js/bower2buck.py
+++ /dev/null
@@ -1,217 +0,0 @@
-#!/usr/bin/env python
-# Copyright (C) 2015 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-from __future__ import print_function
-
-import atexit
-import collections
-import json
-import hashlib
-import optparse
-import os
-import shutil
-import subprocess
-import sys
-import tempfile
-
-from tools.js import bowerutil
-
-# This script is run with `buck run`, but needs to shell out to buck; this is
-# only possible if we avoid buckd.
-BUCK_ENV = dict(os.environ)
-BUCK_ENV['NO_BUCKD'] = '1'
-
-HEADER = """\
-include_defs('//lib/js.defs')
-
-# AUTOGENERATED BY BOWER2BUCK
-#
-# This file should be merged with an existing BUCK file containing these rules.
-#
-# This comment SHOULD NOT be copied to the existing BUCK file, and you should
-# leave alone any non-bower_component contents of the file.
-#
-# Generally, the following attributes SHOULD be copied from this file to the
-# existing BUCK file:
-# - package: the normalized package name
-# - version: the exact version number
-# - deps: direct dependencies of the package
-# - sha1: a hash of the package contents
-#
-# The following fields SHOULD NOT be copied to the existing BUCK file:
-# - semver: manually-specified semantic version, not included in autogenerated
-# output.
-#
-# The following fields require SPECIAL HANDLING:
-# - license: all licenses in this file are specified as TODO. You must replace
-# this text with one of the existing licenses defined in lib/BUCK, or
-# define a new one if necessary. Leave existing licenses alone.
-
-"""
-
-
-def usage():
- print(('Usage: %s -o <outfile> [//path/to:bower_components_rule...]'
- % sys.argv[0]),
- file=sys.stderr)
- return 1
-
-
-class Rule(object):
- def __init__(self, bower_json_path):
- with open(bower_json_path) as f:
- bower_json = json.load(f)
- self.name = bower_json['name']
- self.version = bower_json['version']
- self.deps = bower_json.get('dependencies', {})
- self.license = bower_json.get('license', 'NO LICENSE')
- self.sha1 = bowerutil.hash_bower_component(
- hashlib.sha1(), os.path.dirname(bower_json_path)).hexdigest()
-
- def to_rule(self, packages):
- if self.name not in packages:
- raise ValueError('No package name found for %s' % self.name)
-
- lines = [
- 'bower_component(',
- " name = '%s'," % self.name,
- " package = '%s'," % packages[self.name],
- " version = '%s'," % self.version,
- ]
- if self.deps:
- if len(self.deps) == 1:
- lines.append(" deps = [':%s']," % next(self.deps.iterkeys()))
- else:
- lines.append(' deps = [')
- lines.extend(" ':%s'," % d for d in sorted(self.deps.iterkeys()))
- lines.append(' ],')
- lines.extend([
- " license = 'TODO: %s'," % self.license,
- " sha1 = '%s'," % self.sha1,
- ')'])
- return '\n'.join(lines)
-
-
-def build_bower_json(targets, buck_out):
- """create bower.json so 'bower install' fetches transitive deps"""
- bower_json = collections.OrderedDict()
- bower_json['name'] = 'bower2buck-output'
- bower_json['version'] = '0.0.0'
- bower_json['description'] = 'Auto-generated bower.json for dependency management'
- bower_json['private'] = True
- bower_json['dependencies'] = {}
-
- deps = subprocess.check_output(
- ['buck', 'query', '-v', '0',
- "filter('__download_bower', deps(%s))" % '+'.join(targets)],
- env=BUCK_ENV)
-
- # __bower_version contains the version number coming from version
- # attr in BUCK/BUILD
- deps = deps.replace('__download_bower', '__bower_version').split()
- subprocess.check_call(['buck', 'build'] + deps, env=BUCK_ENV)
-
- for dep in deps:
- dep = dep.replace(':', '/').lstrip('/')
- depout = os.path.basename(dep)
- version_json = os.path.join(buck_out, 'gen', dep, depout)
- with open(version_json) as f:
- bower_json['dependencies'].update(json.load(f))
-
- tmpdir = tempfile.mkdtemp()
- atexit.register(lambda: shutil.rmtree(tmpdir))
- ret = os.path.join(tmpdir, 'bower.json')
- with open(ret, 'w') as f:
- json.dump(bower_json, f, indent=2)
- return ret
-
-
-def get_package_name(name, package_version):
- v = package_version.lower()
- if '#' in v:
- return v[:v.find('#')]
- return name
-
-
-def get_packages(path):
- with open(path) as f:
- bower_json = json.load(f)
- return dict((n, get_package_name(n, v))
- for n, v in bower_json.get('dependencies', {}).iteritems())
-
-
-def collect_rules(packages):
- # TODO(dborowitz): Use run_npm_binary instead of system bower.
- rules = {}
- subprocess.check_call(['bower', 'install'])
- for dirpath, dirnames, filenames in os.walk('.', topdown=True):
- if '.bower.json' not in filenames:
- continue
- del dirnames[:]
- rule = Rule(os.path.join(dirpath, '.bower.json'))
- rules[rule.name] = rule
-
- # Oddly, the package name referred to in the deps section of dependents,
- # e.g. 'PolymerElements/iron-ajax', is not found anywhere in this
- # bower.json, which only contains 'iron-ajax'. Build up a map of short name
- # to package name so we can resolve them later.
- # TODO(dborowitz): We can do better:
- # - Infer 'user/package' from GitHub URLs (i.e. a simple subset of Bower's package
- # resolution logic).
- # - Resolve aliases using https://bower.herokuapp.com/packages/shortname
- # (not currently biting us but it might in the future.)
- for n, v in rule.deps.iteritems():
- p = get_package_name(n, v)
- old = packages.get(n)
- if old is not None and old != p:
- raise ValueError('multiple packages named %s: %s != %s' % (n, p, old))
- packages[n] = p
-
- return rules
-
-
-def find_buck_out():
- dir = os.getcwd()
- while not os.path.isfile(os.path.join(dir, '.buckconfig')):
- dir = os.path.dirname(dir)
- return os.path.join(dir, 'buck-out')
-
-
-def main(args):
- opts = optparse.OptionParser()
- opts.add_option('-o', help='output file location')
- opts, args = opts.parse_args()
-
- if not opts.o or not all(a.startswith('//') for a in args):
- return usage()
- outfile = os.path.abspath(opts.o)
- buck_out = find_buck_out()
-
- targets = args if args else ['//polygerrit-ui/...']
- bower_json_path = build_bower_json(targets, buck_out)
- os.chdir(os.path.dirname(bower_json_path))
- packages = get_packages(bower_json_path)
- rules = collect_rules(packages)
-
- with open(outfile, 'w') as f:
- f.write(HEADER)
- for _, r in sorted(rules.iteritems()):
- f.write('\n\n%s' % r.to_rule(packages))
-
- print('Wrote bower_components rules to:\n %s' % outfile)
-
-
-if __name__ == '__main__':
- main(sys.argv[1:])
diff --git a/tools/maven/BUCK b/tools/maven/BUCK
deleted file mode 100644
index 0541fc0..0000000
--- a/tools/maven/BUCK
+++ /dev/null
@@ -1,33 +0,0 @@
-include_defs('//tools/maven/package.defs')
-include_defs('//tools/maven/repository.defs')
-include_defs('//version.bzl')
-
-if GERRIT_VERSION.endswith('-SNAPSHOT'):
- URL = MAVEN_SNAPSHOT_URL
-else:
- URL = MAVEN_RELEASE_URL
-
-maven_package(
- repository = MAVEN_REPOSITORY,
- url = URL,
- version = GERRIT_VERSION,
- jar = {
- 'gerrit-acceptance-framework': '//gerrit-acceptance-framework:acceptance-framework',
- 'gerrit-extension-api': '//gerrit-extension-api:extension-api',
- 'gerrit-plugin-api': '//gerrit-plugin-api:plugin-api',
- 'gerrit-plugin-gwtui': '//gerrit-plugin-gwtui:gwtui-api',
- },
- src = {
- 'gerrit-acceptance-framework': '//gerrit-acceptance-framework:acceptance-framework-src',
- 'gerrit-extension-api': '//gerrit-extension-api:extension-api-src',
- 'gerrit-plugin-api': '//gerrit-plugin-api:plugin-api-src',
- 'gerrit-plugin-gwtui': '//gerrit-plugin-gwtui:gwtui-api-src',
- },
- doc = {
- 'gerrit-acceptance-framework': '//gerrit-acceptance-framework:acceptance-framework-javadoc',
- 'gerrit-extension-api': '//gerrit-extension-api:extension-api-javadoc',
- 'gerrit-plugin-api': '//gerrit-plugin-api:plugin-api-javadoc',
- 'gerrit-plugin-gwtui': '//gerrit-plugin-gwtui:gwtui-api-javadoc',
- },
- war = {'gerrit-war': '//:release'},
-)
diff --git a/tools/maven/api.sh b/tools/maven/api.sh
index 93b5f2e..92fc0dd 100755
--- a/tools/maven/api.sh
+++ b/tools/maven/api.sh
@@ -14,9 +14,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-if [[ "$#" != "2" ]] ; then
+if [[ "$#" != "1" ]] ; then
cat <<EOF
-Usage: run "$0 COMMAND BUILD-TOOL" from the top of your workspace,
+Usage: run "$0 COMMAND" from the top of your workspace,
where COMMAND is one of
install
@@ -24,10 +24,6 @@
war_install
war_deploy
-and BUILD-TOOL is one of
-
- buck
- bazel
Set VERBOSE in the environment to get more information.
EOF
@@ -38,7 +34,6 @@
set -o errexit
set -o nounset
-
case "$1" in
install)
command="api_install"
@@ -58,33 +53,11 @@
;;
esac
-case "$2" in
-bazel)
- buildProc=bazel
- ;;
-buck)
- buildProc=buck
- ;;
-*)
- echo "unknown build-tool $2. Should be buck or bazel."
- exit 1
- ;;
-esac
-
if [[ "${VERBOSE:-x}" != "x" ]]; then
set -o xtrace
fi
-$buildProc build //tools/maven:gen_${command} || \
- { echo "$buildProc failed to build gen_${command}. Use VERBOSE=1 for more info" ; exit 1 ; }
+bazel build //tools/maven:gen_${command} || \
+ { echo "bazel failed to build gen_${command}. Use VERBOSE=1 for more info" ; exit 1 ; }
-if [[ "$buildProc" = "bazel" ]]; then
- script="./bazel-genfiles/tools/maven/${command}.sh"
- ${script}
-else
- script="./buck-out/gen/tools/maven/gen_${command}/${command}.sh"
- # The PEX wrapper does some funky exit handling, so even if the script
- # does "exit(0)", the return status is '1'. So we can't tell if the
- # following invocation was successful.
- ${script}
-fi
+./bazel-genfiles/tools/maven/${command}.sh
diff --git a/tools/maven/mvn.py b/tools/maven/mvn.py
index 4011d71..f7b5aa8 100755
--- a/tools/maven/mvn.py
+++ b/tools/maven/mvn.py
@@ -33,7 +33,7 @@
exit(1)
root = path.abspath(__file__)
-while not path.exists(path.join(root, '.buckconfig')):
+while not path.exists(path.join(root, 'WORKSPACE')):
root = path.dirname(root)
if 'install' == args.a:
diff --git a/tools/maven/package.defs b/tools/maven/package.defs
deleted file mode 100644
index a557170..0000000
--- a/tools/maven/package.defs
+++ /dev/null
@@ -1,95 +0,0 @@
-# Copyright (C) 2013 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-sh_bang_template = (' && '.join([
- "echo '#!/bin/bash -e' > $OUT",
- 'echo "# this script should run from the root of your workspace." >> $OUT',
- 'echo "" >> $OUT',
- "echo 'if [[ \"${VERBOSE}\" ]]; then set -x ; fi' >> $OUT",
- 'echo "" >> $OUT',
- 'echo %s >> $OUT',
- 'echo "" >> $OUT',
- 'echo %s >> $OUT',
- # This is supposed to be handled by executable=True, but it doesn't
- # work. Bug?
- 'chmod +x $OUT' ]))
-
-def maven_package(
- version,
- repository = None,
- url = None,
- jar = {},
- src = {},
- doc = {},
- war = {}):
-
- build_cmd = ['buck', 'build']
-
- # This is not using python_binary() to avoid the baggage and bugs
- # that PEX brings along.
- mvn_cmd = ['python', 'tools/maven/mvn.py', '-v', version]
- api_cmd = mvn_cmd[:]
- api_targets = []
- for type,d in [('jar', jar), ('java-source', src), ('javadoc', doc)]:
- for a,t in sorted(d.iteritems()):
- api_cmd.append('-s %s:%s:$(location %s)' % (a,type,t))
- api_targets.append(t)
-
- genrule(
- name = 'gen_api_install',
- cmd = sh_bang_template % (
- ' '.join(build_cmd + api_targets),
- ' '.join(api_cmd + ['-a', 'install'])),
- out = 'api_install.sh',
- executable = True,
- )
-
- if repository and url:
- genrule(
- name = 'gen_api_deploy',
- cmd = sh_bang_template % (
- ' '.join(build_cmd + api_targets),
- ' '.join(api_cmd + ['-a', 'deploy',
- '--repository', repository,
- '--url', url])),
- out = 'api_deploy.sh',
- executable = True,
- )
-
- war_cmd = mvn_cmd[:]
- war_targets = []
- for a,t in sorted(war.iteritems()):
- war_cmd.append('-s %s:war:$(location %s)' % (a,t))
- war_targets.append(t)
-
- genrule(
- name = 'gen_war_install',
- cmd = sh_bang_template % (' '.join(build_cmd + war_targets),
- ' '.join(war_cmd + ['-a', 'install'])),
- out = 'war_install.sh',
- executable = True,
- )
-
- if repository and url:
- genrule(
- name = 'gen_war_deploy',
- cmd = sh_bang_template % (
- ' '.join(build_cmd + war_targets),
- ' '.join(war_cmd + [
- '-a', 'deploy',
- '--repository', repository,
- '--url', url])),
- out = 'war_deploy.sh',
- executable = True,
- )
diff --git a/tools/maven/repository.defs b/tools/maven/repository.defs
deleted file mode 100644
index c4e8fbf..0000000
--- a/tools/maven/repository.defs
+++ /dev/null
@@ -1,3 +0,0 @@
-MAVEN_REPOSITORY = 'sonatype-nexus-staging'
-MAVEN_SNAPSHOT_URL = 'https://oss.sonatype.org/content/repositories/snapshots'
-MAVEN_RELEASE_URL = 'https://oss.sonatype.org/service/local/staging/deploy/maven2'
diff --git a/tools/pack_war.py b/tools/pack_war.py
deleted file mode 100755
index ca21790..0000000
--- a/tools/pack_war.py
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/usr/bin/env python
-# Copyright (C) 2013 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-from __future__ import print_function
-from optparse import OptionParser
-from os import makedirs, path, symlink
-from subprocess import check_call
-import sys
-
-opts = OptionParser()
-opts.add_option('-o', help='path to write WAR to')
-opts.add_option('--lib', action='append', help='target for WEB-INF/lib')
-opts.add_option('--pgmlib', action='append', help='target for WEB-INF/pgm-lib')
-opts.add_option('--tmp', help='temporary directory')
-args, ctx = opts.parse_args()
-
-war = args.tmp
-jars = set()
-
-def prune(l):
- return [j for e in l for j in e.split(':')]
-
-def link_jars(libs, directory):
- makedirs(directory)
- for j in libs:
- if j not in jars:
- jars.add(j)
- n = path.basename(j)
- if j.find('buck-out/gen/gerrit-') > 0:
- n = j[j.find('buck-out'):].split('/')[2] + '-' + n
- symlink(j, path.join(directory, n))
-
-if args.lib:
- link_jars(prune(args.lib), path.join(war, 'WEB-INF', 'lib'))
-if args.pgmlib:
- link_jars(prune(args.pgmlib), path.join(war, 'WEB-INF', 'pgm-lib'))
-try:
- for s in ctx:
- check_call(['unzip', '-q', '-d', war, s])
- check_call(['zip', '-9qr', args.o, '.'], cwd=war)
-except KeyboardInterrupt:
- print('Interrupted by user', file=sys.stderr)
- exit(1)