Commit Graph
72 Commits
Author SHA1 Message Date
zeripathandGitHub fb5af37b3e Add Close() method to gogitRepository (#8901) (#8958)
Backport #8901 - Adjusted slightly for 1.9

In investigating #7947 it has become clear that the storage component of go-git repositories needs closing.

This PR adds this Close function and adds the Close functions as necessary.

In TransferOwnership the ctx.Repo.GitRepo is closed if it is open to help prevent the risk of multiple open files.

Fixes #7947
2019-11-13 18:51:33 +00:00
silverwindandzeripath da23041257 fix extra newlines when copying from diff in Firefox (#7288)
* fix extra newlines when copying from diff

See https://bugzilla.mozilla.org/show_bug.cgi?id=1273836

Basically, the <pre><code> seems to add a forced newline that is not
possible to get rid of via CSS, so I replaced it with just a <code>.

Secondly, .lines-type-marker also forced a newline in the copied text,
but that was possible to get rid of via user-select.

Safari still has a extraneous newline in the copied text of unknown
origin, but this should not block stop this PR.

* simplify .line-type-marker

* fix selector

* remove erronous ^^^

* Fix empty split diff

* Fix arc-theme-green

* fix add comment

* ensure line-num is copied too

* Update templates/repo/diff/box.tmpl

Co-Authored-By: zeripath <[email protected]>

* attempt to fix safari via removing <code>

* remove useless whitespace at the end of 'class'

* remove inter-tag whitespace for code <td>s

* more inter-tag removal

* final inter-tag removal

* attempt to fix empty line copy

* move and comment getLineContent

* fix golint

* make background grey for missing added code
2019-06-26 22:35:07 +01:00
Lunny Xiaoandtechknowlogick edc94c7041 Monitor all git commands; move blame to git package and replace git as a variable (#6864)
* monitor all git commands; move blame to git package and replace git as a variable

* use git command but not other commands

* fix build

* move exec.Command to git.NewCommand

* fix fmt

* remove unrelated changes

* remove unrelated changes

* refactor IsEmpty and add tests

* fix tests

* fix tests

* fix tests

* fix tests

* remove gitLogger

* fix fmt

* fix isEmpty

* fix lint

* fix tests
2019-06-26 14:15:26 -04:00
zeripathandGitHub 5908bb1030 Make diff line-marker non-selectable (#7279)
* Make diff line-marker non-selectable
* Move to use data-* as per @mrsdizzie
* fix missing line nums
* Add a minimum-width to force right-align of the line num
* Move line-type-marker into separate column
2019-06-24 21:23:52 +01:00
kolaenteandtechknowlogick f9ec2f89f2 Add golangci (#6418) 2019-06-12 15:41:28 -04:00
Lunny XiaoandGitHub d578b71d61 move code.gitea.io/git to code.gitea.io/gitea/modules/git (#6364)
* move code.gitea.io/git to code.gitea.io/gitea/modules/git

* fix imports

* fix fmt

* fix misspell

* remove wrong tests data

* fix unit tests

* fix tests

* fix tests

* fix tests

* fix tests

* fix tests

* enable Debug to trace the failure tests

* fix tests

* fix tests

* fix tests

* fix tests

* fix tests

* comment commit count tests since git clone depth is 50

* fix tests

* update from code.gitea.io/git

* revert change to makefile
2019-03-27 17:33:00 +08:00
mrsdizzieandLauris BH 7780ea8890 Fix ParsePatch function to work with quoted diff --git strings (#6323)
* Fix ParsePatch to work properly with quoted diff --git string

Currently ParsePatch fails when a diff contains a quoted diff line like:

diff --git "a/file" "b/file"

This patch makes it properly parse the line when that happens.

Fixes #6309

* Add test for regular case while here

* Simplify string modification
2019-03-14 18:09:53 +02:00
kolaenteandtechknowlogick e79e9248fd Fix regex to support optional end line of old section in diff hunk (#5096)
+ Named groups in reges for easier group parsing
2018-10-17 22:03:49 -04:00
Lauris BHandGitHub 4befec242a Code review UI improvements and bugfixes (#4682)
* Code review UI improvements

* More fixes to dark theme

* Style fix

* Fix to allow add code review comments only on review files tab

* More readability dark style fixes

* Fix commenting on deleted files. Fixes #4752

* Fix line blame getting for multiple corner cases
2018-09-17 17:59:49 +03:00
nemoinhoandtechknowlogick ca112f0a04 Add whitespace handling to PR-comparsion (#4683)
* Add whitespace handling to PR-comparsion

In a PR we have to keep an eye on a lot of different things. But sometimes the
bare code is the key-thing we want to care about and just don't want to care
about fixed indention on some places. Especially if we follow the pathfinder
rule we face a lot of these situations because these changes don't break the
code in many languages but improve the readability a lot.

So this change introduce a fine graned button to adjust the way how the
reviewer want to see whitespace-changes within the code.

The possibilities reflect the possibilities from git itself except of the
`--ignore-blank-lines` flag because that one is also handled by `-b` and is
really rare.

Signed-off-by: Felix Nehrke <[email protected]>
2018-08-14 13:49:33 -04:00
Lauris BHandJonas Franz 6e64f9db8e Pull request review/approval and comment on code (#3748)
* Initial ui components for pull request review

* Add Review
Add IssueComment types

Signed-off-by: Jonas Franz <[email protected]>

(cherry picked from commit 2b4daab)
Signed-off-by: Jonas Franz <[email protected]>

* Replace ReviewComment with Content

Signed-off-by: Jonas Franz <[email protected]>

* Add load functions
Add ReviewID to findComments

Signed-off-by: Jonas Franz <[email protected]>

* Add create review comment implementation
Add migration for review
Other small changes

Signed-off-by: Jonas Franz <[email protected]>

* Simplified create and find functions for review

Signed-off-by: Jonas Franz <[email protected]>

* Moved "Pending" to first position

Signed-off-by: Jonas Franz <[email protected]>

* Add GetCurrentReview to simplify fetching current review

Signed-off-by: Jonas Franz <[email protected]>

* Preview for listing comments

Signed-off-by: Jonas Franz <[email protected]>

* Move new comment form to its own file

Signed-off-by: Jonas Franz <[email protected]>

* Implement Review form
Show Review comments on comment stream

Signed-off-by: Jonas Franz <[email protected]>

* Add support for single comments
Showing buttons in context

Signed-off-by: Jonas Franz <[email protected]>

* Add pending tag to pending review comments

Signed-off-by: Jonas Franz <[email protected]>

* Add unit tests for Review

Signed-off-by: Jonas Franz <[email protected]>

* Fetch all review ids at once
Add unit tests

Signed-off-by: Jonas Franz <[email protected]>

* gofmt

Signed-off-by: Jonas Franz <[email protected]>

* Improved comment rendering in "Files" view by adding Comments to DiffLine

Signed-off-by: Jonas Franz <[email protected]>

* Add support for invalidating comments

Signed-off-by: Jonas Franz <[email protected]>

* Switched back to code.gitea.io/git

Signed-off-by: Jonas Franz <[email protected]>

* Moved review migration from v64 to v65

Signed-off-by: Jonas Franz <[email protected]>

* Rebuild css

Signed-off-by: Jonas Franz <[email protected]>

* gofmt

Signed-off-by: Jonas Franz <[email protected]>

* Improve translations

Signed-off-by: Jonas Franz <[email protected]>

* Fix unit tests by updating fixtures and updating outdated test

Signed-off-by: Jonas Franz <[email protected]>

* Comments will be shown at the right place now

Signed-off-by: Jonas Franz <[email protected]>

* Add support for deleting CodeComments

Signed-off-by: Jonas Franz <[email protected]>

* Fix problems caused by files in subdirectories

Signed-off-by: Jonas Franz <[email protected]>

* Add support for showing code comments of reviews in conversation

Signed-off-by: Jonas Franz <[email protected]>

* Add support for "Show/Hide outdated"

Signed-off-by: Jonas Franz <[email protected]>

* Update code.gitea.io/git

Signed-off-by: Jonas Franz <[email protected]>

* Add support for new webhooks

Signed-off-by: Jonas Franz <[email protected]>

* Update comparison

Signed-off-by: Jonas Franz <[email protected]>

* Resolve conflicts

Signed-off-by: Jonas Franz <[email protected]>

* Minor UI improvements

* update code.gitea.io/git

* Fix ui bug reported by @lunny causing wrong position of add button
Add functionality to "Cancel" button
Add scale effects to add button
Hide "Cancel" button for existing comments

Signed-off-by: Jonas Franz <[email protected]>

* Prepare solving conflicts

Signed-off-by: Jonas Franz <[email protected]>

* Show add button only if no comments already exist for the line

Signed-off-by: Jonas Franz <[email protected]>

* Add missing vendor files

Signed-off-by: Jonas Franz <[email protected]>

* Check if reviewer is nil

Signed-off-by: Jonas Franz <[email protected]>

* Show forms only to users who are logged in

Signed-off-by: Jonas Franz <[email protected]>

* Revert "Show forms only to users who are logged in"

This reverts commit c083682

Signed-off-by: Jonas Franz <[email protected]>

* Save patch in comment
Render patch for code comments

Signed-off-by: Jonas Franz <[email protected]>

* Add link to comment in code

Signed-off-by: Jonas Franz <[email protected]>

* Add reply form to comment list
Show forms only to signed in users

Signed-off-by: Jonas Franz <[email protected]>

* Add 'Reply' as translatable
Add CODE_COMMENT_LINES setting

Signed-off-by: Jonas Franz <[email protected]>

* gofmt

Signed-off-by: Jonas Franz <[email protected]>

* Fix problems introduced by checking for singed in user

Signed-off-by: Jonas Franz <[email protected]>

* Add v70

Signed-off-by: Jonas Franz <[email protected]>

* Update generated stylesheet

Signed-off-by: Jonas Franz <[email protected]>

* Fix preview
Beginn with new review comment patch system

Signed-off-by: Jonas Franz <[email protected]>

* Add new algo to generate diff for line range
Remove old algo used for cutting big diffs (it was very buggy)

* Add documentation and example for CutDiffAroundLine

* Fix example of CutDiffAroundLine

* Fix some comment UI rendering bugs

* Add code comment edit mode

* Send notifications / actions to users until review gets published
Fix diff generation bug
Fix wrong hashtag

* Fix vet errors

* Send notifications also for single comments

* Fix some notification bugs, fix link

* Fix: add comment icon is only shown on code lines

* Add lint comment

* Add unit tests for git diff

* Add more error messages

* Regenerated css

Signed-off-by: Jonas Franz <[email protected]>

* fmt

Signed-off-by: Jonas Franz <[email protected]>

* Regenerated CSS with latest less version

Signed-off-by: Jonas Franz <[email protected]>

* Fix test by updating comment type to new ID

Signed-off-by: Jonas Franz <[email protected]>

* Introducing CodeComments as type for map[string]map[int64][]*Comment
Other minor code improvements

Signed-off-by: Jonas Franz <[email protected]>

* Fix data-tab issues

Signed-off-by: Jonas Franz <[email protected]>

* Remove unnecessary change

Signed-off-by: Jonas Franz <[email protected]>

* refactored checkForInvalidation

Signed-off-by: Jonas Franz <[email protected]>

* Append comments instead of setting

Signed-off-by: Jonas Franz <[email protected]>

* Use HeadRepo instead of BaseRepo

Signed-off-by: Jonas Franz <[email protected]>

* Update migration

Signed-off-by: Jonas Franz <[email protected]>

* Regenerated CSS

Signed-off-by: Jonas Franz <[email protected]>

* Add copyright

Signed-off-by: Jonas Franz <[email protected]>

* Update index.css

Signed-off-by: Jonas Franz <[email protected]>
2018-08-06 06:43:21 +02:00
Ethan KoenigandLauris BH 6eaeb01ecf Update code.gitea.io/git (#3482) 2018-02-10 20:19:26 +02:00
Kim "BKC" CarlbäckerandLauris BH 4b5197beb4 Fix Uninitialized variable in ParsePatch (#3156) 2017-12-12 02:32:36 +02:00
Duncan OgilvieandLauris BH c80d147fa9 Improve memory usage when reaching diff limits (#2990)
Signed-off-by: Duncan Ogilvie <[email protected]>
2017-11-29 01:22:24 +02:00
Ethan KoenigandBo-Yi Wu 57cabb3ad3 Fix diff of renamed and modified file (#1967) 2017-06-14 04:07:09 -05:00
Kuba TyszkoandBo-Yi Wu 5d6b71fdbb fixes pull request hanging indefinitely when it contains normal and LFS file pointers (#1425) 2017-04-03 10:21:09 +08:00
Matthias LoiblandLunny Xiao d1006150fb Refactor process package and introduce ProcessManager{} with tests (#75)
* Add a process.Manager singleton with process.GetManager()

* Use process.GetManager everywhere

* Fix godoc comments for process module

* Increment process counter id after locking the mutex
2017-01-17 13:58:58 +08:00
Ethan KoenigandLunny Xiao 1207bda94b Fix typos in models/ (#576) 2017-01-05 08:50:34 +08:00
Fabian ZarembaandLunny Xiao 2e7ccecfe6 Git LFS support v2 (#122)
* Import github.com/git-lfs/lfs-test-server as lfs module base

Imported commit is 3968aac269a77b73924649b9412ae03f7ccd3198

Removed:

Dockerfile CONTRIBUTING.md mgmt* script/ vendor/ kvlogger.go
.dockerignore .gitignore README.md

* Remove config, add JWT support from github.com/mgit-at/lfs-test-server

Imported commit f0cdcc5a01599c5a955dc1bbf683bb4acecdba83

* Add LFS settings

* Add LFS meta object model

* Add LFS routes and initialization

* Import github.com/dgrijalva/jwt-go into vendor/

* Adapt LFS module: handlers, routing, meta store

* Move LFS routes to /user/repo/info/lfs/*

* Add request header checks to LFS BatchHandler / PostHandler

* Implement LFS basic authentication

* Rework JWT secret generation / load

* Implement LFS SSH token authentication with JWT

Specification: https://github.com/github/git-lfs/tree/master/docs/api

* Integrate LFS settings into install process

* Remove LFS objects when repository is deleted

Only removes objects from content store when deleted repo is the only
referencing repository

* Make LFS module stateless

Fixes bug where LFS would not work after installation without
restarting Gitea

* Change 500 'Internal Server Error' to 400 'Bad Request'

* Change sql query to xorm call

* Remove unneeded type from LFS module

* Change internal imports to code.gitea.io/gitea/

* Add Gitea authors copyright

* Change basic auth realm to "gitea-lfs"

* Add unique indexes to LFS model

* Use xorm count function in LFS check on repository delete

* Return io.ReadCloser from content store and close after usage

* Add LFS info to runWeb()

* Export LFS content store base path

* LFS file download from UI

* Work around git-lfs client issue with unauthenticated requests

Returning a dummy Authorization header for unauthenticated requests
lets git-lfs client skip asking for auth credentials
See: https://github.com/github/git-lfs/issues/1088

* Fix unauthenticated UI downloads from public repositories

* Authentication check order, Finish LFS file view logic

* Ignore LFS hooks if installed for current OS user

Fixes Gitea UI actions for repositories tracking LFS files.
Checks for minimum needed git version by parsing the semantic version
string.

* Hide LFS metafile diff from commit view, marking as binary

* Show LFS notice if file in commit view is tracked

* Add notbefore/nbf JWT claim

* Correct lint suggestions - comments for structs and functions

- Add comments to LFS model
- Function comment for GetRandomBytesAsBase64
- LFS server function comments and lint variable suggestion

* Move secret generation code out of conditional

Ensures no LFS code may run with an empty secret

* Do not hand out JWT tokens if LFS server support is disabled
2016-12-26 09:16:37 +08:00
Thomas BoergerandGitHub 83ed234472 Integrate templates into bindata optionally (#314)
Integrated optional bindata for the templates
2016-12-06 18:58:31 +01:00
Sandro Santilli 3fba29c571 Expand documentations 2016-11-24 09:30:08 +01:00
Sandro Santilli 6e644726d0 Lint git_diff.go
Semi-automatic linting (don't really document things)
2016-11-24 09:02:58 +01:00
Thibault Meyer ddee4c8b58 Normalize files with gofmt 2016-11-11 13:11:45 +01:00
Sandro SantilliandThibault Meyer 4247304f5a Update import paths from github.com/go-gitea to code.gitea.io (#135)
- Update import paths from github.com/go-gitea to code.gitea.io
- Fix import path for travis

See https://docs.travis-ci.com/user/languages/go#Go-Import-Path
2016-11-10 17:24:48 +01:00
Sandro Santilli f14232d2e9 This one I overlooked before 2016-11-07 17:33:03 +01:00
Sandro Santilli f6a11e0de1 More MixedCase consts 2016-11-07 17:24:59 +01:00
Sandro SantilliandAndrey Nering 6e4252dad4 Replace gogits/git-module dependency with go-gitea/git (#94)
* Replace gogits/git-module dependency with go-gitea/git

Fixes #92

* Remove git alias for git module import (not needed)
2016-11-06 11:18:34 -02:00
Matthias Loibl 1f44b01e2a Fix imports found by goimports. 2016-11-05 17:56:35 +01:00
Rémy BoulanouarandAndrey Nering 2d68bd1ef9 Change import reference to match gitea instead of gogs (#37) 2016-11-03 10:29:56 -02:00
Unknwon b1504ed99a #3464 add diff signs which does not have inline diff 2016-08-16 07:37:28 -07:00
Unknwon 9349def72e #3464 reproduce diff signs
Commited wrong file.
2016-08-16 07:33:53 -07:00
Unknwon cd89f6c502 Web editor: improve edit file and diff preview 2016-08-14 23:52:24 -07:00
Andrey Neringand无闻 2772791fda Improve diff highlight (#3390)
- Try to reduce memory allocations
- Add possibility to disable diff highlight (can improve performance for large diffs)
- Tweaking with cost for prettier (cleaner) diffs
- Do not calculate diff when the number of removed lines in a block is not equal to the number of added lines (this usually resulted in ugly diffs)
2016-08-07 09:49:47 -07:00
Unknwon 10dc330640 #3345 dump content directly to HTTP ResponseWriter 2016-07-30 23:39:58 +08:00
Dennis Chenand无闻 dfab54d5a2 Diff patch (#3345)
* Add support for .diff and .patch

Add the ability to get text-diff and format-patch by adding .diff or
.patch in the end of a commit url. Issue #2641

* models: git_diff: various fixes

* Renames commitId to commitID.
* Writes stderr to a bytes.Buffer and displays proper error message on
command failure.
* Various style changes.

Signed-off-by: Dennis Chen <[email protected]>
2016-07-30 23:02:22 +08:00
Siarhei Navatskiand无闻 cf85e9eb7b add IsSubmodule field to DiffFile and hide view file button on diff page for submodules (#3097) 2016-07-23 02:18:56 +08:00
Andrey Neringand无闻 743d22669a Re-work MAX_DIFF_LINES: supress diff per file, not the whole diff (#3174) 2016-06-29 23:11:00 +08:00
Andrey Nering d160c7e565 Little refactoring of diff highlight.
Moving cache variable to template instead of in the struct.
2016-02-21 18:45:24 -03:00
Andrey Nering 2bfb8bb5fd Enable sintax highlighting on diff view. Close #733 2016-02-04 18:21:47 -02:00
Andrey Nering 5deb726f3f Refactoring of inline diff computing to prevent empty diff box. Fix #2489 2016-01-27 18:54:08 -02:00
Unknwon 8a93113192 roll back a small change 2016-01-09 15:04:28 +08:00
Unknwon 86bce4a2ae minor fix to #2335 2016-01-09 14:51:17 +08:00
Andrey Nering 697b0e2aba Fix: now highlights in diff view are getting the correct lines. 2016-01-08 16:33:27 -02:00
Andrey Nering bf11ad19ea Semantic fixes. 2016-01-07 11:27:35 -02:00
Andrey Nering 81ed5c4bee Declaring specific types for enums constants.
This makes the code more strict since you can't assign or compare
values of different types without proper cast.
2016-01-06 18:00:40 -02:00
Andrey Nering 73474c043b Highlighting differences of lines in the diff view. 2016-01-06 17:46:56 -02:00
Unknwon 4993ab1a76 #2185 fall back to use custom chardet lib 2015-12-31 22:13:47 -05:00
Unknwon 19423957b1 rename import path 2015-12-15 17:25:45 -05:00
Unknwon 50264200f0 fix huge diff hangs 2015-12-14 09:38:21 -05:00
Unknwon 95f9c85bcc #2185 use Go sub-repo to detect encoding 2015-12-13 19:56:33 -05:00