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