765 Commits

Author SHA1 Message Date
Han-Wen Nienhuys
b0fb0a7a96 Remove 'final' from method signatures across gerrit.
Change-Id: I986a5507aa26ceb28305a7b08991e85238bde0e3
2017-06-14 09:18:42 +02:00
David Pursehouse
419ed573b9 BranchApi: Add method to get the branch's reflog
GetReflog uses Repository#getReflogReader, but this is not implemented
by DfsRepository which is used in the test framework. As a result, calls
to this API method from tests results in UnsupportedOperationException.

Modify GetReflog to catch the UOE and rethrow as MethodNotAllowed, so
we get a graceful failure rather than "internal server error".

In the tests, expect MethodNotAllowed, with a TODO to rework when/if
the implementation of getReflogReader is done in DfsRepository.

Change-Id: I0d0d718ca4e4ecf2c544ea6e912397c20e2fd7e3
2017-06-14 12:56:20 +09:00
David Pursehouse
f0d37e4f80 GetReflog: Move ReflogEntryInfo to a separate class in extension API
Change-Id: Ib9ab9b16cacaed88c5e1d901af37be086b635d0b
2017-06-14 12:53:42 +09:00
Alice Kober-Sotzek
03c48fc727 Merge "Add support for specifying the cherry-pick base commit" 2017-06-13 11:48:33 +00:00
Changcheng Xiao
e333258b94 Add support for specifying the cherry-pick base commit
This change extends the existing cherry-pick endpoints to allow
users to specify the base commit of the cherry-pick destination.

If the base commit represents a visible change revision on the
destination branch, the change status must be either 'New' or
'Merged'.

Alternatively, the base commit can be a merged commit on the
destination branch with no change associated with it.

Change-Id: I6721a2d88f4b73058dc1abf3e85c4184e46088c5
2017-06-13 12:57:15 +02:00
Alice Kober-Sotzek
d1a2e07e4f Merge changes from topic 'improve-diff-for-rebase'
* changes:
  Highlight hunks which are due to rebase on PolyGerrit
  Copy due_to_rebase to subgroups in gr-diff-processor
  Move diff tests from RevisionIT to RevisionDiffIT
  Mark hunks which are present due to a rebase when diffing patch sets
2017-06-12 13:20:22 +00:00
Edwin Kempin
6396d6ddc6 Add basic consistency checker for accounts
So far it only checks that preferred emails are backed by
corresponding external IDs. E.g. change I2b3c5c9d assumes that each
preferred email exists as external ID.

Change-Id: I824caa34545b1ba147fb71ede503104ba1d5481c
Signed-off-by: Edwin Kempin <ekempin@google.com>
2017-06-09 16:10:36 +02:00
Alice Kober-Sotzek
2f62486149 Mark hunks which are present due to a rebase when diffing patch sets
The diff between two patch sets contains hunks which weren't
introduced by either patch set if a rebase occurred between those
patch sets. Previous optimizations for this case simply omitted all
files which aren't touched by either of the patch sets.

This change goes one step further: All hunks which can clearly be
identified as being introduced by a rebase are marked. In case of
doubt (e.g. they overlap with a regular hunk), they aren't marked.

To be consistent with the previous behavior, we exclude all files from
the result which only contain hunks due to rebase. In some cases (e.g.
a patch set touches 'fileA' but all identified hunks were introduced
by the rebase), this rule can be stricter than the previously mentioned
(as the previous rule would still show file 'fileA' but we exclude it
now).

Hunks which are introduced by a rebase are identified by computing
the diff between the parents of the two patch sets and transforming
the result to differences in terms of treeA of patch set A and treeB
of patch set B. This follows a suggestion which was posted as a comment
(https://gerrit-review.googlesource.com/c/33091/5//COMMIT_MSG#7) in
change I63d3a21ad4f.

As we always determine which hunks are introduced by a rebase when
two commits are explicitly specified which don't share a common
parent, we will determine those hunks even when we compute the
diff between the parents of the patch sets provided that those
parents fulfill the condition of being separated by a rebase. Those
situations should be rare and hence we refrain from adding
optimizations for this case for the moment.

Bug: Issue 217
Change-Id: If06381d506d360f0e3d24d078dcb54692698e766
2017-06-09 13:38:43 +02:00
Saša Živkov
91c3c6140f Merge "PermissionBackend: Make considering admin credential configurable" 2017-06-08 11:12:13 +00:00
David Pursehouse
4d28854369 Merge branch 'stable-2.14'
* stable-2.14:
  Document how to set default UI
  Note on branch-specific labels with custom rules.pl
  GWT UI: Allow to set blocking label range rules
  Extend LFS plugin servlet so that Git LFS 2.0 Lock API is handled
  PolyGerrit: Fix undefined url in gr-dropdown

Change-Id: I01320e404daf1abd052c39321346e2eacff3dd09
2017-06-01 16:54:59 +09:00
Jacek Centkowski
8939ee8602 Extend LFS plugin servlet so that Git LFS 2.0 Lock API is handled
The change extends LFS serve regex so that the following operations are
handled (according to [1]):

  POST /locks - create lock
  GET /locks - list locks
  POST /locks/verify - list locks for verification
  POST /locks/lock_id/unlock - delete lock

Common LFS definitions, like paths, regexps, content type, etc., were
moved to gerrit-extension-api so that they can be shared between Gerrit
core and LFS plugin.

[1] https://github.com/git-lfs/git-lfs/blob/master/docs/api/locking.md
Change-Id: I8299000c827b5a34d6de1ed5fc650f74be4164a2
Signed-off-by: Jacek Centkowski <jcentkowski@collab.net>
2017-06-01 05:28:14 +00:00
Patrick Hiesel
4d2dd189b5 Add project~changeNumber as changeId pattern
This change adds support for a new change identifier in the /changes
REST API endpoint. It follows the discussion on
Idac92e61ee1471b074034eef39901b1b8e961706 and the two recent Gerrit
Hackathons.

The new change identifier serves multiple purposes:

1) Since it contains the project name, we can directly construct the
   ChangeApi without a secondary index lookup. This means that we can
   still serve requests to some endpoints, even in case of a complete
   index failure.
   When the project is added in the UI, we will still be able to serve
   change pages in case of an index failure. While the triplet also
   contains the project, it is unfeasible for the UI since it requires a
   branch name (which we don't want to have in the UI URLs) and has the
   changeId instead of the change number.
2) Reducing the number of secondary index lookups is a performance gain.
3) The project name being contained in the URL enables load balancers
   to shard requests based on the project without a need for an index
   lookup (which most load balancers do not support). The sharding
   configuration can then be as easy as a regular expression and a
   static project-to-machine mapping.
4) This change is also a first step in deprecating the other three
   change identifiers and unifying our API access pattern. This will
   happen gradually in upcoming changes. Also the UI will be adapted.

This change also adds extensive testing to both the new parsing logic as
well as all change identifiers in both the Java and the REST API.

Change-Id: I7a904fdd001c065af9897d9c08edce1cfbd43a14
2017-05-30 09:42:34 +02:00
David Ostrovsky
9ef569bf71 PermissionBackend: Make considering admin credential configurable
Default permission backend unconditionally considers administrator
credential when checking for plugin capabilities. This may not always
be what plugin authors want. Make it configurable, but preserve the
current default to be true. Now, different behaviour can be expressed
with:

  @RequiresCapability(
      value = AccessCiDatabaseCapability.ID,
      fallBackToAdmin = false
  )

Change-Id: Id16bfb539d22f47388e3d5464211128987276254
2017-05-30 07:22:00 +00:00
Edwin Kempin
062c9aa512 RevisionApi: Add support to get commit
This change includes tests for the new API which increases the test
coverage for GetCommit from 25% to 94%.

Change-Id: I19457b47bc92f846446a2fc7d3a9127aeaae476d
Signed-off-by: Edwin Kempin <ekempin@google.com>
2017-05-29 11:42:44 +02:00
David Pursehouse
1fec9396b3 Set version to 2.14.1-SNAPSHOT
The API includes some new classes since 2.14 and we need to be able
to build snapshot artifacts to test plugins that use the new classes.

Change-Id: Ifad31b93e5b5068c0d6952582f6882edc252e227
2017-05-26 11:20:43 +09:00
Changcheng Xiao
e04e846873 Support to set cherry-pick notification options
This change adds support to set notification options for the existing
cherry-pick change/commit REST endpoints.

Change-Id: I3b419a4d68ea186092163cddd354b5bf4de0daeb
2017-05-24 17:57:16 +02:00
David Pursehouse
2ae3b327d6 Merge branch 'stable-2.14'
* stable-2.14:
  Update list of maintainers in pom.xml files

Change-Id: I59270a205415a040312e36f89a66c665953d5908
2017-05-15 16:42:35 +09:00
David Pursehouse
3c0899307e Update list of maintainers in pom.xml files
Change-Id: I9bc103431c674b892d696490e7638a2a2f4ac408
2017-05-15 16:27:18 +09:00
Dave Borowitz
d6ee48ebc3 Control auto-publishing comments on push with preference
Change-Id: Ibf6c61d8c34ee790ca7ed29a0fad0b5e81910f09
2017-05-12 11:06:21 -04:00
Shawn Pearce
f537319c22 Migrate Move to PermissionBackend
Change-Id: Ice0bc9099f997e7c3c7d8cde03dd8434fa6c7e70
2017-05-12 08:42:01 +09:00
Dave Borowitz
0328589365 Merge "Support to delete a comment with 'NoteDbRewriter' in BatchUpdate" 2017-05-11 13:19:59 +00:00
ekempin
7cd6a74556 Merge "Allow to specify a message when the private flag on a change is set/unset" 2017-05-10 06:46:38 +00:00
Changcheng Xiao
e5b14cebd5 Support to delete a comment with 'NoteDbRewriter' in BatchUpdate
This change adds a new interface 'NoteDbRewriter', which can be used to
rewrite the NoteDb commit history in BatchUpdate.

By implementing the new interface, this change allows users with
administrate server capability to delete a comment by replacing the
comment's message.

To delete a whole comment, the rewritter is required to update the
commit message, which contains the number of the comments put in by the
original commit. This can be done in later changes when necessary.

Bug: Issue 4445
Change-Id: Icaeb3c24f5dc88f6b44b1297366a692a32676910
2017-05-09 21:56:26 +02:00
Edwin Kempin
364a86bafa Allow to specify a message when the private flag on a change is set/unset
This allows users to explain why the private flag on a change was
set/unset.

Since the requests to set/unset the private flags can have a request
body now, POST is more appropriate than PUT. Changing this is okay,
since the support for private flags was not released yet.

Since some proxies prohibit request bodies for DELETE requests offer
deletion of the private flag also as POST request on
/changes/<id>/private.delete.

The setPrivate method in ChangeApi is changed, which is okay since it
wasn't included into any release yet.

The UI doesn't offer to specify a message yet when the private flag is
set/unset but this may be implemented in a follow-up change.

Change-Id: Ib201114ffa397a313bca565d7fb52767b4c9197c
Signed-off-by: Edwin Kempin <ekempin@google.com>
2017-05-09 11:14:12 +02:00
David Pursehouse
2935175117 Merge branch 'stable-2.14'
* stable-2.14:
  Create group-indexed extension point
  Always use SSL implicitly for POP3 and IMAP
  InitSshd: Check if the ssh_host file exists with the other keys

Change-Id: I1ad22d5566314865c0c03bcf31f7802b653e82fa
2017-05-09 11:14:41 +09:00
Hugo Arès
ee788ddba6 Create group-indexed extension point
Change-Id: I79fb7404e10e619d87b4983346c90ca79c83ddff
2017-05-09 01:47:19 +00:00
Edwin Kempin
14d50ed949 Allow to create private/wip changes via CreateChange REST endpoint
Change-Id: I01029fcde99b57681cda8056efd00182e2227621
Signed-off-by: Edwin Kempin <ekempin@google.com>
2017-05-03 13:33:12 +02:00
David Ostrovsky
90e4f5bffa GET edit info: Expose base patch set number
Change-Id: I68e42543f72cf7b72420f34748711d837ba676f2
(cherry picked from commit 77fbd2189f4dc89e900d403c96e97d59353dc47d)
2017-05-01 10:02:25 +00:00
David Pursehouse
0f123852c4 Merge "GET edit info: Expose base patch set number" 2017-04-29 08:20:32 +00:00
David Pursehouse
a837a05bd7 Merge "Remove Result inner class from AccessCheckInfo" 2017-04-28 21:20:33 +00:00
Han-Wen Nienhuys
bc0cdbc88d Remove Result inner class from AccessCheckInfo
Before:

   {
     "result": {
       "message": "user Kristen Burns \u003cKristen.Burns@gerritcodereview.com\u03e (1000098) cannot see ref refs/heads/secret/master in project medium",
       "status": 403
     }
   }

After:

   {
    "message": "user Kristen Burns \u003cKristen.Burns@gerritcodereview.com\u003e (1000098) cannot see ref refs/heads/secret/master in project medium",
    "status": 403
   }

Change-Id: Idd846c3bd1d14b40bd601b34f0682e017cc50f0c
2017-04-28 17:56:06 +02:00
David Ostrovsky
77fbd2189f GET edit info: Expose base patch set number
Change-Id: I68e42543f72cf7b72420f34748711d837ba676f2
2017-04-28 17:47:12 +02:00
David Ostrovsky
db40d0b961 Add API for work in progress workflow
Change-Id: Idb0faa778977038cea336da38acdfb4089679618
2017-04-28 14:37:35 +02:00
David Ostrovsky
258849bd20 Add REST endpoints for work in progress workflow
New endpoints are documented in the follow-up change.

Change-Id: I322ff79c70416932d1287f1ee4f38837eda3ef02
2017-04-28 14:32:59 +02:00
David Pursehouse
579cabd0de Merge changes Iab3de63e,I83085033
* changes:
  Add REST API endpoints to mark a change as muted/unmuted
  New mute-label allows for temporarily unhighlighting changes in dashboard
2017-04-28 12:22:36 +00:00
Gustaf Lundh
e8647c699f Add REST API endpoints to mark a change as muted/unmuted
The new endpoints wrap the existing star endpoint, making it easier for
users to mute changes by a simple PUT, without input, rather than
having to construct a POST request with the necessary stars input.

The endpoints also provide "Mute" and "Unmute" buttons on the UI.
The buttons are not displayed for own changes.

Change-Id: Iab3de63e47bf7a850d8718febff326bc550c3abd
2017-04-28 14:14:21 +02:00
David Pursehouse
a555aeded1 Merge "Address post-submit review of CheckAccess" 2017-04-28 10:29:16 +00:00
Gustaf Lundh
e011d93ba6 New mute-label allows for temporarily unhighlighting changes in dashboard
If the "mute/<patchset_id>"-star is set by a user, and <patchset_id>
matches the current patch set, the change is always reported as "reviewed"
in the ChangeInfo.

This allows users to "de-highlight" changes in a dashboard until a new
patchset is uploaded.

The ChangeInfo muted-field will show if the change is currently in a
mute-state.

Change-Id: I83085033ff99d7b0ce1fe834fabfad5956db90ae
2017-04-28 12:17:47 +02:00
Han-Wen Nienhuys
d0128b0822 Address post-submit review of CheckAccess
Change-Id: I1b361d081b5fe79266c0f67e9ae17f1e1064ebbf
2017-04-28 11:57:41 +02:00
David Pursehouse
d656fa827b Add REST API endpoints to mark a change as ignored/unignored
Gerrit already allows a user to ignore changes (changes will be excluded
from incoming dashboards and email notification suppressed) but it is
not very accessible. The implementation makes use of the user stars API,
using a star with a specific label, "ignore". There is no UI for it, and
to ignore or unignore a change one must construct a PUT request with the
necessary input and manually send it by curl (or other means).

The new endpoints wrap the existing star endpoint, making it easier for
users to (un)ignore changes by a simple PUT, without input, rather than
having to construct a PUT request with the necessary stars input.

The endpoints also provide "Ignore" and "Unignore" buttons on the UI.
The buttons are not displayed for own changes.

Change-Id: Icbb226d7f5333a78fae27f2a4e5e6c86afd1f419
2017-04-28 10:54:57 +02:00
David Pursehouse
461cff743a Format Java files with google-java-format
Change-Id: I28866fc42249e64133ab68f18ade832e2956cb62
2017-04-28 06:39:48 +02:00
Han-Wen Nienhuys
e04df7e589 Add /config/check.access endpoint
The check.access endpoint is for administrative users. It can be
supplied with a (project, account) or (project, account, ref) tuple to
check that ACLs are behaving as expected.

Change-Id: Icf74b0fc4036312eef9f222aaff8e1769a051eec
2017-04-27 16:06:13 +02:00
Aaron Gable
8c650215eb Update Set Review API to behave in line with RFC 7231
This CL updates the implementation of PostReview to replace
all instances of raising UnprocessableEntityException
(HTTP 422) with failed Additions instead. This matches the
docs for Set Reviewer, which no longer mention 422 being a
valid response code. This also falls in line with
RFC 7231, which promotes HTTP 400s with detailed bodies
over 422s.

It also updates the documentation to be clearer about
how these API functions work.

Bug: issue 6016
Change-Id: I1adad98107ba021132293ec47c6a6da01787556e
2017-04-27 09:16:24 +02:00
David Pursehouse
03453bef90 Set version to 2.14
Change-Id: I5694579a543454322717a1d129e34d4140100479
2017-04-26 15:55:55 +02:00
David Pursehouse
ae46baef39 GlobalOrPluginPermission: Fix Javadoc warning
Change-Id: Ie90d47306db0a1116a55c2eed6aee19eb4157c3d
2017-04-25 17:31:07 +02:00
Luca Milanesio
931fe95745 Move PluginPermissions to extension API
Allow plugins to define their own capability and permission and check
for current user satisfy them, consuming PluginPermission from the
plugin extension API.

Change-Id: Iabba0ffa2a7e40605b09b41c25ab147395bb5f8c
2017-04-25 14:36:18 +02:00
David Pursehouse
0571f16880 Merge branch 'stable-2.14'
* stable-2.14:
  Release 2.14-rc1
  Create account-indexed extension point

Change-Id: I2f332f7c90aaa9ef148b19cd0a40d29554401330
2017-04-24 17:24:45 +02:00
David Pursehouse
b95cafed36 Merge "Merge branch 'stable-2.13' into stable-2.14" into stable-2.14 2017-04-24 15:23:30 +00:00
David Pursehouse
9eb6e4cc43 Merge branch 'stable-2.13' into stable-2.14
* stable-2.13:
  Create account-indexed extension point

Change-Id: Ic5bed970819460f3aa441fbce843c13c87dab951
2017-04-24 17:02:16 +02:00
Patrick Hiesel
e8bf91efaf Release 2.14-rc1
Change-Id: I85790145f2114b4ab9801a78fddc201e59766a8e
2017-04-24 16:03:54 +02:00