Commit Graph

121 Commits

Author SHA1 Message Date
Douwe Maan 742cee756b Merge branch 'jej-22869' into 'security'
Fix information disclosure in `Projects::BlobController#update`

It was possible to discover private project names by modifying `from_merge_request`parameter in `Projects::BlobController#update`. This fixes that.

- [ ] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG.md) entry added
- Tests
  - [x] Added for this feature/bug
  - [ ] All builds are passing
- [x] Conform by the [merge request performance guides](http://docs.gitlab.com/ce/development/merge_request_performance_guidelines.html)
- [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides)
- [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)

https://gitlab.com/gitlab-org/gitlab-ce/issues/22869

See merge request !2023
2016-11-28 21:25:18 -03:00
Yar 8782bb96cc Unify anchor link format for MR diff files !7298
Right now, the following naming scheme for diff files is used: diff-1, diff-2, ... and also we have "internal" format which is file-path-HASH, where HASH is sha1 of file path.
Besides, we have HASH_lineA_lineB format to link exact line number in MR diff. It makes sence to unify the way we link diff from outside, while leave "file-path-HASH" format for internal (js) usage.
Changes in this commit  allow to link diff just by HASH, if we don't want specify exact lines, also it changes "file-path-HASH" and "diff-NUMBER" links in code to this unified format.

Inspired by #24010 and !7298
2016-11-15 20:51:21 +03:00
tiagonbotelho 08dc8af733 fixes distinction between renaming a file and updating its content and
refactors update file
2016-09-09 23:05:30 -04:00
Frank West ade0c2c892 Prevents accidental overwrites of commits from UI
Currently when a user performs an update of a file through the UI  and there
has already been a change committed to the file the previous commits will be
overwritten without a check to see if the file has been changed.

This commit uses the last commit sha at the time the user starts editing the
file and compares it with the current sha of the file being edited to ensure
they are the same before committing the file. If the shas do not match we
throw an exception preventing the commit from the commit from occurring.

Fixes #5857
2016-08-15 02:34:55 +00:00
Tim Masliuchenko b6d545df51 Add unfold links for Side-by-Side view 2016-08-04 09:09:59 +03:00
tiagonbotelho dd3addad48 renames :file_name to :file_path 2016-07-13 11:19:14 +01:00
tiagonbotelho 98c0eb4615 test for nil params :file_name 2016-07-12 15:55:16 +01:00
tiagonbotelho 893f3f2856 refactors update action to change commit_params with the correct path 2016-07-12 15:55:16 +01:00
tiagonbotelho cf96c7596a changes the usasge of path to file_path on blob_controller for compatibillity with the create action 2016-07-12 15:55:16 +01:00
tiagonbotelho 4deab9a540 fixes merge request edit bug where it would generate a cloned file and not remove the previous one 2016-07-12 15:54:17 +01:00
tiagonbotelho b0ce99f5b0 implements the form for renaming the new filename on the file edit page 2016-07-12 15:48:43 +01:00
tiagonbotelho fba72e1e0c creates the update_file method in repository.rb and applies changes accordingly 2016-07-12 15:48:24 +01:00
tiagonbotelho 09194eebff successfully adds the new version with the updated name on the projects repo 2016-07-12 15:46:14 +01:00
tiagonbotelho d9561118e8 implements the form for renaming the new filename on the file edit page 2016-07-12 15:46:14 +01:00
tiagonbotelho f85834bc96 remove prints and useless comments 2016-07-12 15:46:14 +01:00
tiagonbotelho 10954f93e9 successfully adds the new version with the updated name on the projects repo 2016-07-12 15:45:59 +01:00
tiagonbotelho 50613fc6d3 implements the form for renaming the new filename on the file edit page 2016-07-12 15:44:57 +01:00
tiagonbotelho fc747dc346 fixes merge request edit bug where it would generate a cloned file and not remove the previous one 2016-07-12 15:42:19 +01:00
tiagonbotelho 1d5d5b1a42 refactors blob_controller 2016-07-12 15:33:39 +01:00
tiagonbotelho 9951854648 creates the update_file method in repository.rb and applies changes accordingly 2016-07-12 15:24:17 +01:00
tiagonbotelho bb627b6fc2 implements the form for renaming the new filename on the file edit page 2016-07-12 15:23:35 +01:00
tiagonbotelho ea50760b02 remove prints and useless comments 2016-07-12 15:23:02 +01:00
tiagonbotelho ac30c60ad9 successfully adds the new version with the updated name on the projects repo 2016-07-12 15:22:54 +01:00
tiagonbotelho b34310ae9e implements the form for renaming the new filename on the file edit page 2016-07-12 15:22:17 +01:00
Douwe Maan a9fa45f09e Represent DiffRefs as proper class instead of tuple array 2016-07-06 18:50:58 -04:00
Ruben Davila 7627cc1989 Validate presence of essential params for diff rendering
This will avoid application errors generated by the assumption of the
presence of these params.
2016-06-24 16:20:53 -05:00
Robert Speicher 8c454b3624 Add a `Blob` model that wraps `Gitlab::Git::Blob`
This allows us to take advantage of Rails' `to_partial_path` to render
the correct partial based on the Blob type, rather than cluttering the
view with conditionals.

It also allows (and will allow in the future) better encapsulation for
Blob-related logic which makes sense for our Rails app but might not
make as much sense for the core `gitlab_git` library, such as detecting
if the blob is an SVG.
2016-02-18 22:45:30 -05:00
Jacob Vosmaer 51574d779c Merge branch 'master' of https://gitlab.com/gitlab-org/gitlab-ce into lazy-blobs 2016-02-01 13:51:05 +01:00
Jacob Vosmaer 64c8ee47c9 WIP lazy blobs 2016-02-01 10:41:52 +01:00
Douwe Maan 150b4f66e6 Make sure non-highlighted diffs are still escaped 2016-01-22 01:47:17 +01:00
Douwe Maan 8dfad143d4 Add inline diff markers in highlighted diffs. 2016-01-14 22:28:07 +01:00
Rubén Dávila c476395b4d Reuse existent vars with ref and path. #3945 2016-01-12 11:14:41 -05:00
Rubén Dávila 21b602c60a Change strategy to highlight diffs. #3945
Now we apply syntax highlighting to the whole old and new files.
This basically help us to highlight adequately multiline content.
2016-01-07 22:37:01 -05:00
Rubén Dávila 3fbcf52ec8 Apply syntax highlighting when expanding diff plus some refactor. #3945 2015-12-31 01:05:52 -05:00
Douwe Maan d9c82d679f Automatically fork a project when not allowed to edit a file. 2015-12-18 10:03:34 +01:00
Douwe Maan df6750d3d6 Default target branch to patch-n when editing file in protected branch 2015-12-08 16:42:10 +01:00
Douwe Maan f3cfd20952 DRY up code 2015-11-18 17:17:38 +01:00
Douwe Maan e945ec0280 Add "Start a new merge request" option to every commit form 2015-11-17 18:53:56 +01:00
Douwe Maan 0b540a0fad Merge branch 'master' into dirceu/gitlab-ce-new-merge-request-from-file-edit 2015-11-17 17:01:28 +01:00
Ben Ford 3be9d2c422 Add ability to create directories in the editor
Simply type a name with a `/` directory separator and new directories
will be created. This does not do the fancy UI work that github.com
does, but it will get the job done.

I could not find tests for file creation, so I didn't add a test for
this slight behaviour modification. I did test directory traversals
though, using both absolute paths like `/tmp/foo.txt` and relative paths
like `../../foo.txt`. Neither case escaped the repository, though
attempting to traverse with a relative path resulted in a 500 error that
did not affect application stability upon reload.
2015-10-29 15:49:07 +01:00
Dirceu Pereira Tiegs 3d50b99d01 Add option to create merge request when editing/creating a file 2015-10-19 20:25:35 -02:00
Valery Sizov 8346dde052 Only render 404 page from /public 2015-10-13 20:12:34 +03:00
Stan Hu 0ab6ca93aa Add directory feature button
Change "+" icon under "Files" section to have three options:

* Create file
* Upload file
* New directory

Upload file is no longer accessible from the "Create file" page.
Users can now select a target branch in upload file as well.

Closes #2799: Fixes a bug where file modes were overwritten after a commit

Closes https://github.com/gitlabhq/gitlabhq/issues/8253: Existing files
can no longer be overwritten in the "Create file" section.

Closes #2557
2015-10-07 04:22:55 -07:00
Stan Hu ac855e5ed3 Move partial locals out of controller 2015-09-17 07:24:45 -07:00
Stan Hu d9af6f79ed Change the replace placeholder to use the filename
Dynamically adjust placedholder for uploads and fix Dropzone event handlers

Override error handler to prevent error messages from being inserted underneath image preview

Fix tests

Use regexp instead of startsWith for better browser compatibility

Remove duplicate code in _replace.html.haml and use one template

Remove files upon error and retain alert messages until user adds a new file
2015-09-15 13:07:32 -07:00
liyakun e2ece2bc35 Add "Replace" and "Upload" features
Refactor upload and replace functionality

    Rename file and move CSS

    Fix typo

    Make dropzone a div

    Remove unnecessary file

    Change color of "upload existing one"

    Add missing changes
2015-09-15 02:12:56 +02:00
Dmitriy Zaporozhets 3e259ea8bc Revert "Merge branch 'revert-satellites' into 'master' "
This reverts commit 5daf44b7c8, reversing
changes made to 2f706fbd23.
2015-08-11 14:33:31 +02:00
Dmitriy Zaporozhets d4cfa0bf76
Revert "Refactor web editor"
This reverts commit dfccb06dda.

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2015-08-11 11:49:09 +02:00
Dmitriy Zaporozhets dfccb06dda
Refactor web editor
* fix problem with editing non-master branch
* before commit make sure branch exists
* dont allow user change file in one branch and commit to another existing branch
* remove a lot of code duplication
* remove outdated statellite errors

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2015-06-05 15:01:38 +02:00
Jeroen van Baarsen 5a4ebfb47a Fixed the Rails/ActionFilter cop
Signed-off-by: Jeroen van Baarsen <jeroenvanbaarsen@gmail.com>
2015-04-20 15:39:37 +02:00
Valery Sizov 71a844cdae Web Editor: save to new branch 2015-02-24 11:43:20 +02:00
Vinnie Okada 2a9eed6620 Merge branch 'master' into rails-4.1.9
Conflicts:
	app/views/projects/commits/_commit.html.haml
	app/views/projects/issues/_issue.html.haml
	app/views/projects/issues/_issue_context.html.haml
	app/views/projects/merge_requests/_merge_request.html.haml
	app/views/projects/merge_requests/show/_context.html.haml
2015-02-21 12:55:28 -07:00
Douwe Maan 00408f37e3 Move 'require_non_empty_project' filter to front so 'assign_ref_vars' doesn't 404. 2015-02-20 17:20:03 +01:00
Vinnie Okada 76aad9b76e Upgrade to Rails 4.1.9
Make the following changes to deal with new behavior in Rails 4.1.2:

* Use nested resources to avoid slashes in arguments to path helpers.
2015-02-14 11:09:23 -07:00
Dmitriy Zaporozhets cc39bca3fa Rubocop: Style/AlignHash enabled 2015-02-02 21:15:44 -08:00
Dmitriy Zaporozhets ed91378627 Fix blob controller rendering in case of errors 2015-01-26 15:12:13 -08:00
Dmitriy Zaporozhets 59b08942aa Refactor blob controllers 2015-01-26 15:02:28 -08:00
Valery Sizov 6f34d40436 remove auth duplication 2014-11-05 11:04:08 +02:00
Dmitriy Zaporozhets 8ad9a75f88 Merge pull request #8030 from cirosantilli/factor-authorize
Factor authorize_push! and authorize_code_access!
2014-10-21 11:43:12 +03:00
Ciro Santilli 4d0d5e79ba Factor authorize_push! and authorize_code_access!
with existing method_missing. Pattern already used extensively,
so let's be consistent and use it everywhere.
2014-10-13 21:31:49 +02:00
Ciro Santilli 2d23522107 Use :message key, not :error for File::Service. 2014-10-13 20:55:09 +02:00
skv 4e40800166 diff unfold 2014-08-14 15:48:14 +04:00
Marin Jankovski 005752e4c6 Check if blob or tree and redirect to the correct one. 2014-07-07 15:46:57 +02:00
Dmitriy Zaporozhets 237ddd6024
Improve authorization for new/edit blob pages
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-01-24 21:29:52 +02:00
Dmitriy Zaporozhets 1d2bdb4d58
Move all Context classes into Services
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-01-16 19:03:42 +02:00
Takuya Nishigori e78b90ab1d Fix messages typo 2013-12-16 17:57:50 +09:00
Dmitriy Zaporozhets bd20ec1a34 Remove file from repository feature
After click on remove file button you will be asked for commit message
via modal window. After submitting modal form file will be removed from
repository

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2013-11-19 16:14:56 +02:00
Dmitriy Zaporozhets 970d86b7c5 Refactor blob finding 2013-10-01 20:34:41 +03:00
Dmitriy Zaporozhets 1d3f03fb69 Fix blob and repo stuff after gitlab_git v3 2013-10-01 18:26:55 +03:00
Dmitriy Zaporozhets ae9dd62762 Update code to work with gitlab_git 3 2013-10-01 17:00:28 +03:00
Dmitriy Zaporozhets 2ed7cbfba4 Move projects controllers/views in Projects module 2013-06-23 19:47:22 +03:00