You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

setting.go 51 kB

11 years ago
11 years ago
11 years ago
11 years ago
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
8 years ago
11 years ago
11 years ago
11 years ago
11 years ago
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
8 years ago
11 years ago
Feature: Timetracking (#2211) * Added comment's hashtag to url for mail notifications. * Added explanation to return statement + documentation. * Replacing in-line link generation with HTMLURL. (+gofmt) * Replaced action-based model with nil-based model. (+gofmt) * Replaced mailIssueActionToParticipants with mailIssueCommentToParticipants. * Updating comment for mailIssueCommentToParticipants * Added link to comment in "Dashboard" * Deleting feed entry if a comment is going to be deleted * Added migration * Added improved migration to add a CommentID column to action. * Added improved links to comments in feed entries. * Fixes #1956 by filtering for deleted comments that are referenced in actions. * Introducing "IsDeleted" column to action. * Adding design draft (not functional) * Adding database models for stopwatches and trackedtimes * See go-gitea/gitea#967 * Adding design draft (not functional) * Adding translations and improving design * Implementing stopwatch (for timetracking) * Make UI functional * Add hints in timeline for time tracking events * Implementing timetracking feature * Adding "Add time manual" option * Improved stopwatch * Created report of total spent time by user * Only showing total time spent if theire is something to show. * Adding license headers. * Improved error handling for "Add Time Manual" * Adding @sapks 's changes, refactoring * Adding API for feature tracking * Adding unit test * Adding DISABLE/ENABLE option to Repository settings page * Improving translations * Applying @sapk 's changes * Removing repo_unit and using IssuesSetting for disabling/enabling timetracker * Adding DEFAULT_ENABLE_TIMETRACKER to config, installation and admin menu * Improving documentation * Fixing vendor/ folder * Changing timtracking routes by adding subgroups /times and /times/stopwatch (Proposed by @lafriks ) * Restricting write access to timetracking based on the repo settings (Proposed by @lafriks ) * Fixed minor permissions bug. * Adding CanUseTimetracker and IsTimetrackerEnabled in ctx.Repo * Allow assignees and authors to track there time too. * Fixed some build-time-errors + logical errors. * Removing unused Get...ByID functions * Moving IsTimetrackerEnabled from context.Repository to models.Repository * Adding a seperate file for issue related repo functions * Adding license headers * Fixed GetUserByParams return 404 * Moving /users/:username/times to /repos/:username/:reponame/times/:username for security reasons * Adding /repos/:username/times to get all tracked times of the repo * Updating sdk-dependency * Updating swagger.v1.json * Adding warning if user has already a running stopwatch (auto-timetracker) * Replacing GetTrackedTimesBy... with GetTrackedTimes(options FindTrackedTimesOptions) * Changing code.gitea.io/sdk back to code.gitea.io/sdk * Correcting spelling mistake * Updating vendor.json * Changing GET stopwatch/toggle to POST stopwatch/toggle * Changing GET stopwatch/cancel to POST stopwatch/cancel * Added migration for stopwatches/timetracking * Fixed some access bugs for read-only users * Added default allow only contributors to track time value to config * Fixed migration by chaging x.Iterate to x.Find * Resorted imports * Moved Add Time Manually form to repo_form.go * Removed "Seconds" field from Add Time Manually * Resorted imports * Improved permission checking * Fixed some bugs * Added integration test * gofmt * Adding integration test by @lafriks * Added created_unix to comment fixtures * Using last event instead of a fixed event * Adding another integration test by @lafriks * Fixing bug Timetracker enabled causing error 500 at sidebar.tpl * Fixed a refactoring bug that resulted in hiding "HasUserStopwatch" warning. * Returning TrackedTime instead of AddTimeOption at AddTime. * Updating SDK from go-gitea/go-sdk#69 * Resetting Go-SDK back to default repository * Fixing test-vendor by changing ini back to original repository * Adding "tags" to swagger spec * govendor sync * Removed duplicate * Formatting templates * Adding IsTimetrackingEnabled checks to API * Improving translations / english texts * Improving documentation * Updating swagger spec * Fixing integration test caused be translation-changes * Removed encoding issues in local_en-US.ini. * "Added" copyright line * Moved unit.IssuesConfig().EnableTimetracker into a != nil check * Removed some other encoding issues in local_en-US.ini * Improved javascript by checking if data-context exists * Replaced manual comment creation with CreateComment * Removed unnecessary code * Improved error checking * Small cosmetic changes * Replaced int>string>duration parsing with int>duration parsing * Fixed encoding issues * Removed unused imports Signed-off-by: Jonas Franz <info@jonasfranz.software>
7 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
10 years ago
10 years ago
10 years ago
11 years ago
11 years ago
11 years ago
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
8 years ago
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
8 years ago
11 years ago
11 years ago
11 years ago
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 <info@jonasfranz.software> (cherry picked from commit 2b4daab) Signed-off-by: Jonas Franz <info@jonasfranz.software> * Replace ReviewComment with Content Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add load functions Add ReviewID to findComments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add create review comment implementation Add migration for review Other small changes Signed-off-by: Jonas Franz <info@jonasfranz.software> * Simplified create and find functions for review Signed-off-by: Jonas Franz <info@jonasfranz.software> * Moved "Pending" to first position Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add GetCurrentReview to simplify fetching current review Signed-off-by: Jonas Franz <info@jonasfranz.software> * Preview for listing comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Move new comment form to its own file Signed-off-by: Jonas Franz <info@jonasfranz.software> * Implement Review form Show Review comments on comment stream Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for single comments Showing buttons in context Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add pending tag to pending review comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add unit tests for Review Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fetch all review ids at once Add unit tests Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Improved comment rendering in "Files" view by adding Comments to DiffLine Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for invalidating comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Switched back to code.gitea.io/git Signed-off-by: Jonas Franz <info@jonasfranz.software> * Moved review migration from v64 to v65 Signed-off-by: Jonas Franz <info@jonasfranz.software> * Rebuild css Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Improve translations Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix unit tests by updating fixtures and updating outdated test Signed-off-by: Jonas Franz <info@jonasfranz.software> * Comments will be shown at the right place now Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for deleting CodeComments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix problems caused by files in subdirectories Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for showing code comments of reviews in conversation Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for "Show/Hide outdated" Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update code.gitea.io/git Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for new webhooks Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update comparison Signed-off-by: Jonas Franz <info@jonasfranz.software> * Resolve conflicts Signed-off-by: Jonas Franz <info@jonasfranz.software> * 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 <info@jonasfranz.software> * Prepare solving conflicts Signed-off-by: Jonas Franz <info@jonasfranz.software> * Show add button only if no comments already exist for the line Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add missing vendor files Signed-off-by: Jonas Franz <info@jonasfranz.software> * Check if reviewer is nil Signed-off-by: Jonas Franz <info@jonasfranz.software> * Show forms only to users who are logged in Signed-off-by: Jonas Franz <info@jonasfranz.software> * Revert "Show forms only to users who are logged in" This reverts commit c083682 Signed-off-by: Jonas Franz <info@jonasfranz.software> * Save patch in comment Render patch for code comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add link to comment in code Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add reply form to comment list Show forms only to signed in users Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add 'Reply' as translatable Add CODE_COMMENT_LINES setting Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix problems introduced by checking for singed in user Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add v70 Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update generated stylesheet Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix preview Beginn with new review comment patch system Signed-off-by: Jonas Franz <info@jonasfranz.software> * 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 <info@jonasfranz.software> * fmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Regenerated CSS with latest less version Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix test by updating comment type to new ID Signed-off-by: Jonas Franz <info@jonasfranz.software> * Introducing CodeComments as type for map[string]map[int64][]*Comment Other minor code improvements Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix data-tab issues Signed-off-by: Jonas Franz <info@jonasfranz.software> * Remove unnecessary change Signed-off-by: Jonas Franz <info@jonasfranz.software> * refactored checkForInvalidation Signed-off-by: Jonas Franz <info@jonasfranz.software> * Append comments instead of setting Signed-off-by: Jonas Franz <info@jonasfranz.software> * Use HeadRepo instead of BaseRepo Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update migration Signed-off-by: Jonas Franz <info@jonasfranz.de> * Regenerated CSS Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add copyright Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update index.css Signed-off-by: Jonas Franz <info@jonasfranz.software>
6 years ago
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 <info@jonasfranz.software> (cherry picked from commit 2b4daab) Signed-off-by: Jonas Franz <info@jonasfranz.software> * Replace ReviewComment with Content Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add load functions Add ReviewID to findComments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add create review comment implementation Add migration for review Other small changes Signed-off-by: Jonas Franz <info@jonasfranz.software> * Simplified create and find functions for review Signed-off-by: Jonas Franz <info@jonasfranz.software> * Moved "Pending" to first position Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add GetCurrentReview to simplify fetching current review Signed-off-by: Jonas Franz <info@jonasfranz.software> * Preview for listing comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Move new comment form to its own file Signed-off-by: Jonas Franz <info@jonasfranz.software> * Implement Review form Show Review comments on comment stream Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for single comments Showing buttons in context Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add pending tag to pending review comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add unit tests for Review Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fetch all review ids at once Add unit tests Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Improved comment rendering in "Files" view by adding Comments to DiffLine Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for invalidating comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Switched back to code.gitea.io/git Signed-off-by: Jonas Franz <info@jonasfranz.software> * Moved review migration from v64 to v65 Signed-off-by: Jonas Franz <info@jonasfranz.software> * Rebuild css Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Improve translations Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix unit tests by updating fixtures and updating outdated test Signed-off-by: Jonas Franz <info@jonasfranz.software> * Comments will be shown at the right place now Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for deleting CodeComments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix problems caused by files in subdirectories Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for showing code comments of reviews in conversation Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for "Show/Hide outdated" Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update code.gitea.io/git Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for new webhooks Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update comparison Signed-off-by: Jonas Franz <info@jonasfranz.software> * Resolve conflicts Signed-off-by: Jonas Franz <info@jonasfranz.software> * 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 <info@jonasfranz.software> * Prepare solving conflicts Signed-off-by: Jonas Franz <info@jonasfranz.software> * Show add button only if no comments already exist for the line Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add missing vendor files Signed-off-by: Jonas Franz <info@jonasfranz.software> * Check if reviewer is nil Signed-off-by: Jonas Franz <info@jonasfranz.software> * Show forms only to users who are logged in Signed-off-by: Jonas Franz <info@jonasfranz.software> * Revert "Show forms only to users who are logged in" This reverts commit c083682 Signed-off-by: Jonas Franz <info@jonasfranz.software> * Save patch in comment Render patch for code comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add link to comment in code Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add reply form to comment list Show forms only to signed in users Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add 'Reply' as translatable Add CODE_COMMENT_LINES setting Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix problems introduced by checking for singed in user Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add v70 Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update generated stylesheet Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix preview Beginn with new review comment patch system Signed-off-by: Jonas Franz <info@jonasfranz.software> * 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 <info@jonasfranz.software> * fmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Regenerated CSS with latest less version Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix test by updating comment type to new ID Signed-off-by: Jonas Franz <info@jonasfranz.software> * Introducing CodeComments as type for map[string]map[int64][]*Comment Other minor code improvements Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix data-tab issues Signed-off-by: Jonas Franz <info@jonasfranz.software> * Remove unnecessary change Signed-off-by: Jonas Franz <info@jonasfranz.software> * refactored checkForInvalidation Signed-off-by: Jonas Franz <info@jonasfranz.software> * Append comments instead of setting Signed-off-by: Jonas Franz <info@jonasfranz.software> * Use HeadRepo instead of BaseRepo Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update migration Signed-off-by: Jonas Franz <info@jonasfranz.de> * Regenerated CSS Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add copyright Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update index.css Signed-off-by: Jonas Franz <info@jonasfranz.software>
6 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
9 years ago
11 years ago
9 years ago
11 years ago
11 years ago
11 years ago
9 years ago
11 years ago
11 years ago
9 years ago
9 years ago
10 years ago
11 years ago
10 years ago
11 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
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
8 years ago
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
8 years ago
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
8 years ago
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
8 years ago
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
8 years ago
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
8 years ago
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
8 years ago
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
8 years ago
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
8 years ago
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
8 years ago
10 years ago
10 years ago
10 years ago
11 years ago
11 years ago
10 years ago
10 years ago
11 years ago
Squashed commit of the following: commit 0afcb843d7ffd596991c4885cab768273a6eb42c Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 17:13:29 2016 -0600 Removed Upload stats as the upload table is just a temporary table commit 7ecd73ff5535612d79d471409173ee7f1fcfa157 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 08:42:41 2016 -0600 Fix for CodeMirror mode commit c29b9ab531e2e7af0fb5db24dc17e51027dd1174 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 08:03:33 2016 -0600 Made tabbing in editor use spaces commit 23af384c53206a8a40e11e45bf49d7a149c4adcd Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:56:46 2016 -0600 Fix for data-url commit cfb8a97591cb6fc0a92e49563b7b764c524db0e9 Merge: 7fc8a89 991ce42 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:42:53 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go public/js/gogs.js commit 7fc8a89cb495478225b02d613e647f99a1489634 Merge: fd3d86c c03d040 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:40:00 2016 -0600 Merge branch 'feature-create-and-edit-repo-file' of github.com:richmahn/gogs into feature-create-and-edit-repo-file commit fd3d86ca6bbc02cfda566a504ffd6b03db4f75ef Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:39:44 2016 -0600 Code cleanup commit c03d0401c1049eeeccc32ab1f9c3303c130be5ee Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 29 15:38:23 2016 -0600 Code cleanup commit 98e1206ccf9f9a4503c020e3a7830cf9f861dfae Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Thu Jul 28 18:36:01 2016 -0600 Code cleanup and fixes commit c2895dc742f25f8412879c9fa15e18f27f42f194 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Thu Jul 28 18:24:04 2016 -0600 Fixes per Unknwon's requests commit 6aa7e46b21ad4c96e562daa2eac26a8fb408f8ef Merge: 889e9fa ad7ea88 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Thu Jul 28 17:13:43 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go modules/setting/setting.go commit 889e9faf1bd8559a4979c8f46005d488c1a234d4 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 22 14:09:18 2016 -0600 Fix in gogs.js commit 47603edf223f147b114be65f3bd27bc1e88827a5 Merge: bb57912 cf85e9e Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 22 14:07:36 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go public/js/gogs.js commit bb5791255867a71c11a77b639db050ad09c597a4 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 22 14:02:18 2016 -0600 Update for using CodeMirror mode addon commit d10d128c51039be19e2af9c66c63db66a9f2ec6d Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Tue Jul 19 16:12:57 2016 -0600 Update for Edit commit 34a34982025144e3225e389f7849eb6273c1d576 Merge: fa1b752 1c7dcdd Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Tue Jul 19 11:52:02 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go commit fa1b752be29cd455c5184ddac2ffe80b3489763e Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 15 18:35:42 2016 -0600 Feature for editing, creating, uploading and deleting files
8 years ago
10 years ago
10 years ago
Add support for federated avatars (#3320) * Add support for federated avatars Fixes #3105 Removes avatar fetching duplication code Adds an "Enable Federated Avatar" checkbox in user settings (defaults to unchecked) Moves avatar settings all in the same form, making local and remote avatars mutually exclusive Renames UploadAvatarForm to AvatarForm as it's not anymore only for uploading * Run gofmt on all modified files * Move Avatar form in its own page * Add go-libravatar dependency to vendor/ dir Hopefully helps with accepting the contribution. See also #3214 * Revert "Add go-libravatar dependency to vendor/ dir" This reverts commit a8cb93ae640bbb90f7d25012fc257bda9fae9b82. * Make federated avatar setting a global configuration Removes the per-user setting * Move avatar handling back to base tool, disable federated avatar in offline mode * Format, handle error * Properly set fallback host * Use unsupported github.com mirror for importing go-libravatar * Remove comment showing life exists outside of github.com ... pity, but contribution would not be accepted otherwise * Use Combo for Get and Post methods over /avatar * FEDERATED_AVATAR -> ENABLE_FEDERATED_AVATAR * Fix persistance of federated avatar lookup checkbox at install time * Federated Avatars -> Enable Federated Avatars * Use len(string) == 0 instead of string == "" * Move import line where it belong See https://github.com/Unknwon/go-code-convention/blob/master/en-US/import_packages.md Pity the import url is still the unofficial one, but oh well... * Save a line (and waste much more expensive time) * Remove redundant parens * Remove an empty line * Remove empty lines * Reorder lines to make diff smaller * Remove another newline Unknwon review got me start a fight against newlines * Move DISABLE_GRAVATAR and ENABLE_FEDERATED_AVATAR after OFFLINE_MODE On re-reading the diff I figured what Unknwon meant here: https://github.com/gogits/gogs/pull/3320/files#r73741106 * Remove newlines that weren't there before my intervention
8 years ago
Add support for federated avatars (#3320) * Add support for federated avatars Fixes #3105 Removes avatar fetching duplication code Adds an "Enable Federated Avatar" checkbox in user settings (defaults to unchecked) Moves avatar settings all in the same form, making local and remote avatars mutually exclusive Renames UploadAvatarForm to AvatarForm as it's not anymore only for uploading * Run gofmt on all modified files * Move Avatar form in its own page * Add go-libravatar dependency to vendor/ dir Hopefully helps with accepting the contribution. See also #3214 * Revert "Add go-libravatar dependency to vendor/ dir" This reverts commit a8cb93ae640bbb90f7d25012fc257bda9fae9b82. * Make federated avatar setting a global configuration Removes the per-user setting * Move avatar handling back to base tool, disable federated avatar in offline mode * Format, handle error * Properly set fallback host * Use unsupported github.com mirror for importing go-libravatar * Remove comment showing life exists outside of github.com ... pity, but contribution would not be accepted otherwise * Use Combo for Get and Post methods over /avatar * FEDERATED_AVATAR -> ENABLE_FEDERATED_AVATAR * Fix persistance of federated avatar lookup checkbox at install time * Federated Avatars -> Enable Federated Avatars * Use len(string) == 0 instead of string == "" * Move import line where it belong See https://github.com/Unknwon/go-code-convention/blob/master/en-US/import_packages.md Pity the import url is still the unofficial one, but oh well... * Save a line (and waste much more expensive time) * Remove redundant parens * Remove an empty line * Remove empty lines * Reorder lines to make diff smaller * Remove another newline Unknwon review got me start a fight against newlines * Move DISABLE_GRAVATAR and ENABLE_FEDERATED_AVATAR after OFFLINE_MODE On re-reading the diff I figured what Unknwon meant here: https://github.com/gogits/gogs/pull/3320/files#r73741106 * Remove newlines that weren't there before my intervention
8 years ago
Add support for federated avatars (#3320) * Add support for federated avatars Fixes #3105 Removes avatar fetching duplication code Adds an "Enable Federated Avatar" checkbox in user settings (defaults to unchecked) Moves avatar settings all in the same form, making local and remote avatars mutually exclusive Renames UploadAvatarForm to AvatarForm as it's not anymore only for uploading * Run gofmt on all modified files * Move Avatar form in its own page * Add go-libravatar dependency to vendor/ dir Hopefully helps with accepting the contribution. See also #3214 * Revert "Add go-libravatar dependency to vendor/ dir" This reverts commit a8cb93ae640bbb90f7d25012fc257bda9fae9b82. * Make federated avatar setting a global configuration Removes the per-user setting * Move avatar handling back to base tool, disable federated avatar in offline mode * Format, handle error * Properly set fallback host * Use unsupported github.com mirror for importing go-libravatar * Remove comment showing life exists outside of github.com ... pity, but contribution would not be accepted otherwise * Use Combo for Get and Post methods over /avatar * FEDERATED_AVATAR -> ENABLE_FEDERATED_AVATAR * Fix persistance of federated avatar lookup checkbox at install time * Federated Avatars -> Enable Federated Avatars * Use len(string) == 0 instead of string == "" * Move import line where it belong See https://github.com/Unknwon/go-code-convention/blob/master/en-US/import_packages.md Pity the import url is still the unofficial one, but oh well... * Save a line (and waste much more expensive time) * Remove redundant parens * Remove an empty line * Remove empty lines * Reorder lines to make diff smaller * Remove another newline Unknwon review got me start a fight against newlines * Move DISABLE_GRAVATAR and ENABLE_FEDERATED_AVATAR after OFFLINE_MODE On re-reading the diff I figured what Unknwon meant here: https://github.com/gogits/gogs/pull/3320/files#r73741106 * Remove newlines that weren't there before my intervention
8 years ago
Add support for federated avatars (#3320) * Add support for federated avatars Fixes #3105 Removes avatar fetching duplication code Adds an "Enable Federated Avatar" checkbox in user settings (defaults to unchecked) Moves avatar settings all in the same form, making local and remote avatars mutually exclusive Renames UploadAvatarForm to AvatarForm as it's not anymore only for uploading * Run gofmt on all modified files * Move Avatar form in its own page * Add go-libravatar dependency to vendor/ dir Hopefully helps with accepting the contribution. See also #3214 * Revert "Add go-libravatar dependency to vendor/ dir" This reverts commit a8cb93ae640bbb90f7d25012fc257bda9fae9b82. * Make federated avatar setting a global configuration Removes the per-user setting * Move avatar handling back to base tool, disable federated avatar in offline mode * Format, handle error * Properly set fallback host * Use unsupported github.com mirror for importing go-libravatar * Remove comment showing life exists outside of github.com ... pity, but contribution would not be accepted otherwise * Use Combo for Get and Post methods over /avatar * FEDERATED_AVATAR -> ENABLE_FEDERATED_AVATAR * Fix persistance of federated avatar lookup checkbox at install time * Federated Avatars -> Enable Federated Avatars * Use len(string) == 0 instead of string == "" * Move import line where it belong See https://github.com/Unknwon/go-code-convention/blob/master/en-US/import_packages.md Pity the import url is still the unofficial one, but oh well... * Save a line (and waste much more expensive time) * Remove redundant parens * Remove an empty line * Remove empty lines * Reorder lines to make diff smaller * Remove another newline Unknwon review got me start a fight against newlines * Move DISABLE_GRAVATAR and ENABLE_FEDERATED_AVATAR after OFFLINE_MODE On re-reading the diff I figured what Unknwon meant here: https://github.com/gogits/gogs/pull/3320/files#r73741106 * Remove newlines that weren't there before my intervention
8 years ago
10 years ago
10 years ago
11 years ago
11 years ago
Feature: Timetracking (#2211) * Added comment's hashtag to url for mail notifications. * Added explanation to return statement + documentation. * Replacing in-line link generation with HTMLURL. (+gofmt) * Replaced action-based model with nil-based model. (+gofmt) * Replaced mailIssueActionToParticipants with mailIssueCommentToParticipants. * Updating comment for mailIssueCommentToParticipants * Added link to comment in "Dashboard" * Deleting feed entry if a comment is going to be deleted * Added migration * Added improved migration to add a CommentID column to action. * Added improved links to comments in feed entries. * Fixes #1956 by filtering for deleted comments that are referenced in actions. * Introducing "IsDeleted" column to action. * Adding design draft (not functional) * Adding database models for stopwatches and trackedtimes * See go-gitea/gitea#967 * Adding design draft (not functional) * Adding translations and improving design * Implementing stopwatch (for timetracking) * Make UI functional * Add hints in timeline for time tracking events * Implementing timetracking feature * Adding "Add time manual" option * Improved stopwatch * Created report of total spent time by user * Only showing total time spent if theire is something to show. * Adding license headers. * Improved error handling for "Add Time Manual" * Adding @sapks 's changes, refactoring * Adding API for feature tracking * Adding unit test * Adding DISABLE/ENABLE option to Repository settings page * Improving translations * Applying @sapk 's changes * Removing repo_unit and using IssuesSetting for disabling/enabling timetracker * Adding DEFAULT_ENABLE_TIMETRACKER to config, installation and admin menu * Improving documentation * Fixing vendor/ folder * Changing timtracking routes by adding subgroups /times and /times/stopwatch (Proposed by @lafriks ) * Restricting write access to timetracking based on the repo settings (Proposed by @lafriks ) * Fixed minor permissions bug. * Adding CanUseTimetracker and IsTimetrackerEnabled in ctx.Repo * Allow assignees and authors to track there time too. * Fixed some build-time-errors + logical errors. * Removing unused Get...ByID functions * Moving IsTimetrackerEnabled from context.Repository to models.Repository * Adding a seperate file for issue related repo functions * Adding license headers * Fixed GetUserByParams return 404 * Moving /users/:username/times to /repos/:username/:reponame/times/:username for security reasons * Adding /repos/:username/times to get all tracked times of the repo * Updating sdk-dependency * Updating swagger.v1.json * Adding warning if user has already a running stopwatch (auto-timetracker) * Replacing GetTrackedTimesBy... with GetTrackedTimes(options FindTrackedTimesOptions) * Changing code.gitea.io/sdk back to code.gitea.io/sdk * Correcting spelling mistake * Updating vendor.json * Changing GET stopwatch/toggle to POST stopwatch/toggle * Changing GET stopwatch/cancel to POST stopwatch/cancel * Added migration for stopwatches/timetracking * Fixed some access bugs for read-only users * Added default allow only contributors to track time value to config * Fixed migration by chaging x.Iterate to x.Find * Resorted imports * Moved Add Time Manually form to repo_form.go * Removed "Seconds" field from Add Time Manually * Resorted imports * Improved permission checking * Fixed some bugs * Added integration test * gofmt * Adding integration test by @lafriks * Added created_unix to comment fixtures * Using last event instead of a fixed event * Adding another integration test by @lafriks * Fixing bug Timetracker enabled causing error 500 at sidebar.tpl * Fixed a refactoring bug that resulted in hiding "HasUserStopwatch" warning. * Returning TrackedTime instead of AddTimeOption at AddTime. * Updating SDK from go-gitea/go-sdk#69 * Resetting Go-SDK back to default repository * Fixing test-vendor by changing ini back to original repository * Adding "tags" to swagger spec * govendor sync * Removed duplicate * Formatting templates * Adding IsTimetrackingEnabled checks to API * Improving translations / english texts * Improving documentation * Updating swagger spec * Fixing integration test caused be translation-changes * Removed encoding issues in local_en-US.ini. * "Added" copyright line * Moved unit.IssuesConfig().EnableTimetracker into a != nil check * Removed some other encoding issues in local_en-US.ini * Improved javascript by checking if data-context exists * Replaced manual comment creation with CreateComment * Removed unnecessary code * Improved error checking * Small cosmetic changes * Replaced int>string>duration parsing with int>duration parsing * Fixed encoding issues * Removed unused imports Signed-off-by: Jonas Franz <info@jonasfranz.software>
7 years ago
Feature: Timetracking (#2211) * Added comment's hashtag to url for mail notifications. * Added explanation to return statement + documentation. * Replacing in-line link generation with HTMLURL. (+gofmt) * Replaced action-based model with nil-based model. (+gofmt) * Replaced mailIssueActionToParticipants with mailIssueCommentToParticipants. * Updating comment for mailIssueCommentToParticipants * Added link to comment in "Dashboard" * Deleting feed entry if a comment is going to be deleted * Added migration * Added improved migration to add a CommentID column to action. * Added improved links to comments in feed entries. * Fixes #1956 by filtering for deleted comments that are referenced in actions. * Introducing "IsDeleted" column to action. * Adding design draft (not functional) * Adding database models for stopwatches and trackedtimes * See go-gitea/gitea#967 * Adding design draft (not functional) * Adding translations and improving design * Implementing stopwatch (for timetracking) * Make UI functional * Add hints in timeline for time tracking events * Implementing timetracking feature * Adding "Add time manual" option * Improved stopwatch * Created report of total spent time by user * Only showing total time spent if theire is something to show. * Adding license headers. * Improved error handling for "Add Time Manual" * Adding @sapks 's changes, refactoring * Adding API for feature tracking * Adding unit test * Adding DISABLE/ENABLE option to Repository settings page * Improving translations * Applying @sapk 's changes * Removing repo_unit and using IssuesSetting for disabling/enabling timetracker * Adding DEFAULT_ENABLE_TIMETRACKER to config, installation and admin menu * Improving documentation * Fixing vendor/ folder * Changing timtracking routes by adding subgroups /times and /times/stopwatch (Proposed by @lafriks ) * Restricting write access to timetracking based on the repo settings (Proposed by @lafriks ) * Fixed minor permissions bug. * Adding CanUseTimetracker and IsTimetrackerEnabled in ctx.Repo * Allow assignees and authors to track there time too. * Fixed some build-time-errors + logical errors. * Removing unused Get...ByID functions * Moving IsTimetrackerEnabled from context.Repository to models.Repository * Adding a seperate file for issue related repo functions * Adding license headers * Fixed GetUserByParams return 404 * Moving /users/:username/times to /repos/:username/:reponame/times/:username for security reasons * Adding /repos/:username/times to get all tracked times of the repo * Updating sdk-dependency * Updating swagger.v1.json * Adding warning if user has already a running stopwatch (auto-timetracker) * Replacing GetTrackedTimesBy... with GetTrackedTimes(options FindTrackedTimesOptions) * Changing code.gitea.io/sdk back to code.gitea.io/sdk * Correcting spelling mistake * Updating vendor.json * Changing GET stopwatch/toggle to POST stopwatch/toggle * Changing GET stopwatch/cancel to POST stopwatch/cancel * Added migration for stopwatches/timetracking * Fixed some access bugs for read-only users * Added default allow only contributors to track time value to config * Fixed migration by chaging x.Iterate to x.Find * Resorted imports * Moved Add Time Manually form to repo_form.go * Removed "Seconds" field from Add Time Manually * Resorted imports * Improved permission checking * Fixed some bugs * Added integration test * gofmt * Adding integration test by @lafriks * Added created_unix to comment fixtures * Using last event instead of a fixed event * Adding another integration test by @lafriks * Fixing bug Timetracker enabled causing error 500 at sidebar.tpl * Fixed a refactoring bug that resulted in hiding "HasUserStopwatch" warning. * Returning TrackedTime instead of AddTimeOption at AddTime. * Updating SDK from go-gitea/go-sdk#69 * Resetting Go-SDK back to default repository * Fixing test-vendor by changing ini back to original repository * Adding "tags" to swagger spec * govendor sync * Removed duplicate * Formatting templates * Adding IsTimetrackingEnabled checks to API * Improving translations / english texts * Improving documentation * Updating swagger spec * Fixing integration test caused be translation-changes * Removed encoding issues in local_en-US.ini. * "Added" copyright line * Moved unit.IssuesConfig().EnableTimetracker into a != nil check * Removed some other encoding issues in local_en-US.ini * Improved javascript by checking if data-context exists * Replaced manual comment creation with CreateComment * Removed unnecessary code * Improved error checking * Small cosmetic changes * Replaced int>string>duration parsing with int>duration parsing * Fixed encoding issues * Removed unused imports Signed-off-by: Jonas Franz <info@jonasfranz.software>
7 years ago
Feature: Timetracking (#2211) * Added comment's hashtag to url for mail notifications. * Added explanation to return statement + documentation. * Replacing in-line link generation with HTMLURL. (+gofmt) * Replaced action-based model with nil-based model. (+gofmt) * Replaced mailIssueActionToParticipants with mailIssueCommentToParticipants. * Updating comment for mailIssueCommentToParticipants * Added link to comment in "Dashboard" * Deleting feed entry if a comment is going to be deleted * Added migration * Added improved migration to add a CommentID column to action. * Added improved links to comments in feed entries. * Fixes #1956 by filtering for deleted comments that are referenced in actions. * Introducing "IsDeleted" column to action. * Adding design draft (not functional) * Adding database models for stopwatches and trackedtimes * See go-gitea/gitea#967 * Adding design draft (not functional) * Adding translations and improving design * Implementing stopwatch (for timetracking) * Make UI functional * Add hints in timeline for time tracking events * Implementing timetracking feature * Adding "Add time manual" option * Improved stopwatch * Created report of total spent time by user * Only showing total time spent if theire is something to show. * Adding license headers. * Improved error handling for "Add Time Manual" * Adding @sapks 's changes, refactoring * Adding API for feature tracking * Adding unit test * Adding DISABLE/ENABLE option to Repository settings page * Improving translations * Applying @sapk 's changes * Removing repo_unit and using IssuesSetting for disabling/enabling timetracker * Adding DEFAULT_ENABLE_TIMETRACKER to config, installation and admin menu * Improving documentation * Fixing vendor/ folder * Changing timtracking routes by adding subgroups /times and /times/stopwatch (Proposed by @lafriks ) * Restricting write access to timetracking based on the repo settings (Proposed by @lafriks ) * Fixed minor permissions bug. * Adding CanUseTimetracker and IsTimetrackerEnabled in ctx.Repo * Allow assignees and authors to track there time too. * Fixed some build-time-errors + logical errors. * Removing unused Get...ByID functions * Moving IsTimetrackerEnabled from context.Repository to models.Repository * Adding a seperate file for issue related repo functions * Adding license headers * Fixed GetUserByParams return 404 * Moving /users/:username/times to /repos/:username/:reponame/times/:username for security reasons * Adding /repos/:username/times to get all tracked times of the repo * Updating sdk-dependency * Updating swagger.v1.json * Adding warning if user has already a running stopwatch (auto-timetracker) * Replacing GetTrackedTimesBy... with GetTrackedTimes(options FindTrackedTimesOptions) * Changing code.gitea.io/sdk back to code.gitea.io/sdk * Correcting spelling mistake * Updating vendor.json * Changing GET stopwatch/toggle to POST stopwatch/toggle * Changing GET stopwatch/cancel to POST stopwatch/cancel * Added migration for stopwatches/timetracking * Fixed some access bugs for read-only users * Added default allow only contributors to track time value to config * Fixed migration by chaging x.Iterate to x.Find * Resorted imports * Moved Add Time Manually form to repo_form.go * Removed "Seconds" field from Add Time Manually * Resorted imports * Improved permission checking * Fixed some bugs * Added integration test * gofmt * Adding integration test by @lafriks * Added created_unix to comment fixtures * Using last event instead of a fixed event * Adding another integration test by @lafriks * Fixing bug Timetracker enabled causing error 500 at sidebar.tpl * Fixed a refactoring bug that resulted in hiding "HasUserStopwatch" warning. * Returning TrackedTime instead of AddTimeOption at AddTime. * Updating SDK from go-gitea/go-sdk#69 * Resetting Go-SDK back to default repository * Fixing test-vendor by changing ini back to original repository * Adding "tags" to swagger spec * govendor sync * Removed duplicate * Formatting templates * Adding IsTimetrackingEnabled checks to API * Improving translations / english texts * Improving documentation * Updating swagger spec * Fixing integration test caused be translation-changes * Removed encoding issues in local_en-US.ini. * "Added" copyright line * Moved unit.IssuesConfig().EnableTimetracker into a != nil check * Removed some other encoding issues in local_en-US.ini * Improved javascript by checking if data-context exists * Replaced manual comment creation with CreateComment * Removed unnecessary code * Improved error checking * Small cosmetic changes * Replaced int>string>duration parsing with int>duration parsing * Fixed encoding issues * Removed unused imports Signed-off-by: Jonas Franz <info@jonasfranz.software>
7 years ago
Feature: Timetracking (#2211) * Added comment's hashtag to url for mail notifications. * Added explanation to return statement + documentation. * Replacing in-line link generation with HTMLURL. (+gofmt) * Replaced action-based model with nil-based model. (+gofmt) * Replaced mailIssueActionToParticipants with mailIssueCommentToParticipants. * Updating comment for mailIssueCommentToParticipants * Added link to comment in "Dashboard" * Deleting feed entry if a comment is going to be deleted * Added migration * Added improved migration to add a CommentID column to action. * Added improved links to comments in feed entries. * Fixes #1956 by filtering for deleted comments that are referenced in actions. * Introducing "IsDeleted" column to action. * Adding design draft (not functional) * Adding database models for stopwatches and trackedtimes * See go-gitea/gitea#967 * Adding design draft (not functional) * Adding translations and improving design * Implementing stopwatch (for timetracking) * Make UI functional * Add hints in timeline for time tracking events * Implementing timetracking feature * Adding "Add time manual" option * Improved stopwatch * Created report of total spent time by user * Only showing total time spent if theire is something to show. * Adding license headers. * Improved error handling for "Add Time Manual" * Adding @sapks 's changes, refactoring * Adding API for feature tracking * Adding unit test * Adding DISABLE/ENABLE option to Repository settings page * Improving translations * Applying @sapk 's changes * Removing repo_unit and using IssuesSetting for disabling/enabling timetracker * Adding DEFAULT_ENABLE_TIMETRACKER to config, installation and admin menu * Improving documentation * Fixing vendor/ folder * Changing timtracking routes by adding subgroups /times and /times/stopwatch (Proposed by @lafriks ) * Restricting write access to timetracking based on the repo settings (Proposed by @lafriks ) * Fixed minor permissions bug. * Adding CanUseTimetracker and IsTimetrackerEnabled in ctx.Repo * Allow assignees and authors to track there time too. * Fixed some build-time-errors + logical errors. * Removing unused Get...ByID functions * Moving IsTimetrackerEnabled from context.Repository to models.Repository * Adding a seperate file for issue related repo functions * Adding license headers * Fixed GetUserByParams return 404 * Moving /users/:username/times to /repos/:username/:reponame/times/:username for security reasons * Adding /repos/:username/times to get all tracked times of the repo * Updating sdk-dependency * Updating swagger.v1.json * Adding warning if user has already a running stopwatch (auto-timetracker) * Replacing GetTrackedTimesBy... with GetTrackedTimes(options FindTrackedTimesOptions) * Changing code.gitea.io/sdk back to code.gitea.io/sdk * Correcting spelling mistake * Updating vendor.json * Changing GET stopwatch/toggle to POST stopwatch/toggle * Changing GET stopwatch/cancel to POST stopwatch/cancel * Added migration for stopwatches/timetracking * Fixed some access bugs for read-only users * Added default allow only contributors to track time value to config * Fixed migration by chaging x.Iterate to x.Find * Resorted imports * Moved Add Time Manually form to repo_form.go * Removed "Seconds" field from Add Time Manually * Resorted imports * Improved permission checking * Fixed some bugs * Added integration test * gofmt * Adding integration test by @lafriks * Added created_unix to comment fixtures * Using last event instead of a fixed event * Adding another integration test by @lafriks * Fixing bug Timetracker enabled causing error 500 at sidebar.tpl * Fixed a refactoring bug that resulted in hiding "HasUserStopwatch" warning. * Returning TrackedTime instead of AddTimeOption at AddTime. * Updating SDK from go-gitea/go-sdk#69 * Resetting Go-SDK back to default repository * Fixing test-vendor by changing ini back to original repository * Adding "tags" to swagger spec * govendor sync * Removed duplicate * Formatting templates * Adding IsTimetrackingEnabled checks to API * Improving translations / english texts * Improving documentation * Updating swagger spec * Fixing integration test caused be translation-changes * Removed encoding issues in local_en-US.ini. * "Added" copyright line * Moved unit.IssuesConfig().EnableTimetracker into a != nil check * Removed some other encoding issues in local_en-US.ini * Improved javascript by checking if data-context exists * Replaced manual comment creation with CreateComment * Removed unnecessary code * Improved error checking * Small cosmetic changes * Replaced int>string>duration parsing with int>duration parsing * Fixed encoding issues * Removed unused imports Signed-off-by: Jonas Franz <info@jonasfranz.software>
7 years ago
Feature: Timetracking (#2211) * Added comment's hashtag to url for mail notifications. * Added explanation to return statement + documentation. * Replacing in-line link generation with HTMLURL. (+gofmt) * Replaced action-based model with nil-based model. (+gofmt) * Replaced mailIssueActionToParticipants with mailIssueCommentToParticipants. * Updating comment for mailIssueCommentToParticipants * Added link to comment in "Dashboard" * Deleting feed entry if a comment is going to be deleted * Added migration * Added improved migration to add a CommentID column to action. * Added improved links to comments in feed entries. * Fixes #1956 by filtering for deleted comments that are referenced in actions. * Introducing "IsDeleted" column to action. * Adding design draft (not functional) * Adding database models for stopwatches and trackedtimes * See go-gitea/gitea#967 * Adding design draft (not functional) * Adding translations and improving design * Implementing stopwatch (for timetracking) * Make UI functional * Add hints in timeline for time tracking events * Implementing timetracking feature * Adding "Add time manual" option * Improved stopwatch * Created report of total spent time by user * Only showing total time spent if theire is something to show. * Adding license headers. * Improved error handling for "Add Time Manual" * Adding @sapks 's changes, refactoring * Adding API for feature tracking * Adding unit test * Adding DISABLE/ENABLE option to Repository settings page * Improving translations * Applying @sapk 's changes * Removing repo_unit and using IssuesSetting for disabling/enabling timetracker * Adding DEFAULT_ENABLE_TIMETRACKER to config, installation and admin menu * Improving documentation * Fixing vendor/ folder * Changing timtracking routes by adding subgroups /times and /times/stopwatch (Proposed by @lafriks ) * Restricting write access to timetracking based on the repo settings (Proposed by @lafriks ) * Fixed minor permissions bug. * Adding CanUseTimetracker and IsTimetrackerEnabled in ctx.Repo * Allow assignees and authors to track there time too. * Fixed some build-time-errors + logical errors. * Removing unused Get...ByID functions * Moving IsTimetrackerEnabled from context.Repository to models.Repository * Adding a seperate file for issue related repo functions * Adding license headers * Fixed GetUserByParams return 404 * Moving /users/:username/times to /repos/:username/:reponame/times/:username for security reasons * Adding /repos/:username/times to get all tracked times of the repo * Updating sdk-dependency * Updating swagger.v1.json * Adding warning if user has already a running stopwatch (auto-timetracker) * Replacing GetTrackedTimesBy... with GetTrackedTimes(options FindTrackedTimesOptions) * Changing code.gitea.io/sdk back to code.gitea.io/sdk * Correcting spelling mistake * Updating vendor.json * Changing GET stopwatch/toggle to POST stopwatch/toggle * Changing GET stopwatch/cancel to POST stopwatch/cancel * Added migration for stopwatches/timetracking * Fixed some access bugs for read-only users * Added default allow only contributors to track time value to config * Fixed migration by chaging x.Iterate to x.Find * Resorted imports * Moved Add Time Manually form to repo_form.go * Removed "Seconds" field from Add Time Manually * Resorted imports * Improved permission checking * Fixed some bugs * Added integration test * gofmt * Adding integration test by @lafriks * Added created_unix to comment fixtures * Using last event instead of a fixed event * Adding another integration test by @lafriks * Fixing bug Timetracker enabled causing error 500 at sidebar.tpl * Fixed a refactoring bug that resulted in hiding "HasUserStopwatch" warning. * Returning TrackedTime instead of AddTimeOption at AddTime. * Updating SDK from go-gitea/go-sdk#69 * Resetting Go-SDK back to default repository * Fixing test-vendor by changing ini back to original repository * Adding "tags" to swagger spec * govendor sync * Removed duplicate * Formatting templates * Adding IsTimetrackingEnabled checks to API * Improving translations / english texts * Improving documentation * Updating swagger spec * Fixing integration test caused be translation-changes * Removed encoding issues in local_en-US.ini. * "Added" copyright line * Moved unit.IssuesConfig().EnableTimetracker into a != nil check * Removed some other encoding issues in local_en-US.ini * Improved javascript by checking if data-context exists * Replaced manual comment creation with CreateComment * Removed unnecessary code * Improved error checking * Small cosmetic changes * Replaced int>string>duration parsing with int>duration parsing * Fixed encoding issues * Removed unused imports Signed-off-by: Jonas Franz <info@jonasfranz.software>
7 years ago
Feature: Timetracking (#2211) * Added comment's hashtag to url for mail notifications. * Added explanation to return statement + documentation. * Replacing in-line link generation with HTMLURL. (+gofmt) * Replaced action-based model with nil-based model. (+gofmt) * Replaced mailIssueActionToParticipants with mailIssueCommentToParticipants. * Updating comment for mailIssueCommentToParticipants * Added link to comment in "Dashboard" * Deleting feed entry if a comment is going to be deleted * Added migration * Added improved migration to add a CommentID column to action. * Added improved links to comments in feed entries. * Fixes #1956 by filtering for deleted comments that are referenced in actions. * Introducing "IsDeleted" column to action. * Adding design draft (not functional) * Adding database models for stopwatches and trackedtimes * See go-gitea/gitea#967 * Adding design draft (not functional) * Adding translations and improving design * Implementing stopwatch (for timetracking) * Make UI functional * Add hints in timeline for time tracking events * Implementing timetracking feature * Adding "Add time manual" option * Improved stopwatch * Created report of total spent time by user * Only showing total time spent if theire is something to show. * Adding license headers. * Improved error handling for "Add Time Manual" * Adding @sapks 's changes, refactoring * Adding API for feature tracking * Adding unit test * Adding DISABLE/ENABLE option to Repository settings page * Improving translations * Applying @sapk 's changes * Removing repo_unit and using IssuesSetting for disabling/enabling timetracker * Adding DEFAULT_ENABLE_TIMETRACKER to config, installation and admin menu * Improving documentation * Fixing vendor/ folder * Changing timtracking routes by adding subgroups /times and /times/stopwatch (Proposed by @lafriks ) * Restricting write access to timetracking based on the repo settings (Proposed by @lafriks ) * Fixed minor permissions bug. * Adding CanUseTimetracker and IsTimetrackerEnabled in ctx.Repo * Allow assignees and authors to track there time too. * Fixed some build-time-errors + logical errors. * Removing unused Get...ByID functions * Moving IsTimetrackerEnabled from context.Repository to models.Repository * Adding a seperate file for issue related repo functions * Adding license headers * Fixed GetUserByParams return 404 * Moving /users/:username/times to /repos/:username/:reponame/times/:username for security reasons * Adding /repos/:username/times to get all tracked times of the repo * Updating sdk-dependency * Updating swagger.v1.json * Adding warning if user has already a running stopwatch (auto-timetracker) * Replacing GetTrackedTimesBy... with GetTrackedTimes(options FindTrackedTimesOptions) * Changing code.gitea.io/sdk back to code.gitea.io/sdk * Correcting spelling mistake * Updating vendor.json * Changing GET stopwatch/toggle to POST stopwatch/toggle * Changing GET stopwatch/cancel to POST stopwatch/cancel * Added migration for stopwatches/timetracking * Fixed some access bugs for read-only users * Added default allow only contributors to track time value to config * Fixed migration by chaging x.Iterate to x.Find * Resorted imports * Moved Add Time Manually form to repo_form.go * Removed "Seconds" field from Add Time Manually * Resorted imports * Improved permission checking * Fixed some bugs * Added integration test * gofmt * Adding integration test by @lafriks * Added created_unix to comment fixtures * Using last event instead of a fixed event * Adding another integration test by @lafriks * Fixing bug Timetracker enabled causing error 500 at sidebar.tpl * Fixed a refactoring bug that resulted in hiding "HasUserStopwatch" warning. * Returning TrackedTime instead of AddTimeOption at AddTime. * Updating SDK from go-gitea/go-sdk#69 * Resetting Go-SDK back to default repository * Fixing test-vendor by changing ini back to original repository * Adding "tags" to swagger spec * govendor sync * Removed duplicate * Formatting templates * Adding IsTimetrackingEnabled checks to API * Improving translations / english texts * Improving documentation * Updating swagger spec * Fixing integration test caused be translation-changes * Removed encoding issues in local_en-US.ini. * "Added" copyright line * Moved unit.IssuesConfig().EnableTimetracker into a != nil check * Removed some other encoding issues in local_en-US.ini * Improved javascript by checking if data-context exists * Replaced manual comment creation with CreateComment * Removed unnecessary code * Improved error checking * Small cosmetic changes * Replaced int>string>duration parsing with int>duration parsing * Fixed encoding issues * Removed unused imports Signed-off-by: Jonas Franz <info@jonasfranz.software>
7 years ago
11 years ago
11 years ago
Feature: Timetracking (#2211) * Added comment's hashtag to url for mail notifications. * Added explanation to return statement + documentation. * Replacing in-line link generation with HTMLURL. (+gofmt) * Replaced action-based model with nil-based model. (+gofmt) * Replaced mailIssueActionToParticipants with mailIssueCommentToParticipants. * Updating comment for mailIssueCommentToParticipants * Added link to comment in "Dashboard" * Deleting feed entry if a comment is going to be deleted * Added migration * Added improved migration to add a CommentID column to action. * Added improved links to comments in feed entries. * Fixes #1956 by filtering for deleted comments that are referenced in actions. * Introducing "IsDeleted" column to action. * Adding design draft (not functional) * Adding database models for stopwatches and trackedtimes * See go-gitea/gitea#967 * Adding design draft (not functional) * Adding translations and improving design * Implementing stopwatch (for timetracking) * Make UI functional * Add hints in timeline for time tracking events * Implementing timetracking feature * Adding "Add time manual" option * Improved stopwatch * Created report of total spent time by user * Only showing total time spent if theire is something to show. * Adding license headers. * Improved error handling for "Add Time Manual" * Adding @sapks 's changes, refactoring * Adding API for feature tracking * Adding unit test * Adding DISABLE/ENABLE option to Repository settings page * Improving translations * Applying @sapk 's changes * Removing repo_unit and using IssuesSetting for disabling/enabling timetracker * Adding DEFAULT_ENABLE_TIMETRACKER to config, installation and admin menu * Improving documentation * Fixing vendor/ folder * Changing timtracking routes by adding subgroups /times and /times/stopwatch (Proposed by @lafriks ) * Restricting write access to timetracking based on the repo settings (Proposed by @lafriks ) * Fixed minor permissions bug. * Adding CanUseTimetracker and IsTimetrackerEnabled in ctx.Repo * Allow assignees and authors to track there time too. * Fixed some build-time-errors + logical errors. * Removing unused Get...ByID functions * Moving IsTimetrackerEnabled from context.Repository to models.Repository * Adding a seperate file for issue related repo functions * Adding license headers * Fixed GetUserByParams return 404 * Moving /users/:username/times to /repos/:username/:reponame/times/:username for security reasons * Adding /repos/:username/times to get all tracked times of the repo * Updating sdk-dependency * Updating swagger.v1.json * Adding warning if user has already a running stopwatch (auto-timetracker) * Replacing GetTrackedTimesBy... with GetTrackedTimes(options FindTrackedTimesOptions) * Changing code.gitea.io/sdk back to code.gitea.io/sdk * Correcting spelling mistake * Updating vendor.json * Changing GET stopwatch/toggle to POST stopwatch/toggle * Changing GET stopwatch/cancel to POST stopwatch/cancel * Added migration for stopwatches/timetracking * Fixed some access bugs for read-only users * Added default allow only contributors to track time value to config * Fixed migration by chaging x.Iterate to x.Find * Resorted imports * Moved Add Time Manually form to repo_form.go * Removed "Seconds" field from Add Time Manually * Resorted imports * Improved permission checking * Fixed some bugs * Added integration test * gofmt * Adding integration test by @lafriks * Added created_unix to comment fixtures * Using last event instead of a fixed event * Adding another integration test by @lafriks * Fixing bug Timetracker enabled causing error 500 at sidebar.tpl * Fixed a refactoring bug that resulted in hiding "HasUserStopwatch" warning. * Returning TrackedTime instead of AddTimeOption at AddTime. * Updating SDK from go-gitea/go-sdk#69 * Resetting Go-SDK back to default repository * Fixing test-vendor by changing ini back to original repository * Adding "tags" to swagger spec * govendor sync * Removed duplicate * Formatting templates * Adding IsTimetrackingEnabled checks to API * Improving translations / english texts * Improving documentation * Updating swagger spec * Fixing integration test caused be translation-changes * Removed encoding issues in local_en-US.ini. * "Added" copyright line * Moved unit.IssuesConfig().EnableTimetracker into a != nil check * Removed some other encoding issues in local_en-US.ini * Improved javascript by checking if data-context exists * Replaced manual comment creation with CreateComment * Removed unnecessary code * Improved error checking * Small cosmetic changes * Replaced int>string>duration parsing with int>duration parsing * Fixed encoding issues * Removed unused imports Signed-off-by: Jonas Franz <info@jonasfranz.software>
7 years ago
11 years ago
11 years ago
11 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
10 years ago
10 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
10 years ago
11 years ago
10 years ago
11 years ago
11 years ago
10 years ago
11 years ago
10 years ago
11 years ago
10 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624
  1. // Copyright 2014 The Gogs Authors. All rights reserved.
  2. // Copyright 2017 The Gitea Authors. All rights reserved.
  3. // Use of this source code is governed by a MIT-style
  4. // license that can be found in the LICENSE file.
  5. package setting
  6. import (
  7. "encoding/base64"
  8. "fmt"
  9. "net"
  10. "net/mail"
  11. "net/url"
  12. "os"
  13. "os/exec"
  14. "path"
  15. "path/filepath"
  16. "regexp"
  17. "runtime"
  18. "strconv"
  19. "strings"
  20. "time"
  21. "code.gitea.io/git"
  22. "code.gitea.io/gitea/modules/generate"
  23. "code.gitea.io/gitea/modules/log"
  24. _ "code.gitea.io/gitea/modules/minwinsvc" // import minwinsvc for windows services
  25. "code.gitea.io/gitea/modules/user"
  26. "github.com/Unknwon/com"
  27. _ "github.com/go-macaron/cache/memcache" // memcache plugin for cache
  28. _ "github.com/go-macaron/cache/redis"
  29. "github.com/go-macaron/session"
  30. _ "github.com/go-macaron/session/redis" // redis plugin for store session
  31. "github.com/go-xorm/core"
  32. "github.com/kballard/go-shellquote"
  33. "github.com/mcuadros/go-version"
  34. "gopkg.in/ini.v1"
  35. "strk.kbt.io/projects/go/libravatar"
  36. )
  37. // Scheme describes protocol types
  38. type Scheme string
  39. // enumerates all the scheme types
  40. const (
  41. HTTP Scheme = "http"
  42. HTTPS Scheme = "https"
  43. FCGI Scheme = "fcgi"
  44. UnixSocket Scheme = "unix"
  45. )
  46. // LandingPage describes the default page
  47. type LandingPage string
  48. // enumerates all the landing page types
  49. const (
  50. LandingPageHome LandingPage = "/"
  51. LandingPageExplore LandingPage = "/explore"
  52. LandingPageOrganizations LandingPage = "/explore/organizations"
  53. )
  54. // MarkupParser defines the external parser configured in ini
  55. type MarkupParser struct {
  56. Enabled bool
  57. MarkupName string
  58. Command string
  59. FileExtensions []string
  60. IsInputFile bool
  61. }
  62. // enumerates all the policy repository creating
  63. const (
  64. RepoCreatingLastUserVisibility = "last"
  65. RepoCreatingPrivate = "private"
  66. RepoCreatingPublic = "public"
  67. )
  68. // enumerates all the types of captchas
  69. const (
  70. ImageCaptcha = "image"
  71. ReCaptcha = "recaptcha"
  72. )
  73. // settings
  74. var (
  75. // AppVer settings
  76. AppVer string
  77. AppBuiltWith string
  78. AppName string
  79. AppURL string
  80. AppSubURL string
  81. AppSubURLDepth int // Number of slashes
  82. AppPath string
  83. AppDataPath string
  84. AppWorkPath string
  85. // Server settings
  86. Protocol Scheme
  87. Domain string
  88. HTTPAddr string
  89. HTTPPort string
  90. LocalURL string
  91. RedirectOtherPort bool
  92. PortToRedirect string
  93. OfflineMode bool
  94. DisableRouterLog bool
  95. CertFile string
  96. KeyFile string
  97. StaticRootPath string
  98. EnableGzip bool
  99. LandingPageURL LandingPage
  100. UnixSocketPermission uint32
  101. EnablePprof bool
  102. PprofDataPath string
  103. EnableLetsEncrypt bool
  104. LetsEncryptTOS bool
  105. LetsEncryptDirectory string
  106. LetsEncryptEmail string
  107. SSH = struct {
  108. Disabled bool `ini:"DISABLE_SSH"`
  109. StartBuiltinServer bool `ini:"START_SSH_SERVER"`
  110. BuiltinServerUser string `ini:"BUILTIN_SSH_SERVER_USER"`
  111. Domain string `ini:"SSH_DOMAIN"`
  112. Port int `ini:"SSH_PORT"`
  113. ListenHost string `ini:"SSH_LISTEN_HOST"`
  114. ListenPort int `ini:"SSH_LISTEN_PORT"`
  115. RootPath string `ini:"SSH_ROOT_PATH"`
  116. ServerCiphers []string `ini:"SSH_SERVER_CIPHERS"`
  117. ServerKeyExchanges []string `ini:"SSH_SERVER_KEY_EXCHANGES"`
  118. ServerMACs []string `ini:"SSH_SERVER_MACS"`
  119. KeyTestPath string `ini:"SSH_KEY_TEST_PATH"`
  120. KeygenPath string `ini:"SSH_KEYGEN_PATH"`
  121. AuthorizedKeysBackup bool `ini:"SSH_AUTHORIZED_KEYS_BACKUP"`
  122. MinimumKeySizeCheck bool `ini:"-"`
  123. MinimumKeySizes map[string]int `ini:"-"`
  124. CreateAuthorizedKeysFile bool `ini:"SSH_CREATE_AUTHORIZED_KEYS_FILE"`
  125. ExposeAnonymous bool `ini:"SSH_EXPOSE_ANONYMOUS"`
  126. }{
  127. Disabled: false,
  128. StartBuiltinServer: false,
  129. Domain: "",
  130. Port: 22,
  131. ServerCiphers: []string{"aes128-ctr", "aes192-ctr", "aes256-ctr", "aes128-gcm@openssh.com", "arcfour256", "arcfour128"},
  132. ServerKeyExchanges: []string{"diffie-hellman-group1-sha1", "diffie-hellman-group14-sha1", "ecdh-sha2-nistp256", "ecdh-sha2-nistp384", "ecdh-sha2-nistp521", "curve25519-sha256@libssh.org"},
  133. ServerMACs: []string{"hmac-sha2-256-etm@openssh.com", "hmac-sha2-256", "hmac-sha1", "hmac-sha1-96"},
  134. KeygenPath: "ssh-keygen",
  135. }
  136. LFS struct {
  137. StartServer bool `ini:"LFS_START_SERVER"`
  138. ContentPath string `ini:"LFS_CONTENT_PATH"`
  139. JWTSecretBase64 string `ini:"LFS_JWT_SECRET"`
  140. JWTSecretBytes []byte `ini:"-"`
  141. HTTPAuthExpiry time.Duration `ini:"LFS_HTTP_AUTH_EXPIRY"`
  142. }
  143. // Security settings
  144. InstallLock bool
  145. SecretKey string
  146. LogInRememberDays int
  147. CookieUserName string
  148. CookieRememberName string
  149. ReverseProxyAuthUser string
  150. MinPasswordLength int
  151. ImportLocalPaths bool
  152. DisableGitHooks bool
  153. // Database settings
  154. UseSQLite3 bool
  155. UseMySQL bool
  156. UseMSSQL bool
  157. UsePostgreSQL bool
  158. UseTiDB bool
  159. LogSQL bool
  160. // Indexer settings
  161. Indexer struct {
  162. IssuePath string
  163. RepoIndexerEnabled bool
  164. RepoPath string
  165. UpdateQueueLength int
  166. MaxIndexerFileSize int64
  167. }
  168. // Webhook settings
  169. Webhook = struct {
  170. QueueLength int
  171. DeliverTimeout int
  172. SkipTLSVerify bool
  173. Types []string
  174. PagingNum int
  175. }{
  176. QueueLength: 1000,
  177. DeliverTimeout: 5,
  178. SkipTLSVerify: false,
  179. PagingNum: 10,
  180. }
  181. // Repository settings
  182. Repository = struct {
  183. AnsiCharset string
  184. ForcePrivate bool
  185. DefaultPrivate string
  186. MaxCreationLimit int
  187. MirrorQueueLength int
  188. PullRequestQueueLength int
  189. PreferredLicenses []string
  190. DisableHTTPGit bool
  191. UseCompatSSHURI bool
  192. // Repository editor settings
  193. Editor struct {
  194. LineWrapExtensions []string
  195. PreviewableFileModes []string
  196. } `ini:"-"`
  197. // Repository upload settings
  198. Upload struct {
  199. Enabled bool
  200. TempPath string
  201. AllowedTypes []string `delim:"|"`
  202. FileMaxSize int64
  203. MaxFiles int
  204. } `ini:"-"`
  205. // Repository local settings
  206. Local struct {
  207. LocalCopyPath string
  208. LocalWikiPath string
  209. } `ini:"-"`
  210. // Pull request settings
  211. PullRequest struct {
  212. WorkInProgressPrefixes []string
  213. } `ini:"repository.pull-request"`
  214. }{
  215. AnsiCharset: "",
  216. ForcePrivate: false,
  217. DefaultPrivate: RepoCreatingLastUserVisibility,
  218. MaxCreationLimit: -1,
  219. MirrorQueueLength: 1000,
  220. PullRequestQueueLength: 1000,
  221. PreferredLicenses: []string{"Apache License 2.0,MIT License"},
  222. DisableHTTPGit: false,
  223. UseCompatSSHURI: false,
  224. // Repository editor settings
  225. Editor: struct {
  226. LineWrapExtensions []string
  227. PreviewableFileModes []string
  228. }{
  229. LineWrapExtensions: strings.Split(".txt,.md,.markdown,.mdown,.mkd,", ","),
  230. PreviewableFileModes: []string{"markdown"},
  231. },
  232. // Repository upload settings
  233. Upload: struct {
  234. Enabled bool
  235. TempPath string
  236. AllowedTypes []string `delim:"|"`
  237. FileMaxSize int64
  238. MaxFiles int
  239. }{
  240. Enabled: true,
  241. TempPath: "data/tmp/uploads",
  242. AllowedTypes: []string{},
  243. FileMaxSize: 3,
  244. MaxFiles: 5,
  245. },
  246. // Repository local settings
  247. Local: struct {
  248. LocalCopyPath string
  249. LocalWikiPath string
  250. }{
  251. LocalCopyPath: "tmp/local-repo",
  252. LocalWikiPath: "tmp/local-wiki",
  253. },
  254. // Pull request settings
  255. PullRequest: struct {
  256. WorkInProgressPrefixes []string
  257. }{
  258. WorkInProgressPrefixes: defaultPullRequestWorkInProgressPrefixes,
  259. },
  260. }
  261. RepoRootPath string
  262. ScriptType = "bash"
  263. // UI settings
  264. UI = struct {
  265. ExplorePagingNum int
  266. IssuePagingNum int
  267. RepoSearchPagingNum int
  268. FeedMaxCommitNum int
  269. GraphMaxCommitNum int
  270. CodeCommentLines int
  271. ReactionMaxUserNum int
  272. ThemeColorMetaTag string
  273. MaxDisplayFileSize int64
  274. ShowUserEmail bool
  275. DefaultTheme string
  276. Admin struct {
  277. UserPagingNum int
  278. RepoPagingNum int
  279. NoticePagingNum int
  280. OrgPagingNum int
  281. } `ini:"ui.admin"`
  282. User struct {
  283. RepoPagingNum int
  284. } `ini:"ui.user"`
  285. Meta struct {
  286. Author string
  287. Description string
  288. Keywords string
  289. } `ini:"ui.meta"`
  290. }{
  291. ExplorePagingNum: 20,
  292. IssuePagingNum: 10,
  293. RepoSearchPagingNum: 10,
  294. FeedMaxCommitNum: 5,
  295. GraphMaxCommitNum: 100,
  296. CodeCommentLines: 4,
  297. ReactionMaxUserNum: 10,
  298. ThemeColorMetaTag: `#6cc644`,
  299. MaxDisplayFileSize: 8388608,
  300. DefaultTheme: `gitea`,
  301. Admin: struct {
  302. UserPagingNum int
  303. RepoPagingNum int
  304. NoticePagingNum int
  305. OrgPagingNum int
  306. }{
  307. UserPagingNum: 50,
  308. RepoPagingNum: 50,
  309. NoticePagingNum: 25,
  310. OrgPagingNum: 50,
  311. },
  312. User: struct {
  313. RepoPagingNum int
  314. }{
  315. RepoPagingNum: 15,
  316. },
  317. Meta: struct {
  318. Author string
  319. Description string
  320. Keywords string
  321. }{
  322. Author: "Gitea - Git with a cup of tea",
  323. Description: "Gitea (Git with a cup of tea) is a painless self-hosted Git service written in Go",
  324. Keywords: "go,git,self-hosted,gitea",
  325. },
  326. }
  327. // Markdown settings
  328. Markdown = struct {
  329. EnableHardLineBreak bool
  330. CustomURLSchemes []string `ini:"CUSTOM_URL_SCHEMES"`
  331. FileExtensions []string
  332. }{
  333. EnableHardLineBreak: false,
  334. FileExtensions: strings.Split(".md,.markdown,.mdown,.mkd", ","),
  335. }
  336. // Admin settings
  337. Admin struct {
  338. DisableRegularOrgCreation bool
  339. }
  340. // Picture settings
  341. AvatarUploadPath string
  342. AvatarMaxWidth int
  343. AvatarMaxHeight int
  344. GravatarSource string
  345. GravatarSourceURL *url.URL
  346. DisableGravatar bool
  347. EnableFederatedAvatar bool
  348. LibravatarService *libravatar.Libravatar
  349. // Log settings
  350. LogLevel string
  351. LogRootPath string
  352. LogModes []string
  353. LogConfigs []string
  354. // Attachment settings
  355. AttachmentPath string
  356. AttachmentAllowedTypes string
  357. AttachmentMaxSize int64
  358. AttachmentMaxFiles int
  359. AttachmentEnabled bool
  360. // Time settings
  361. TimeFormat string
  362. // Session settings
  363. SessionConfig session.Options
  364. CSRFCookieName = "_csrf"
  365. // Cron tasks
  366. Cron = struct {
  367. UpdateMirror struct {
  368. Enabled bool
  369. RunAtStart bool
  370. Schedule string
  371. } `ini:"cron.update_mirrors"`
  372. RepoHealthCheck struct {
  373. Enabled bool
  374. RunAtStart bool
  375. Schedule string
  376. Timeout time.Duration
  377. Args []string `delim:" "`
  378. } `ini:"cron.repo_health_check"`
  379. CheckRepoStats struct {
  380. Enabled bool
  381. RunAtStart bool
  382. Schedule string
  383. } `ini:"cron.check_repo_stats"`
  384. ArchiveCleanup struct {
  385. Enabled bool
  386. RunAtStart bool
  387. Schedule string
  388. OlderThan time.Duration
  389. } `ini:"cron.archive_cleanup"`
  390. SyncExternalUsers struct {
  391. Enabled bool
  392. RunAtStart bool
  393. Schedule string
  394. UpdateExisting bool
  395. } `ini:"cron.sync_external_users"`
  396. DeletedBranchesCleanup struct {
  397. Enabled bool
  398. RunAtStart bool
  399. Schedule string
  400. OlderThan time.Duration
  401. } `ini:"cron.deleted_branches_cleanup"`
  402. }{
  403. UpdateMirror: struct {
  404. Enabled bool
  405. RunAtStart bool
  406. Schedule string
  407. }{
  408. Enabled: true,
  409. RunAtStart: false,
  410. Schedule: "@every 10m",
  411. },
  412. RepoHealthCheck: struct {
  413. Enabled bool
  414. RunAtStart bool
  415. Schedule string
  416. Timeout time.Duration
  417. Args []string `delim:" "`
  418. }{
  419. Enabled: true,
  420. RunAtStart: false,
  421. Schedule: "@every 24h",
  422. Timeout: 60 * time.Second,
  423. Args: []string{},
  424. },
  425. CheckRepoStats: struct {
  426. Enabled bool
  427. RunAtStart bool
  428. Schedule string
  429. }{
  430. Enabled: true,
  431. RunAtStart: true,
  432. Schedule: "@every 24h",
  433. },
  434. ArchiveCleanup: struct {
  435. Enabled bool
  436. RunAtStart bool
  437. Schedule string
  438. OlderThan time.Duration
  439. }{
  440. Enabled: true,
  441. RunAtStart: true,
  442. Schedule: "@every 24h",
  443. OlderThan: 24 * time.Hour,
  444. },
  445. SyncExternalUsers: struct {
  446. Enabled bool
  447. RunAtStart bool
  448. Schedule string
  449. UpdateExisting bool
  450. }{
  451. Enabled: true,
  452. RunAtStart: false,
  453. Schedule: "@every 24h",
  454. UpdateExisting: true,
  455. },
  456. DeletedBranchesCleanup: struct {
  457. Enabled bool
  458. RunAtStart bool
  459. Schedule string
  460. OlderThan time.Duration
  461. }{
  462. Enabled: true,
  463. RunAtStart: true,
  464. Schedule: "@every 24h",
  465. OlderThan: 24 * time.Hour,
  466. },
  467. }
  468. // Git settings
  469. Git = struct {
  470. Version string `ini:"-"`
  471. DisableDiffHighlight bool
  472. MaxGitDiffLines int
  473. MaxGitDiffLineCharacters int
  474. MaxGitDiffFiles int
  475. GCArgs []string `delim:" "`
  476. Timeout struct {
  477. Migrate int
  478. Mirror int
  479. Clone int
  480. Pull int
  481. GC int `ini:"GC"`
  482. } `ini:"git.timeout"`
  483. }{
  484. DisableDiffHighlight: false,
  485. MaxGitDiffLines: 1000,
  486. MaxGitDiffLineCharacters: 5000,
  487. MaxGitDiffFiles: 100,
  488. GCArgs: []string{},
  489. Timeout: struct {
  490. Migrate int
  491. Mirror int
  492. Clone int
  493. Pull int
  494. GC int `ini:"GC"`
  495. }{
  496. Migrate: 600,
  497. Mirror: 300,
  498. Clone: 300,
  499. Pull: 300,
  500. GC: 60,
  501. },
  502. }
  503. // Mirror settings
  504. Mirror struct {
  505. DefaultInterval time.Duration
  506. MinInterval time.Duration
  507. }
  508. // API settings
  509. API = struct {
  510. EnableSwagger bool
  511. MaxResponseItems int
  512. }{
  513. EnableSwagger: true,
  514. MaxResponseItems: 50,
  515. }
  516. U2F = struct {
  517. AppID string
  518. TrustedFacets []string
  519. }{}
  520. // Metrics settings
  521. Metrics = struct {
  522. Enabled bool
  523. Token string
  524. }{
  525. Enabled: false,
  526. Token: "",
  527. }
  528. // I18n settings
  529. Langs []string
  530. Names []string
  531. dateLangs map[string]string
  532. // Highlight settings are loaded in modules/template/highlight.go
  533. // Other settings
  534. ShowFooterBranding bool
  535. ShowFooterVersion bool
  536. ShowFooterTemplateLoadTime bool
  537. // Global setting objects
  538. Cfg *ini.File
  539. CustomPath string // Custom directory path
  540. CustomConf string
  541. CustomPID string
  542. ProdMode bool
  543. RunUser string
  544. IsWindows bool
  545. HasRobotsTxt bool
  546. InternalToken string // internal access token
  547. IterateBufferSize int
  548. ExternalMarkupParsers []MarkupParser
  549. // UILocation is the location on the UI, so that we can display the time on UI.
  550. // Currently only show the default time.Local, it could be added to app.ini after UI is ready
  551. UILocation = time.Local
  552. )
  553. // DateLang transforms standard language locale name to corresponding value in datetime plugin.
  554. func DateLang(lang string) string {
  555. name, ok := dateLangs[lang]
  556. if ok {
  557. return name
  558. }
  559. return "en"
  560. }
  561. func getAppPath() (string, error) {
  562. var appPath string
  563. var err error
  564. if IsWindows && filepath.IsAbs(os.Args[0]) {
  565. appPath = filepath.Clean(os.Args[0])
  566. } else {
  567. appPath, err = exec.LookPath(os.Args[0])
  568. }
  569. if err != nil {
  570. return "", err
  571. }
  572. appPath, err = filepath.Abs(appPath)
  573. if err != nil {
  574. return "", err
  575. }
  576. // Note: we don't use path.Dir here because it does not handle case
  577. // which path starts with two "/" in Windows: "//psf/Home/..."
  578. return strings.Replace(appPath, "\\", "/", -1), err
  579. }
  580. func getWorkPath(appPath string) string {
  581. workPath := ""
  582. giteaWorkPath := os.Getenv("GITEA_WORK_DIR")
  583. if len(giteaWorkPath) > 0 {
  584. workPath = giteaWorkPath
  585. } else {
  586. i := strings.LastIndex(appPath, "/")
  587. if i == -1 {
  588. workPath = appPath
  589. } else {
  590. workPath = appPath[:i]
  591. }
  592. }
  593. return strings.Replace(workPath, "\\", "/", -1)
  594. }
  595. func init() {
  596. IsWindows = runtime.GOOS == "windows"
  597. log.NewLogger(0, "console", `{"level": 0}`)
  598. var err error
  599. if AppPath, err = getAppPath(); err != nil {
  600. log.Fatal(4, "Failed to get app path: %v", err)
  601. }
  602. AppWorkPath = getWorkPath(AppPath)
  603. }
  604. func forcePathSeparator(path string) {
  605. if strings.Contains(path, "\\") {
  606. log.Fatal(4, "Do not use '\\' or '\\\\' in paths, instead, please use '/' in all places")
  607. }
  608. }
  609. // IsRunUserMatchCurrentUser returns false if configured run user does not match
  610. // actual user that runs the app. The first return value is the actual user name.
  611. // This check is ignored under Windows since SSH remote login is not the main
  612. // method to login on Windows.
  613. func IsRunUserMatchCurrentUser(runUser string) (string, bool) {
  614. if IsWindows {
  615. return "", true
  616. }
  617. currentUser := user.CurrentUsername()
  618. return currentUser, runUser == currentUser
  619. }
  620. func createPIDFile(pidPath string) {
  621. currentPid := os.Getpid()
  622. if err := os.MkdirAll(filepath.Dir(pidPath), os.ModePerm); err != nil {
  623. log.Fatal(4, "Failed to create PID folder: %v", err)
  624. }
  625. file, err := os.Create(pidPath)
  626. if err != nil {
  627. log.Fatal(4, "Failed to create PID file: %v", err)
  628. }
  629. defer file.Close()
  630. if _, err := file.WriteString(strconv.FormatInt(int64(currentPid), 10)); err != nil {
  631. log.Fatal(4, "Failed to write PID information: %v", err)
  632. }
  633. }
  634. // NewContext initializes configuration context.
  635. // NOTE: do not print any log except error.
  636. func NewContext() {
  637. Cfg = ini.Empty()
  638. CustomPath = os.Getenv("GITEA_CUSTOM")
  639. if len(CustomPath) == 0 {
  640. CustomPath = path.Join(AppWorkPath, "custom")
  641. } else if !filepath.IsAbs(CustomPath) {
  642. CustomPath = path.Join(AppWorkPath, CustomPath)
  643. }
  644. if len(CustomPID) > 0 {
  645. createPIDFile(CustomPID)
  646. }
  647. if len(CustomConf) == 0 {
  648. CustomConf = path.Join(CustomPath, "conf/app.ini")
  649. } else if !filepath.IsAbs(CustomConf) {
  650. CustomConf = path.Join(CustomPath, CustomConf)
  651. }
  652. if com.IsFile(CustomConf) {
  653. if err := Cfg.Append(CustomConf); err != nil {
  654. log.Fatal(4, "Failed to load custom conf '%s': %v", CustomConf, err)
  655. }
  656. } else {
  657. log.Warn("Custom config '%s' not found, ignore this if you're running first time", CustomConf)
  658. }
  659. Cfg.NameMapper = ini.AllCapsUnderscore
  660. homeDir, err := com.HomeDir()
  661. if err != nil {
  662. log.Fatal(4, "Failed to get home directory: %v", err)
  663. }
  664. homeDir = strings.Replace(homeDir, "\\", "/", -1)
  665. LogLevel = getLogLevel("log", "LEVEL", "Info")
  666. LogRootPath = Cfg.Section("log").Key("ROOT_PATH").MustString(path.Join(AppWorkPath, "log"))
  667. forcePathSeparator(LogRootPath)
  668. sec := Cfg.Section("server")
  669. AppName = Cfg.Section("").Key("APP_NAME").MustString("Gitea: Git with a cup of tea")
  670. Protocol = HTTP
  671. if sec.Key("PROTOCOL").String() == "https" {
  672. Protocol = HTTPS
  673. CertFile = sec.Key("CERT_FILE").String()
  674. KeyFile = sec.Key("KEY_FILE").String()
  675. } else if sec.Key("PROTOCOL").String() == "fcgi" {
  676. Protocol = FCGI
  677. } else if sec.Key("PROTOCOL").String() == "unix" {
  678. Protocol = UnixSocket
  679. UnixSocketPermissionRaw := sec.Key("UNIX_SOCKET_PERMISSION").MustString("666")
  680. UnixSocketPermissionParsed, err := strconv.ParseUint(UnixSocketPermissionRaw, 8, 32)
  681. if err != nil || UnixSocketPermissionParsed > 0777 {
  682. log.Fatal(4, "Failed to parse unixSocketPermission: %s", UnixSocketPermissionRaw)
  683. }
  684. UnixSocketPermission = uint32(UnixSocketPermissionParsed)
  685. }
  686. EnableLetsEncrypt = sec.Key("ENABLE_LETSENCRYPT").MustBool(false)
  687. LetsEncryptTOS = sec.Key("LETSENCRYPT_ACCEPTTOS").MustBool(false)
  688. if !LetsEncryptTOS && EnableLetsEncrypt {
  689. log.Warn("Failed to enable Let's Encrypt due to Let's Encrypt TOS not being accepted")
  690. EnableLetsEncrypt = false
  691. }
  692. LetsEncryptDirectory = sec.Key("LETSENCRYPT_DIRECTORY").MustString("https")
  693. LetsEncryptEmail = sec.Key("LETSENCRYPT_EMAIL").MustString("")
  694. Domain = sec.Key("DOMAIN").MustString("localhost")
  695. HTTPAddr = sec.Key("HTTP_ADDR").MustString("0.0.0.0")
  696. HTTPPort = sec.Key("HTTP_PORT").MustString("3000")
  697. defaultAppURL := string(Protocol) + "://" + Domain
  698. if (Protocol == HTTP && HTTPPort != "80") || (Protocol == HTTPS && HTTPPort != "443") {
  699. defaultAppURL += ":" + HTTPPort
  700. }
  701. AppURL = sec.Key("ROOT_URL").MustString(defaultAppURL)
  702. AppURL = strings.TrimRight(AppURL, "/") + "/"
  703. // Check if has app suburl.
  704. url, err := url.Parse(AppURL)
  705. if err != nil {
  706. log.Fatal(4, "Invalid ROOT_URL '%s': %s", AppURL, err)
  707. }
  708. // Suburl should start with '/' and end without '/', such as '/{subpath}'.
  709. // This value is empty if site does not have sub-url.
  710. AppSubURL = strings.TrimSuffix(url.Path, "/")
  711. AppSubURLDepth = strings.Count(AppSubURL, "/")
  712. // Check if Domain differs from AppURL domain than update it to AppURL's domain
  713. // TODO: Can be replaced with url.Hostname() when minimal GoLang version is 1.8
  714. urlHostname := strings.SplitN(url.Host, ":", 2)[0]
  715. if urlHostname != Domain && net.ParseIP(urlHostname) == nil {
  716. Domain = urlHostname
  717. }
  718. var defaultLocalURL string
  719. switch Protocol {
  720. case UnixSocket:
  721. defaultLocalURL = "http://unix/"
  722. case FCGI:
  723. defaultLocalURL = AppURL
  724. default:
  725. defaultLocalURL = string(Protocol) + "://"
  726. if HTTPAddr == "0.0.0.0" {
  727. defaultLocalURL += "localhost"
  728. } else {
  729. defaultLocalURL += HTTPAddr
  730. }
  731. defaultLocalURL += ":" + HTTPPort + "/"
  732. }
  733. LocalURL = sec.Key("LOCAL_ROOT_URL").MustString(defaultLocalURL)
  734. RedirectOtherPort = sec.Key("REDIRECT_OTHER_PORT").MustBool(false)
  735. PortToRedirect = sec.Key("PORT_TO_REDIRECT").MustString("80")
  736. OfflineMode = sec.Key("OFFLINE_MODE").MustBool()
  737. DisableRouterLog = sec.Key("DISABLE_ROUTER_LOG").MustBool()
  738. StaticRootPath = sec.Key("STATIC_ROOT_PATH").MustString(AppWorkPath)
  739. AppDataPath = sec.Key("APP_DATA_PATH").MustString(path.Join(AppWorkPath, "data"))
  740. EnableGzip = sec.Key("ENABLE_GZIP").MustBool()
  741. EnablePprof = sec.Key("ENABLE_PPROF").MustBool(false)
  742. PprofDataPath = sec.Key("PPROF_DATA_PATH").MustString(path.Join(AppWorkPath, "data/tmp/pprof"))
  743. if !filepath.IsAbs(PprofDataPath) {
  744. PprofDataPath = filepath.Join(AppWorkPath, PprofDataPath)
  745. }
  746. switch sec.Key("LANDING_PAGE").MustString("home") {
  747. case "explore":
  748. LandingPageURL = LandingPageExplore
  749. case "organizations":
  750. LandingPageURL = LandingPageOrganizations
  751. default:
  752. LandingPageURL = LandingPageHome
  753. }
  754. if len(SSH.Domain) == 0 {
  755. SSH.Domain = Domain
  756. }
  757. SSH.RootPath = path.Join(homeDir, ".ssh")
  758. serverCiphers := sec.Key("SSH_SERVER_CIPHERS").Strings(",")
  759. if len(serverCiphers) > 0 {
  760. SSH.ServerCiphers = serverCiphers
  761. }
  762. serverKeyExchanges := sec.Key("SSH_SERVER_KEY_EXCHANGES").Strings(",")
  763. if len(serverKeyExchanges) > 0 {
  764. SSH.ServerKeyExchanges = serverKeyExchanges
  765. }
  766. serverMACs := sec.Key("SSH_SERVER_MACS").Strings(",")
  767. if len(serverMACs) > 0 {
  768. SSH.ServerMACs = serverMACs
  769. }
  770. SSH.KeyTestPath = os.TempDir()
  771. if err = Cfg.Section("server").MapTo(&SSH); err != nil {
  772. log.Fatal(4, "Failed to map SSH settings: %v", err)
  773. }
  774. SSH.KeygenPath = sec.Key("SSH_KEYGEN_PATH").MustString("ssh-keygen")
  775. SSH.Port = sec.Key("SSH_PORT").MustInt(22)
  776. SSH.ListenPort = sec.Key("SSH_LISTEN_PORT").MustInt(SSH.Port)
  777. // When disable SSH, start builtin server value is ignored.
  778. if SSH.Disabled {
  779. SSH.StartBuiltinServer = false
  780. }
  781. if !SSH.Disabled && !SSH.StartBuiltinServer {
  782. if err := os.MkdirAll(SSH.RootPath, 0700); err != nil {
  783. log.Fatal(4, "Failed to create '%s': %v", SSH.RootPath, err)
  784. } else if err = os.MkdirAll(SSH.KeyTestPath, 0644); err != nil {
  785. log.Fatal(4, "Failed to create '%s': %v", SSH.KeyTestPath, err)
  786. }
  787. }
  788. SSH.MinimumKeySizeCheck = sec.Key("MINIMUM_KEY_SIZE_CHECK").MustBool()
  789. SSH.MinimumKeySizes = map[string]int{}
  790. minimumKeySizes := Cfg.Section("ssh.minimum_key_sizes").Keys()
  791. for _, key := range minimumKeySizes {
  792. if key.MustInt() != -1 {
  793. SSH.MinimumKeySizes[strings.ToLower(key.Name())] = key.MustInt()
  794. }
  795. }
  796. SSH.AuthorizedKeysBackup = sec.Key("SSH_AUTHORIZED_KEYS_BACKUP").MustBool(true)
  797. SSH.CreateAuthorizedKeysFile = sec.Key("SSH_CREATE_AUTHORIZED_KEYS_FILE").MustBool(true)
  798. SSH.ExposeAnonymous = sec.Key("SSH_EXPOSE_ANONYMOUS").MustBool(false)
  799. sec = Cfg.Section("server")
  800. if err = sec.MapTo(&LFS); err != nil {
  801. log.Fatal(4, "Failed to map LFS settings: %v", err)
  802. }
  803. LFS.ContentPath = sec.Key("LFS_CONTENT_PATH").MustString(filepath.Join(AppDataPath, "lfs"))
  804. if !filepath.IsAbs(LFS.ContentPath) {
  805. LFS.ContentPath = filepath.Join(AppWorkPath, LFS.ContentPath)
  806. }
  807. LFS.HTTPAuthExpiry = sec.Key("LFS_HTTP_AUTH_EXPIRY").MustDuration(20 * time.Minute)
  808. if LFS.StartServer {
  809. if err := os.MkdirAll(LFS.ContentPath, 0700); err != nil {
  810. log.Fatal(4, "Failed to create '%s': %v", LFS.ContentPath, err)
  811. }
  812. LFS.JWTSecretBytes = make([]byte, 32)
  813. n, err := base64.RawURLEncoding.Decode(LFS.JWTSecretBytes, []byte(LFS.JWTSecretBase64))
  814. if err != nil || n != 32 {
  815. LFS.JWTSecretBase64, err = generate.NewLfsJwtSecret()
  816. if err != nil {
  817. log.Fatal(4, "Error generating JWT Secret for custom config: %v", err)
  818. return
  819. }
  820. // Save secret
  821. cfg := ini.Empty()
  822. if com.IsFile(CustomConf) {
  823. // Keeps custom settings if there is already something.
  824. if err := cfg.Append(CustomConf); err != nil {
  825. log.Error(4, "Failed to load custom conf '%s': %v", CustomConf, err)
  826. }
  827. }
  828. cfg.Section("server").Key("LFS_JWT_SECRET").SetValue(LFS.JWTSecretBase64)
  829. if err := os.MkdirAll(filepath.Dir(CustomConf), os.ModePerm); err != nil {
  830. log.Fatal(4, "Failed to create '%s': %v", CustomConf, err)
  831. }
  832. if err := cfg.SaveTo(CustomConf); err != nil {
  833. log.Fatal(4, "Error saving generated JWT Secret to custom config: %v", err)
  834. return
  835. }
  836. }
  837. //Disable LFS client hooks if installed for the current OS user
  838. //Needs at least git v2.1.2
  839. binVersion, err := git.BinVersion()
  840. if err != nil {
  841. log.Fatal(4, "Error retrieving git version: %v", err)
  842. }
  843. if !version.Compare(binVersion, "2.1.2", ">=") {
  844. LFS.StartServer = false
  845. log.Error(4, "LFS server support needs at least Git v2.1.2")
  846. } else {
  847. git.GlobalCommandArgs = append(git.GlobalCommandArgs, "-c", "filter.lfs.required=",
  848. "-c", "filter.lfs.smudge=", "-c", "filter.lfs.clean=")
  849. }
  850. }
  851. sec = Cfg.Section("security")
  852. InstallLock = sec.Key("INSTALL_LOCK").MustBool(false)
  853. SecretKey = sec.Key("SECRET_KEY").MustString("!#@FDEWREWR&*(")
  854. LogInRememberDays = sec.Key("LOGIN_REMEMBER_DAYS").MustInt(7)
  855. CookieUserName = sec.Key("COOKIE_USERNAME").MustString("gitea_awesome")
  856. CookieRememberName = sec.Key("COOKIE_REMEMBER_NAME").MustString("gitea_incredible")
  857. ReverseProxyAuthUser = sec.Key("REVERSE_PROXY_AUTHENTICATION_USER").MustString("X-WEBAUTH-USER")
  858. MinPasswordLength = sec.Key("MIN_PASSWORD_LENGTH").MustInt(6)
  859. ImportLocalPaths = sec.Key("IMPORT_LOCAL_PATHS").MustBool(false)
  860. DisableGitHooks = sec.Key("DISABLE_GIT_HOOKS").MustBool(false)
  861. InternalToken = sec.Key("INTERNAL_TOKEN").String()
  862. if len(InternalToken) == 0 {
  863. InternalToken, err = generate.NewInternalToken()
  864. if err != nil {
  865. log.Fatal(4, "Error generate internal token: %v", err)
  866. }
  867. // Save secret
  868. cfgSave := ini.Empty()
  869. if com.IsFile(CustomConf) {
  870. // Keeps custom settings if there is already something.
  871. if err := cfgSave.Append(CustomConf); err != nil {
  872. log.Error(4, "Failed to load custom conf '%s': %v", CustomConf, err)
  873. }
  874. }
  875. cfgSave.Section("security").Key("INTERNAL_TOKEN").SetValue(InternalToken)
  876. if err := os.MkdirAll(filepath.Dir(CustomConf), os.ModePerm); err != nil {
  877. log.Fatal(4, "Failed to create '%s': %v", CustomConf, err)
  878. }
  879. if err := cfgSave.SaveTo(CustomConf); err != nil {
  880. log.Fatal(4, "Error saving generated JWT Secret to custom config: %v", err)
  881. }
  882. }
  883. IterateBufferSize = Cfg.Section("database").Key("ITERATE_BUFFER_SIZE").MustInt(50)
  884. LogSQL = Cfg.Section("database").Key("LOG_SQL").MustBool(true)
  885. sec = Cfg.Section("attachment")
  886. AttachmentPath = sec.Key("PATH").MustString(path.Join(AppDataPath, "attachments"))
  887. if !filepath.IsAbs(AttachmentPath) {
  888. AttachmentPath = path.Join(AppWorkPath, AttachmentPath)
  889. }
  890. AttachmentAllowedTypes = strings.Replace(sec.Key("ALLOWED_TYPES").MustString("image/jpeg,image/png,application/zip,application/gzip"), "|", ",", -1)
  891. AttachmentMaxSize = sec.Key("MAX_SIZE").MustInt64(4)
  892. AttachmentMaxFiles = sec.Key("MAX_FILES").MustInt(5)
  893. AttachmentEnabled = sec.Key("ENABLED").MustBool(true)
  894. TimeFormatKey := Cfg.Section("time").Key("FORMAT").MustString("RFC1123")
  895. TimeFormat = map[string]string{
  896. "ANSIC": time.ANSIC,
  897. "UnixDate": time.UnixDate,
  898. "RubyDate": time.RubyDate,
  899. "RFC822": time.RFC822,
  900. "RFC822Z": time.RFC822Z,
  901. "RFC850": time.RFC850,
  902. "RFC1123": time.RFC1123,
  903. "RFC1123Z": time.RFC1123Z,
  904. "RFC3339": time.RFC3339,
  905. "RFC3339Nano": time.RFC3339Nano,
  906. "Kitchen": time.Kitchen,
  907. "Stamp": time.Stamp,
  908. "StampMilli": time.StampMilli,
  909. "StampMicro": time.StampMicro,
  910. "StampNano": time.StampNano,
  911. }[TimeFormatKey]
  912. // When the TimeFormatKey does not exist in the previous map e.g.'2006-01-02 15:04:05'
  913. if len(TimeFormat) == 0 {
  914. TimeFormat = TimeFormatKey
  915. TestTimeFormat, _ := time.Parse(TimeFormat, TimeFormat)
  916. if TestTimeFormat.Format(time.RFC3339) != "2006-01-02T15:04:05Z" {
  917. log.Fatal(4, "Can't create time properly, please check your time format has 2006, 01, 02, 15, 04 and 05")
  918. }
  919. log.Trace("Custom TimeFormat: %s", TimeFormat)
  920. }
  921. RunUser = Cfg.Section("").Key("RUN_USER").MustString(user.CurrentUsername())
  922. // Does not check run user when the install lock is off.
  923. if InstallLock {
  924. currentUser, match := IsRunUserMatchCurrentUser(RunUser)
  925. if !match {
  926. log.Fatal(4, "Expect user '%s' but current user is: %s", RunUser, currentUser)
  927. }
  928. }
  929. SSH.BuiltinServerUser = Cfg.Section("server").Key("BUILTIN_SSH_SERVER_USER").MustString(RunUser)
  930. // Determine and create root git repository path.
  931. sec = Cfg.Section("repository")
  932. Repository.DisableHTTPGit = sec.Key("DISABLE_HTTP_GIT").MustBool()
  933. Repository.UseCompatSSHURI = sec.Key("USE_COMPAT_SSH_URI").MustBool()
  934. Repository.MaxCreationLimit = sec.Key("MAX_CREATION_LIMIT").MustInt(-1)
  935. RepoRootPath = sec.Key("ROOT").MustString(path.Join(homeDir, "gitea-repositories"))
  936. forcePathSeparator(RepoRootPath)
  937. if !filepath.IsAbs(RepoRootPath) {
  938. RepoRootPath = filepath.Join(AppWorkPath, RepoRootPath)
  939. } else {
  940. RepoRootPath = filepath.Clean(RepoRootPath)
  941. }
  942. ScriptType = sec.Key("SCRIPT_TYPE").MustString("bash")
  943. if err = Cfg.Section("repository").MapTo(&Repository); err != nil {
  944. log.Fatal(4, "Failed to map Repository settings: %v", err)
  945. } else if err = Cfg.Section("repository.editor").MapTo(&Repository.Editor); err != nil {
  946. log.Fatal(4, "Failed to map Repository.Editor settings: %v", err)
  947. } else if err = Cfg.Section("repository.upload").MapTo(&Repository.Upload); err != nil {
  948. log.Fatal(4, "Failed to map Repository.Upload settings: %v", err)
  949. } else if err = Cfg.Section("repository.local").MapTo(&Repository.Local); err != nil {
  950. log.Fatal(4, "Failed to map Repository.Local settings: %v", err)
  951. } else if err = Cfg.Section("repository.pull-request").MapTo(&Repository.PullRequest); err != nil {
  952. log.Fatal(4, "Failed to map Repository.PullRequest settings: %v", err)
  953. }
  954. if !filepath.IsAbs(Repository.Upload.TempPath) {
  955. Repository.Upload.TempPath = path.Join(AppWorkPath, Repository.Upload.TempPath)
  956. }
  957. sec = Cfg.Section("picture")
  958. AvatarUploadPath = sec.Key("AVATAR_UPLOAD_PATH").MustString(path.Join(AppDataPath, "avatars"))
  959. forcePathSeparator(AvatarUploadPath)
  960. if !filepath.IsAbs(AvatarUploadPath) {
  961. AvatarUploadPath = path.Join(AppWorkPath, AvatarUploadPath)
  962. }
  963. AvatarMaxWidth = sec.Key("AVATAR_MAX_WIDTH").MustInt(4096)
  964. AvatarMaxHeight = sec.Key("AVATAR_MAX_HEIGHT").MustInt(3072)
  965. switch source := sec.Key("GRAVATAR_SOURCE").MustString("gravatar"); source {
  966. case "duoshuo":
  967. GravatarSource = "http://gravatar.duoshuo.com/avatar/"
  968. case "gravatar":
  969. GravatarSource = "https://secure.gravatar.com/avatar/"
  970. case "libravatar":
  971. GravatarSource = "https://seccdn.libravatar.org/avatar/"
  972. default:
  973. GravatarSource = source
  974. }
  975. DisableGravatar = sec.Key("DISABLE_GRAVATAR").MustBool()
  976. EnableFederatedAvatar = sec.Key("ENABLE_FEDERATED_AVATAR").MustBool(!InstallLock)
  977. if OfflineMode {
  978. DisableGravatar = true
  979. EnableFederatedAvatar = false
  980. }
  981. if DisableGravatar {
  982. EnableFederatedAvatar = false
  983. }
  984. if EnableFederatedAvatar || !DisableGravatar {
  985. GravatarSourceURL, err = url.Parse(GravatarSource)
  986. if err != nil {
  987. log.Fatal(4, "Failed to parse Gravatar URL(%s): %v",
  988. GravatarSource, err)
  989. }
  990. }
  991. if EnableFederatedAvatar {
  992. LibravatarService = libravatar.New()
  993. if GravatarSourceURL.Scheme == "https" {
  994. LibravatarService.SetUseHTTPS(true)
  995. LibravatarService.SetSecureFallbackHost(GravatarSourceURL.Host)
  996. } else {
  997. LibravatarService.SetUseHTTPS(false)
  998. LibravatarService.SetFallbackHost(GravatarSourceURL.Host)
  999. }
  1000. }
  1001. if err = Cfg.Section("ui").MapTo(&UI); err != nil {
  1002. log.Fatal(4, "Failed to map UI settings: %v", err)
  1003. } else if err = Cfg.Section("markdown").MapTo(&Markdown); err != nil {
  1004. log.Fatal(4, "Failed to map Markdown settings: %v", err)
  1005. } else if err = Cfg.Section("admin").MapTo(&Admin); err != nil {
  1006. log.Fatal(4, "Fail to map Admin settings: %v", err)
  1007. } else if err = Cfg.Section("cron").MapTo(&Cron); err != nil {
  1008. log.Fatal(4, "Failed to map Cron settings: %v", err)
  1009. } else if err = Cfg.Section("git").MapTo(&Git); err != nil {
  1010. log.Fatal(4, "Failed to map Git settings: %v", err)
  1011. } else if err = Cfg.Section("api").MapTo(&API); err != nil {
  1012. log.Fatal(4, "Failed to map API settings: %v", err)
  1013. } else if err = Cfg.Section("metrics").MapTo(&Metrics); err != nil {
  1014. log.Fatal(4, "Failed to map Metrics settings: %v", err)
  1015. }
  1016. sec = Cfg.Section("mirror")
  1017. Mirror.MinInterval = sec.Key("MIN_INTERVAL").MustDuration(10 * time.Minute)
  1018. Mirror.DefaultInterval = sec.Key("DEFAULT_INTERVAL").MustDuration(8 * time.Hour)
  1019. if Mirror.MinInterval.Minutes() < 1 {
  1020. log.Warn("Mirror.MinInterval is too low")
  1021. Mirror.MinInterval = 1 * time.Minute
  1022. }
  1023. if Mirror.DefaultInterval < Mirror.MinInterval {
  1024. log.Warn("Mirror.DefaultInterval is less than Mirror.MinInterval")
  1025. Mirror.DefaultInterval = time.Hour * 8
  1026. }
  1027. Langs = Cfg.Section("i18n").Key("LANGS").Strings(",")
  1028. if len(Langs) == 0 {
  1029. Langs = defaultLangs
  1030. }
  1031. Names = Cfg.Section("i18n").Key("NAMES").Strings(",")
  1032. if len(Names) == 0 {
  1033. Names = defaultLangNames
  1034. }
  1035. dateLangs = Cfg.Section("i18n.datelang").KeysHash()
  1036. ShowFooterBranding = Cfg.Section("other").Key("SHOW_FOOTER_BRANDING").MustBool(false)
  1037. ShowFooterVersion = Cfg.Section("other").Key("SHOW_FOOTER_VERSION").MustBool(true)
  1038. ShowFooterTemplateLoadTime = Cfg.Section("other").Key("SHOW_FOOTER_TEMPLATE_LOAD_TIME").MustBool(true)
  1039. UI.ShowUserEmail = Cfg.Section("ui").Key("SHOW_USER_EMAIL").MustBool(true)
  1040. HasRobotsTxt = com.IsFile(path.Join(CustomPath, "robots.txt"))
  1041. extensionReg := regexp.MustCompile(`\.\w`)
  1042. for _, sec := range Cfg.Section("markup").ChildSections() {
  1043. name := strings.TrimPrefix(sec.Name(), "markup.")
  1044. if name == "" {
  1045. log.Warn("name is empty, markup " + sec.Name() + "ignored")
  1046. continue
  1047. }
  1048. extensions := sec.Key("FILE_EXTENSIONS").Strings(",")
  1049. var exts = make([]string, 0, len(extensions))
  1050. for _, extension := range extensions {
  1051. if !extensionReg.MatchString(extension) {
  1052. log.Warn(sec.Name() + " file extension " + extension + " is invalid. Extension ignored")
  1053. } else {
  1054. exts = append(exts, extension)
  1055. }
  1056. }
  1057. if len(exts) == 0 {
  1058. log.Warn(sec.Name() + " file extension is empty, markup " + name + " ignored")
  1059. continue
  1060. }
  1061. command := sec.Key("RENDER_COMMAND").MustString("")
  1062. if command == "" {
  1063. log.Warn(" RENDER_COMMAND is empty, markup " + name + " ignored")
  1064. continue
  1065. }
  1066. ExternalMarkupParsers = append(ExternalMarkupParsers, MarkupParser{
  1067. Enabled: sec.Key("ENABLED").MustBool(false),
  1068. MarkupName: name,
  1069. FileExtensions: exts,
  1070. Command: command,
  1071. IsInputFile: sec.Key("IS_INPUT_FILE").MustBool(false),
  1072. })
  1073. }
  1074. sec = Cfg.Section("U2F")
  1075. U2F.TrustedFacets, _ = shellquote.Split(sec.Key("TRUSTED_FACETS").MustString(strings.TrimRight(AppURL, "/")))
  1076. U2F.AppID = sec.Key("APP_ID").MustString(strings.TrimRight(AppURL, "/"))
  1077. binVersion, err := git.BinVersion()
  1078. if err != nil {
  1079. log.Fatal(4, "Error retrieving git version: %v", err)
  1080. }
  1081. if version.Compare(binVersion, "2.9", ">=") {
  1082. // Explicitly disable credential helper, otherwise Git credentials might leak
  1083. git.GlobalCommandArgs = append(git.GlobalCommandArgs, "-c", "credential.helper=")
  1084. }
  1085. }
  1086. // Service settings
  1087. var Service struct {
  1088. ActiveCodeLives int
  1089. ResetPwdCodeLives int
  1090. RegisterEmailConfirm bool
  1091. EmailDomainWhitelist []string
  1092. DisableRegistration bool
  1093. AllowOnlyExternalRegistration bool
  1094. ShowRegistrationButton bool
  1095. RequireSignInView bool
  1096. EnableNotifyMail bool
  1097. EnableReverseProxyAuth bool
  1098. EnableReverseProxyAutoRegister bool
  1099. EnableCaptcha bool
  1100. CaptchaType string
  1101. RecaptchaSecret string
  1102. RecaptchaSitekey string
  1103. DefaultKeepEmailPrivate bool
  1104. DefaultAllowCreateOrganization bool
  1105. EnableTimetracking bool
  1106. DefaultEnableTimetracking bool
  1107. DefaultEnableDependencies bool
  1108. DefaultAllowOnlyContributorsToTrackTime bool
  1109. NoReplyAddress string
  1110. EnableUserHeatmap bool
  1111. // OpenID settings
  1112. EnableOpenIDSignIn bool
  1113. EnableOpenIDSignUp bool
  1114. OpenIDWhitelist []*regexp.Regexp
  1115. OpenIDBlacklist []*regexp.Regexp
  1116. }
  1117. func newService() {
  1118. sec := Cfg.Section("service")
  1119. Service.ActiveCodeLives = sec.Key("ACTIVE_CODE_LIVE_MINUTES").MustInt(180)
  1120. Service.ResetPwdCodeLives = sec.Key("RESET_PASSWD_CODE_LIVE_MINUTES").MustInt(180)
  1121. Service.DisableRegistration = sec.Key("DISABLE_REGISTRATION").MustBool()
  1122. Service.AllowOnlyExternalRegistration = sec.Key("ALLOW_ONLY_EXTERNAL_REGISTRATION").MustBool()
  1123. Service.EmailDomainWhitelist = sec.Key("EMAIL_DOMAIN_WHITELIST").Strings(",")
  1124. Service.ShowRegistrationButton = sec.Key("SHOW_REGISTRATION_BUTTON").MustBool(!(Service.DisableRegistration || Service.AllowOnlyExternalRegistration))
  1125. Service.RequireSignInView = sec.Key("REQUIRE_SIGNIN_VIEW").MustBool()
  1126. Service.EnableReverseProxyAuth = sec.Key("ENABLE_REVERSE_PROXY_AUTHENTICATION").MustBool()
  1127. Service.EnableReverseProxyAutoRegister = sec.Key("ENABLE_REVERSE_PROXY_AUTO_REGISTRATION").MustBool()
  1128. Service.EnableCaptcha = sec.Key("ENABLE_CAPTCHA").MustBool(false)
  1129. Service.CaptchaType = sec.Key("CAPTCHA_TYPE").MustString(ImageCaptcha)
  1130. Service.RecaptchaSecret = sec.Key("RECAPTCHA_SECRET").MustString("")
  1131. Service.RecaptchaSitekey = sec.Key("RECAPTCHA_SITEKEY").MustString("")
  1132. Service.DefaultKeepEmailPrivate = sec.Key("DEFAULT_KEEP_EMAIL_PRIVATE").MustBool()
  1133. Service.DefaultAllowCreateOrganization = sec.Key("DEFAULT_ALLOW_CREATE_ORGANIZATION").MustBool(true)
  1134. Service.EnableTimetracking = sec.Key("ENABLE_TIMETRACKING").MustBool(true)
  1135. if Service.EnableTimetracking {
  1136. Service.DefaultEnableTimetracking = sec.Key("DEFAULT_ENABLE_TIMETRACKING").MustBool(true)
  1137. }
  1138. Service.DefaultEnableDependencies = sec.Key("DEFAULT_ENABLE_DEPENDENCIES").MustBool(true)
  1139. Service.DefaultAllowOnlyContributorsToTrackTime = sec.Key("DEFAULT_ALLOW_ONLY_CONTRIBUTORS_TO_TRACK_TIME").MustBool(true)
  1140. Service.NoReplyAddress = sec.Key("NO_REPLY_ADDRESS").MustString("noreply.example.org")
  1141. Service.EnableUserHeatmap = sec.Key("ENABLE_USER_HEATMAP").MustBool(true)
  1142. sec = Cfg.Section("openid")
  1143. Service.EnableOpenIDSignIn = sec.Key("ENABLE_OPENID_SIGNIN").MustBool(!InstallLock)
  1144. Service.EnableOpenIDSignUp = sec.Key("ENABLE_OPENID_SIGNUP").MustBool(!Service.DisableRegistration && Service.EnableOpenIDSignIn)
  1145. pats := sec.Key("WHITELISTED_URIS").Strings(" ")
  1146. if len(pats) != 0 {
  1147. Service.OpenIDWhitelist = make([]*regexp.Regexp, len(pats))
  1148. for i, p := range pats {
  1149. Service.OpenIDWhitelist[i] = regexp.MustCompilePOSIX(p)
  1150. }
  1151. }
  1152. pats = sec.Key("BLACKLISTED_URIS").Strings(" ")
  1153. if len(pats) != 0 {
  1154. Service.OpenIDBlacklist = make([]*regexp.Regexp, len(pats))
  1155. for i, p := range pats {
  1156. Service.OpenIDBlacklist[i] = regexp.MustCompilePOSIX(p)
  1157. }
  1158. }
  1159. }
  1160. var logLevels = map[string]string{
  1161. "Trace": "0",
  1162. "Debug": "1",
  1163. "Info": "2",
  1164. "Warn": "3",
  1165. "Error": "4",
  1166. "Critical": "5",
  1167. }
  1168. func getLogLevel(section string, key string, defaultValue string) string {
  1169. validLevels := []string{"Trace", "Debug", "Info", "Warn", "Error", "Critical"}
  1170. return Cfg.Section(section).Key(key).In(defaultValue, validLevels)
  1171. }
  1172. func newLogService() {
  1173. log.Info("Gitea v%s%s", AppVer, AppBuiltWith)
  1174. LogModes = strings.Split(Cfg.Section("log").Key("MODE").MustString("console"), ",")
  1175. LogConfigs = make([]string, len(LogModes))
  1176. useConsole := false
  1177. for i := 0; i < len(LogModes); i++ {
  1178. LogModes[i] = strings.TrimSpace(LogModes[i])
  1179. if LogModes[i] == "console" {
  1180. useConsole = true
  1181. }
  1182. }
  1183. if !useConsole {
  1184. log.DelLogger("console")
  1185. }
  1186. for i, mode := range LogModes {
  1187. sec, err := Cfg.GetSection("log." + mode)
  1188. if err != nil {
  1189. sec, _ = Cfg.NewSection("log." + mode)
  1190. }
  1191. // Log level.
  1192. levelName := getLogLevel("log."+mode, "LEVEL", LogLevel)
  1193. level, ok := logLevels[levelName]
  1194. if !ok {
  1195. log.Fatal(4, "Unknown log level: %s", levelName)
  1196. }
  1197. // Generate log configuration.
  1198. switch mode {
  1199. case "console":
  1200. LogConfigs[i] = fmt.Sprintf(`{"level":%s}`, level)
  1201. case "file":
  1202. logPath := sec.Key("FILE_NAME").MustString(path.Join(LogRootPath, "gitea.log"))
  1203. if err = os.MkdirAll(path.Dir(logPath), os.ModePerm); err != nil {
  1204. panic(err.Error())
  1205. }
  1206. LogConfigs[i] = fmt.Sprintf(
  1207. `{"level":%s,"filename":"%s","rotate":%v,"maxsize":%d,"daily":%v,"maxdays":%d}`, level,
  1208. logPath,
  1209. sec.Key("LOG_ROTATE").MustBool(true),
  1210. 1<<uint(sec.Key("MAX_SIZE_SHIFT").MustInt(28)),
  1211. sec.Key("DAILY_ROTATE").MustBool(true),
  1212. sec.Key("MAX_DAYS").MustInt(7))
  1213. case "conn":
  1214. LogConfigs[i] = fmt.Sprintf(`{"level":%s,"reconnectOnMsg":%v,"reconnect":%v,"net":"%s","addr":"%s"}`, level,
  1215. sec.Key("RECONNECT_ON_MSG").MustBool(),
  1216. sec.Key("RECONNECT").MustBool(),
  1217. sec.Key("PROTOCOL").In("tcp", []string{"tcp", "unix", "udp"}),
  1218. sec.Key("ADDR").MustString(":7020"))
  1219. case "smtp":
  1220. LogConfigs[i] = fmt.Sprintf(`{"level":%s,"username":"%s","password":"%s","host":"%s","sendTos":["%s"],"subject":"%s"}`, level,
  1221. sec.Key("USER").MustString("example@example.com"),
  1222. sec.Key("PASSWD").MustString("******"),
  1223. sec.Key("HOST").MustString("127.0.0.1:25"),
  1224. strings.Replace(sec.Key("RECEIVERS").MustString("example@example.com"), ",", "\",\"", -1),
  1225. sec.Key("SUBJECT").MustString("Diagnostic message from serve"))
  1226. case "database":
  1227. LogConfigs[i] = fmt.Sprintf(`{"level":%s,"driver":"%s","conn":"%s"}`, level,
  1228. sec.Key("DRIVER").String(),
  1229. sec.Key("CONN").String())
  1230. }
  1231. log.NewLogger(Cfg.Section("log").Key("BUFFER_LEN").MustInt64(10000), mode, LogConfigs[i])
  1232. log.Info("Log Mode: %s(%s)", strings.Title(mode), levelName)
  1233. }
  1234. }
  1235. // NewXORMLogService initializes xorm logger service
  1236. func NewXORMLogService(disableConsole bool) {
  1237. logModes := strings.Split(Cfg.Section("log").Key("MODE").MustString("console"), ",")
  1238. var logConfigs string
  1239. for _, mode := range logModes {
  1240. mode = strings.TrimSpace(mode)
  1241. if disableConsole && mode == "console" {
  1242. continue
  1243. }
  1244. sec, err := Cfg.GetSection("log." + mode)
  1245. if err != nil {
  1246. sec, _ = Cfg.NewSection("log." + mode)
  1247. }
  1248. // Log level.
  1249. levelName := getLogLevel("log."+mode, "LEVEL", LogLevel)
  1250. level, ok := logLevels[levelName]
  1251. if !ok {
  1252. log.Fatal(4, "Unknown log level: %s", levelName)
  1253. }
  1254. // Generate log configuration.
  1255. switch mode {
  1256. case "console":
  1257. logConfigs = fmt.Sprintf(`{"level":%s}`, level)
  1258. case "file":
  1259. logPath := sec.Key("FILE_NAME").MustString(path.Join(LogRootPath, "xorm.log"))
  1260. if err = os.MkdirAll(path.Dir(logPath), os.ModePerm); err != nil {
  1261. panic(err.Error())
  1262. }
  1263. logPath = path.Join(filepath.Dir(logPath), "xorm.log")
  1264. logConfigs = fmt.Sprintf(
  1265. `{"level":%s,"filename":"%s","rotate":%v,"maxsize":%d,"daily":%v,"maxdays":%d}`, level,
  1266. logPath,
  1267. sec.Key("LOG_ROTATE").MustBool(true),
  1268. 1<<uint(sec.Key("MAX_SIZE_SHIFT").MustInt(28)),
  1269. sec.Key("DAILY_ROTATE").MustBool(true),
  1270. sec.Key("MAX_DAYS").MustInt(7))
  1271. case "conn":
  1272. logConfigs = fmt.Sprintf(`{"level":%s,"reconnectOnMsg":%v,"reconnect":%v,"net":"%s","addr":"%s"}`, level,
  1273. sec.Key("RECONNECT_ON_MSG").MustBool(),
  1274. sec.Key("RECONNECT").MustBool(),
  1275. sec.Key("PROTOCOL").In("tcp", []string{"tcp", "unix", "udp"}),
  1276. sec.Key("ADDR").MustString(":7020"))
  1277. case "smtp":
  1278. logConfigs = fmt.Sprintf(`{"level":%s,"username":"%s","password":"%s","host":"%s","sendTos":"%s","subject":"%s"}`, level,
  1279. sec.Key("USER").MustString("example@example.com"),
  1280. sec.Key("PASSWD").MustString("******"),
  1281. sec.Key("HOST").MustString("127.0.0.1:25"),
  1282. sec.Key("RECEIVERS").MustString("[]"),
  1283. sec.Key("SUBJECT").MustString("Diagnostic message from serve"))
  1284. case "database":
  1285. logConfigs = fmt.Sprintf(`{"level":%s,"driver":"%s","conn":"%s"}`, level,
  1286. sec.Key("DRIVER").String(),
  1287. sec.Key("CONN").String())
  1288. }
  1289. log.NewXORMLogger(Cfg.Section("log").Key("BUFFER_LEN").MustInt64(10000), mode, logConfigs)
  1290. if !disableConsole {
  1291. log.Info("XORM Log Mode: %s(%s)", strings.Title(mode), levelName)
  1292. }
  1293. var lvl core.LogLevel
  1294. switch levelName {
  1295. case "Trace", "Debug":
  1296. lvl = core.LOG_DEBUG
  1297. case "Info":
  1298. lvl = core.LOG_INFO
  1299. case "Warn":
  1300. lvl = core.LOG_WARNING
  1301. case "Error", "Critical":
  1302. lvl = core.LOG_ERR
  1303. }
  1304. log.XORMLogger.SetLevel(lvl)
  1305. }
  1306. if len(logConfigs) == 0 {
  1307. log.DiscardXORMLogger()
  1308. }
  1309. }
  1310. // Cache represents cache settings
  1311. type Cache struct {
  1312. Adapter string
  1313. Interval int
  1314. Conn string
  1315. TTL time.Duration
  1316. }
  1317. var (
  1318. // CacheService the global cache
  1319. CacheService *Cache
  1320. )
  1321. func newCacheService() {
  1322. sec := Cfg.Section("cache")
  1323. CacheService = &Cache{
  1324. Adapter: sec.Key("ADAPTER").In("memory", []string{"memory", "redis", "memcache"}),
  1325. }
  1326. switch CacheService.Adapter {
  1327. case "memory":
  1328. CacheService.Interval = sec.Key("INTERVAL").MustInt(60)
  1329. case "redis", "memcache":
  1330. CacheService.Conn = strings.Trim(sec.Key("HOST").String(), "\" ")
  1331. default:
  1332. log.Fatal(4, "Unknown cache adapter: %s", CacheService.Adapter)
  1333. }
  1334. CacheService.TTL = sec.Key("ITEM_TTL").MustDuration(16 * time.Hour)
  1335. log.Info("Cache Service Enabled")
  1336. }
  1337. func newSessionService() {
  1338. SessionConfig.Provider = Cfg.Section("session").Key("PROVIDER").In("memory",
  1339. []string{"memory", "file", "redis", "mysql"})
  1340. SessionConfig.ProviderConfig = strings.Trim(Cfg.Section("session").Key("PROVIDER_CONFIG").MustString(path.Join(AppDataPath, "sessions")), "\" ")
  1341. if SessionConfig.Provider == "file" && !filepath.IsAbs(SessionConfig.ProviderConfig) {
  1342. SessionConfig.ProviderConfig = path.Join(AppWorkPath, SessionConfig.ProviderConfig)
  1343. }
  1344. SessionConfig.CookieName = Cfg.Section("session").Key("COOKIE_NAME").MustString("i_like_gitea")
  1345. SessionConfig.CookiePath = AppSubURL
  1346. SessionConfig.Secure = Cfg.Section("session").Key("COOKIE_SECURE").MustBool(false)
  1347. SessionConfig.Gclifetime = Cfg.Section("session").Key("GC_INTERVAL_TIME").MustInt64(86400)
  1348. SessionConfig.Maxlifetime = Cfg.Section("session").Key("SESSION_LIFE_TIME").MustInt64(86400)
  1349. log.Info("Session Service Enabled")
  1350. }
  1351. // Mailer represents mail service.
  1352. type Mailer struct {
  1353. // Mailer
  1354. QueueLength int
  1355. Name string
  1356. From string
  1357. FromName string
  1358. FromEmail string
  1359. SendAsPlainText bool
  1360. // SMTP sender
  1361. Host string
  1362. User, Passwd string
  1363. DisableHelo bool
  1364. HeloHostname string
  1365. SkipVerify bool
  1366. UseCertificate bool
  1367. CertFile, KeyFile string
  1368. IsTLSEnabled bool
  1369. // Sendmail sender
  1370. UseSendmail bool
  1371. SendmailPath string
  1372. SendmailArgs []string
  1373. }
  1374. var (
  1375. // MailService the global mailer
  1376. MailService *Mailer
  1377. )
  1378. func newMailService() {
  1379. sec := Cfg.Section("mailer")
  1380. // Check mailer setting.
  1381. if !sec.Key("ENABLED").MustBool() {
  1382. return
  1383. }
  1384. MailService = &Mailer{
  1385. QueueLength: sec.Key("SEND_BUFFER_LEN").MustInt(100),
  1386. Name: sec.Key("NAME").MustString(AppName),
  1387. SendAsPlainText: sec.Key("SEND_AS_PLAIN_TEXT").MustBool(false),
  1388. Host: sec.Key("HOST").String(),
  1389. User: sec.Key("USER").String(),
  1390. Passwd: sec.Key("PASSWD").String(),
  1391. DisableHelo: sec.Key("DISABLE_HELO").MustBool(),
  1392. HeloHostname: sec.Key("HELO_HOSTNAME").String(),
  1393. SkipVerify: sec.Key("SKIP_VERIFY").MustBool(),
  1394. UseCertificate: sec.Key("USE_CERTIFICATE").MustBool(),
  1395. CertFile: sec.Key("CERT_FILE").String(),
  1396. KeyFile: sec.Key("KEY_FILE").String(),
  1397. IsTLSEnabled: sec.Key("IS_TLS_ENABLED").MustBool(),
  1398. UseSendmail: sec.Key("USE_SENDMAIL").MustBool(),
  1399. SendmailPath: sec.Key("SENDMAIL_PATH").MustString("sendmail"),
  1400. }
  1401. MailService.From = sec.Key("FROM").MustString(MailService.User)
  1402. if sec.HasKey("ENABLE_HTML_ALTERNATIVE") {
  1403. log.Warn("ENABLE_HTML_ALTERNATIVE is deprecated, use SEND_AS_PLAIN_TEXT")
  1404. MailService.SendAsPlainText = !sec.Key("ENABLE_HTML_ALTERNATIVE").MustBool(false)
  1405. }
  1406. parsed, err := mail.ParseAddress(MailService.From)
  1407. if err != nil {
  1408. log.Fatal(4, "Invalid mailer.FROM (%s): %v", MailService.From, err)
  1409. }
  1410. MailService.FromName = parsed.Name
  1411. MailService.FromEmail = parsed.Address
  1412. if MailService.UseSendmail {
  1413. MailService.SendmailArgs, err = shellquote.Split(sec.Key("SENDMAIL_ARGS").String())
  1414. if err != nil {
  1415. log.Error(4, "Failed to parse Sendmail args: %v", CustomConf, err)
  1416. }
  1417. }
  1418. log.Info("Mail Service Enabled")
  1419. }
  1420. func newRegisterMailService() {
  1421. if !Cfg.Section("service").Key("REGISTER_EMAIL_CONFIRM").MustBool() {
  1422. return
  1423. } else if MailService == nil {
  1424. log.Warn("Register Mail Service: Mail Service is not enabled")
  1425. return
  1426. }
  1427. Service.RegisterEmailConfirm = true
  1428. log.Info("Register Mail Service Enabled")
  1429. }
  1430. func newNotifyMailService() {
  1431. if !Cfg.Section("service").Key("ENABLE_NOTIFY_MAIL").MustBool() {
  1432. return
  1433. } else if MailService == nil {
  1434. log.Warn("Notify Mail Service: Mail Service is not enabled")
  1435. return
  1436. }
  1437. Service.EnableNotifyMail = true
  1438. log.Info("Notify Mail Service Enabled")
  1439. }
  1440. func newWebhookService() {
  1441. sec := Cfg.Section("webhook")
  1442. Webhook.QueueLength = sec.Key("QUEUE_LENGTH").MustInt(1000)
  1443. Webhook.DeliverTimeout = sec.Key("DELIVER_TIMEOUT").MustInt(5)
  1444. Webhook.SkipTLSVerify = sec.Key("SKIP_TLS_VERIFY").MustBool()
  1445. Webhook.Types = []string{"gitea", "gogs", "slack", "discord", "dingtalk"}
  1446. Webhook.PagingNum = sec.Key("PAGING_NUM").MustInt(10)
  1447. }
  1448. // NewServices initializes the services
  1449. func NewServices() {
  1450. newService()
  1451. newLogService()
  1452. NewXORMLogService(false)
  1453. newCacheService()
  1454. newSessionService()
  1455. newMailService()
  1456. newRegisterMailService()
  1457. newNotifyMailService()
  1458. newWebhookService()
  1459. }