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