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