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

1283 lines
39 KiB

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
7 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
7 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
9 years ago
9 years ago
9 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
7 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
7 years ago
10 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>
5 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>
5 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
8 years ago
10 years ago
8 years ago
10 years ago
10 years ago
10 years ago
8 years ago
10 years ago
10 years ago
8 years ago
8 years ago
9 years ago
10 years ago
9 years ago
10 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
Git LFS support v2 (#122) * Import github.com/git-lfs/lfs-test-server as lfs module base Imported commit is 3968aac269a77b73924649b9412ae03f7ccd3198 Removed: Dockerfile CONTRIBUTING.md mgmt* script/ vendor/ kvlogger.go .dockerignore .gitignore README.md * Remove config, add JWT support from github.com/mgit-at/lfs-test-server Imported commit f0cdcc5a01599c5a955dc1bbf683bb4acecdba83 * Add LFS settings * Add LFS meta object model * Add LFS routes and initialization * Import github.com/dgrijalva/jwt-go into vendor/ * Adapt LFS module: handlers, routing, meta store * Move LFS routes to /user/repo/info/lfs/* * Add request header checks to LFS BatchHandler / PostHandler * Implement LFS basic authentication * Rework JWT secret generation / load * Implement LFS SSH token authentication with JWT Specification: https://github.com/github/git-lfs/tree/master/docs/api * Integrate LFS settings into install process * Remove LFS objects when repository is deleted Only removes objects from content store when deleted repo is the only referencing repository * Make LFS module stateless Fixes bug where LFS would not work after installation without restarting Gitea * Change 500 'Internal Server Error' to 400 'Bad Request' * Change sql query to xorm call * Remove unneeded type from LFS module * Change internal imports to code.gitea.io/gitea/ * Add Gitea authors copyright * Change basic auth realm to "gitea-lfs" * Add unique indexes to LFS model * Use xorm count function in LFS check on repository delete * Return io.ReadCloser from content store and close after usage * Add LFS info to runWeb() * Export LFS content store base path * LFS file download from UI * Work around git-lfs client issue with unauthenticated requests Returning a dummy Authorization header for unauthenticated requests lets git-lfs client skip asking for auth credentials See: https://github.com/github/git-lfs/issues/1088 * Fix unauthenticated UI downloads from public repositories * Authentication check order, Finish LFS file view logic * Ignore LFS hooks if installed for current OS user Fixes Gitea UI actions for repositories tracking LFS files. Checks for minimum needed git version by parsing the semantic version string. * Hide LFS metafile diff from commit view, marking as binary * Show LFS notice if file in commit view is tracked * Add notbefore/nbf JWT claim * Correct lint suggestions - comments for structs and functions - Add comments to LFS model - Function comment for GetRandomBytesAsBase64 - LFS server function comments and lint variable suggestion * Move secret generation code out of conditional Ensures no LFS code may run with an empty secret * Do not hand out JWT tokens if LFS server support is disabled
7 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
7 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
7 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
7 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
7 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
7 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
7 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
7 years ago
9 years ago
9 years ago
9 years ago
10 years ago
10 years ago
9 years ago
9 years ago
10 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
7 years ago
9 years ago
9 years ago
Add support for federated avatars (#3320) * Add support for federated avatars Fixes #3105 Removes avatar fetching duplication code Adds an "Enable Federated Avatar" checkbox in user settings (defaults to unchecked) Moves avatar settings all in the same form, making local and remote avatars mutually exclusive Renames UploadAvatarForm to AvatarForm as it's not anymore only for uploading * Run gofmt on all modified files * Move Avatar form in its own page * Add go-libravatar dependency to vendor/ dir Hopefully helps with accepting the contribution. See also #3214 * Revert "Add go-libravatar dependency to vendor/ dir" This reverts commit a8cb93ae640bbb90f7d25012fc257bda9fae9b82. * Make federated avatar setting a global configuration Removes the per-user setting * Move avatar handling back to base tool, disable federated avatar in offline mode * Format, handle error * Properly set fallback host * Use unsupported github.com mirror for importing go-libravatar * Remove comment showing life exists outside of github.com ... pity, but contribution would not be accepted otherwise * Use Combo for Get and Post methods over /avatar * FEDERATED_AVATAR -> ENABLE_FEDERATED_AVATAR * Fix persistance of federated avatar lookup checkbox at install time * Federated Avatars -> Enable Federated Avatars * Use len(string) == 0 instead of string == "" * Move import line where it belong See https://github.com/Unknwon/go-code-convention/blob/master/en-US/import_packages.md Pity the import url is still the unofficial one, but oh well... * Save a line (and waste much more expensive time) * Remove redundant parens * Remove an empty line * Remove empty lines * Reorder lines to make diff smaller * Remove another newline Unknwon review got me start a fight against newlines * Move DISABLE_GRAVATAR and ENABLE_FEDERATED_AVATAR after OFFLINE_MODE On re-reading the diff I figured what Unknwon meant here: https://github.com/gogits/gogs/pull/3320/files#r73741106 * Remove newlines that weren't there before my intervention
7 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
7 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
7 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
7 years ago
9 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
  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. "net"
  9. "net/url"
  10. "os"
  11. "os/exec"
  12. "path"
  13. "path/filepath"
  14. "regexp"
  15. "runtime"
  16. "strconv"
  17. "strings"
  18. "time"
  19. "code.gitea.io/git"
  20. "code.gitea.io/gitea/modules/generate"
  21. "code.gitea.io/gitea/modules/log"
  22. _ "code.gitea.io/gitea/modules/minwinsvc" // import minwinsvc for windows services
  23. "code.gitea.io/gitea/modules/user"
  24. "github.com/Unknwon/com"
  25. _ "github.com/go-macaron/cache/memcache" // memcache plugin for cache
  26. _ "github.com/go-macaron/cache/redis"
  27. _ "github.com/go-macaron/session/couchbase" // couchbase plugin for session store
  28. _ "github.com/go-macaron/session/memcache" // memcache plugin for session store
  29. _ "github.com/go-macaron/session/mysql" // mysql plugin for session store
  30. _ "github.com/go-macaron/session/nodb" // nodb plugin for session store
  31. _ "github.com/go-macaron/session/postgres" // postgres plugin for session store
  32. _ "github.com/go-macaron/session/redis" // redis plugin for store session
  33. shellquote "github.com/kballard/go-shellquote"
  34. version "github.com/mcuadros/go-version"
  35. ini "gopkg.in/ini.v1"
  36. "strk.kbt.io/projects/go/libravatar"
  37. )
  38. // Scheme describes protocol types
  39. type Scheme string
  40. // enumerates all the scheme types
  41. const (
  42. HTTP Scheme = "http"
  43. HTTPS Scheme = "https"
  44. FCGI Scheme = "fcgi"
  45. UnixSocket Scheme = "unix"
  46. )
  47. // LandingPage describes the default page
  48. type LandingPage string
  49. // enumerates all the landing page types
  50. const (
  51. LandingPageHome LandingPage = "/"
  52. LandingPageExplore LandingPage = "/explore"
  53. LandingPageOrganizations LandingPage = "/explore/organizations"
  54. )
  55. // MarkupParser defines the external parser configured in ini
  56. type MarkupParser struct {
  57. Enabled bool
  58. MarkupName string
  59. Command string
  60. FileExtensions []string
  61. IsInputFile bool
  62. }
  63. // enumerates all the policy repository creating
  64. const (
  65. RepoCreatingLastUserVisibility = "last"
  66. RepoCreatingPrivate = "private"
  67. RepoCreatingPublic = "public"
  68. )
  69. // enumerates all the types of captchas
  70. const (
  71. ImageCaptcha = "image"
  72. ReCaptcha = "recaptcha"
  73. )
  74. // settings
  75. var (
  76. // AppVer settings
  77. AppVer string
  78. AppBuiltWith string
  79. AppName string
  80. AppURL string
  81. AppSubURL string
  82. AppSubURLDepth int // Number of slashes
  83. AppPath string
  84. AppDataPath string
  85. AppWorkPath string
  86. // Server settings
  87. Protocol Scheme
  88. Domain string
  89. HTTPAddr string
  90. HTTPPort string
  91. LocalURL string
  92. RedirectOtherPort bool
  93. PortToRedirect string
  94. OfflineMode bool
  95. DisableRouterLog bool
  96. CertFile string
  97. KeyFile string
  98. StaticRootPath string
  99. EnableGzip bool
  100. LandingPageURL LandingPage
  101. UnixSocketPermission uint32
  102. EnablePprof bool
  103. PprofDataPath string
  104. EnableLetsEncrypt bool
  105. LetsEncryptTOS bool
  106. LetsEncryptDirectory string
  107. LetsEncryptEmail string
  108. SSH = struct {
  109. Disabled bool `ini:"DISABLE_SSH"`
  110. StartBuiltinServer bool `ini:"START_SSH_SERVER"`
  111. BuiltinServerUser string `ini:"BUILTIN_SSH_SERVER_USER"`
  112. Domain string `ini:"SSH_DOMAIN"`
  113. Port int `ini:"SSH_PORT"`
  114. ListenHost string `ini:"SSH_LISTEN_HOST"`
  115. ListenPort int `ini:"SSH_LISTEN_PORT"`
  116. RootPath string `ini:"SSH_ROOT_PATH"`
  117. ServerCiphers []string `ini:"SSH_SERVER_CIPHERS"`
  118. ServerKeyExchanges []string `ini:"SSH_SERVER_KEY_EXCHANGES"`
  119. ServerMACs []string `ini:"SSH_SERVER_MACS"`
  120. KeyTestPath string `ini:"SSH_KEY_TEST_PATH"`
  121. KeygenPath string `ini:"SSH_KEYGEN_PATH"`
  122. AuthorizedKeysBackup bool `ini:"SSH_AUTHORIZED_KEYS_BACKUP"`
  123. MinimumKeySizeCheck bool `ini:"-"`
  124. MinimumKeySizes map[string]int `ini:"-"`
  125. CreateAuthorizedKeysFile bool `ini:"SSH_CREATE_AUTHORIZED_KEYS_FILE"`
  126. ExposeAnonymous bool `ini:"SSH_EXPOSE_ANONYMOUS"`
  127. }{
  128. Disabled: false,
  129. StartBuiltinServer: false,
  130. Domain: "",
  131. Port: 22,
  132. ServerCiphers: []string{"aes128-ctr", "aes192-ctr", "aes256-ctr", "aes128-gcm@openssh.com", "arcfour256", "arcfour128"},
  133. ServerKeyExchanges: []string{"diffie-hellman-group1-sha1", "diffie-hellman-group14-sha1", "ecdh-sha2-nistp256", "ecdh-sha2-nistp384", "ecdh-sha2-nistp521", "curve25519-sha256@libssh.org"},
  134. ServerMACs: []string{"hmac-sha2-256-etm@openssh.com", "hmac-sha2-256", "hmac-sha1", "hmac-sha1-96"},
  135. KeygenPath: "ssh-keygen",
  136. }
  137. LFS struct {
  138. StartServer bool `ini:"LFS_START_SERVER"`
  139. ContentPath string `ini:"LFS_CONTENT_PATH"`
  140. JWTSecretBase64 string `ini:"LFS_JWT_SECRET"`
  141. JWTSecretBytes []byte `ini:"-"`
  142. HTTPAuthExpiry time.Duration `ini:"LFS_HTTP_AUTH_EXPIRY"`
  143. }
  144. // Security settings
  145. InstallLock bool
  146. SecretKey string
  147. LogInRememberDays int
  148. CookieUserName string
  149. CookieRememberName string
  150. ReverseProxyAuthUser string
  151. ReverseProxyAuthEmail string
  152. MinPasswordLength int
  153. ImportLocalPaths bool
  154. DisableGitHooks bool
  155. // Database settings
  156. UseSQLite3 bool
  157. UseMySQL bool
  158. UseMSSQL bool
  159. UsePostgreSQL bool
  160. UseTiDB bool
  161. LogSQL bool
  162. DBConnectRetries int
  163. DBConnectBackoff time.Duration
  164. // Repository settings
  165. Repository = struct {
  166. AnsiCharset string
  167. ForcePrivate bool
  168. DefaultPrivate string
  169. MaxCreationLimit int
  170. MirrorQueueLength int
  171. PullRequestQueueLength int
  172. PreferredLicenses []string
  173. DisableHTTPGit bool
  174. AccessControlAllowOrigin string
  175. UseCompatSSHURI bool
  176. DefaultCloseIssuesViaCommitsInAnyBranch bool
  177. // Repository editor settings
  178. Editor struct {
  179. LineWrapExtensions []string
  180. PreviewableFileModes []string
  181. } `ini:"-"`
  182. // Repository upload settings
  183. Upload struct {
  184. Enabled bool
  185. TempPath string
  186. AllowedTypes []string `delim:"|"`
  187. FileMaxSize int64
  188. MaxFiles int
  189. } `ini:"-"`
  190. // Repository local settings
  191. Local struct {
  192. LocalCopyPath string
  193. LocalWikiPath string
  194. } `ini:"-"`
  195. // Pull request settings
  196. PullRequest struct {
  197. WorkInProgressPrefixes []string
  198. } `ini:"repository.pull-request"`
  199. // Issue Setting
  200. Issue struct {
  201. LockReasons []string
  202. } `ini:"repository.issue"`
  203. }{
  204. AnsiCharset: "",
  205. ForcePrivate: false,
  206. DefaultPrivate: RepoCreatingLastUserVisibility,
  207. MaxCreationLimit: -1,
  208. MirrorQueueLength: 1000,
  209. PullRequestQueueLength: 1000,
  210. PreferredLicenses: []string{"Apache License 2.0,MIT License"},
  211. DisableHTTPGit: false,
  212. AccessControlAllowOrigin: "",
  213. UseCompatSSHURI: false,
  214. DefaultCloseIssuesViaCommitsInAnyBranch: false,
  215. // Repository editor settings
  216. Editor: struct {
  217. LineWrapExtensions []string
  218. PreviewableFileModes []string
  219. }{
  220. LineWrapExtensions: strings.Split(".txt,.md,.markdown,.mdown,.mkd,", ","),
  221. PreviewableFileModes: []string{"markdown"},
  222. },
  223. // Repository upload settings
  224. Upload: struct {
  225. Enabled bool
  226. TempPath string
  227. AllowedTypes []string `delim:"|"`
  228. FileMaxSize int64
  229. MaxFiles int
  230. }{
  231. Enabled: true,
  232. TempPath: "data/tmp/uploads",
  233. AllowedTypes: []string{},
  234. FileMaxSize: 3,
  235. MaxFiles: 5,
  236. },
  237. // Repository local settings
  238. Local: struct {
  239. LocalCopyPath string
  240. LocalWikiPath string
  241. }{
  242. LocalCopyPath: "tmp/local-repo",
  243. LocalWikiPath: "tmp/local-wiki",
  244. },
  245. // Pull request settings
  246. PullRequest: struct {
  247. WorkInProgressPrefixes []string
  248. }{
  249. WorkInProgressPrefixes: []string{"WIP:", "[WIP]"},
  250. },
  251. // Issue settings
  252. Issue: struct {
  253. LockReasons []string
  254. }{
  255. LockReasons: strings.Split("Too heated,Off-topic,Spam,Resolved", ","),
  256. },
  257. }
  258. RepoRootPath string
  259. ScriptType = "bash"
  260. // UI settings
  261. UI = struct {
  262. ExplorePagingNum int
  263. IssuePagingNum int
  264. RepoSearchPagingNum int
  265. FeedMaxCommitNum int
  266. GraphMaxCommitNum int
  267. CodeCommentLines int
  268. ReactionMaxUserNum int
  269. ThemeColorMetaTag string
  270. MaxDisplayFileSize int64
  271. ShowUserEmail bool
  272. DefaultTheme string
  273. Themes []string
  274. Admin struct {
  275. UserPagingNum int
  276. RepoPagingNum int
  277. NoticePagingNum int
  278. OrgPagingNum int
  279. } `ini:"ui.admin"`
  280. User struct {
  281. RepoPagingNum int
  282. } `ini:"ui.user"`
  283. Meta struct {
  284. Author string
  285. Description string
  286. Keywords string
  287. } `ini:"ui.meta"`
  288. }{
  289. ExplorePagingNum: 20,
  290. IssuePagingNum: 10,
  291. RepoSearchPagingNum: 10,
  292. FeedMaxCommitNum: 5,
  293. GraphMaxCommitNum: 100,
  294. CodeCommentLines: 4,
  295. ReactionMaxUserNum: 10,
  296. ThemeColorMetaTag: `#6cc644`,
  297. MaxDisplayFileSize: 8388608,
  298. DefaultTheme: `gitea`,
  299. Themes: []string{`gitea`, `arc-green`},
  300. Admin: struct {
  301. UserPagingNum int
  302. RepoPagingNum int
  303. NoticePagingNum int
  304. OrgPagingNum int
  305. }{
  306. UserPagingNum: 50,
  307. RepoPagingNum: 50,
  308. NoticePagingNum: 25,
  309. OrgPagingNum: 50,
  310. },
  311. User: struct {
  312. RepoPagingNum int
  313. }{
  314. RepoPagingNum: 15,
  315. },
  316. Meta: struct {
  317. Author string
  318. Description string
  319. Keywords string
  320. }{
  321. Author: "Gitea - Git with a cup of tea",
  322. Description: "Gitea (Git with a cup of tea) is a painless self-hosted Git service written in Go",
  323. Keywords: "go,git,self-hosted,gitea",
  324. },
  325. }
  326. // Markdown settings
  327. Markdown = struct {
  328. EnableHardLineBreak bool
  329. CustomURLSchemes []string `ini:"CUSTOM_URL_SCHEMES"`
  330. FileExtensions []string
  331. }{
  332. EnableHardLineBreak: false,
  333. FileExtensions: strings.Split(".md,.markdown,.mdown,.mkd", ","),
  334. }
  335. // Admin settings
  336. Admin struct {
  337. DisableRegularOrgCreation bool
  338. }
  339. // Picture settings
  340. AvatarUploadPath string
  341. AvatarMaxWidth int
  342. AvatarMaxHeight int
  343. GravatarSource string
  344. GravatarSourceURL *url.URL
  345. DisableGravatar bool
  346. EnableFederatedAvatar bool
  347. LibravatarService *libravatar.Libravatar
  348. // Log settings
  349. LogLevel string
  350. LogRootPath string
  351. LogModes []string
  352. LogConfigs []string
  353. RedirectMacaronLog bool
  354. // Attachment settings
  355. AttachmentPath string
  356. AttachmentAllowedTypes string
  357. AttachmentMaxSize int64
  358. AttachmentMaxFiles int
  359. AttachmentEnabled bool
  360. // Time settings
  361. TimeFormat string
  362. CSRFCookieName = "_csrf"
  363. // Cron tasks
  364. Cron = struct {
  365. UpdateMirror struct {
  366. Enabled bool
  367. RunAtStart bool
  368. Schedule string
  369. } `ini:"cron.update_mirrors"`
  370. RepoHealthCheck struct {
  371. Enabled bool
  372. RunAtStart bool
  373. Schedule string
  374. Timeout time.Duration
  375. Args []string `delim:" "`
  376. } `ini:"cron.repo_health_check"`
  377. CheckRepoStats struct {
  378. Enabled bool
  379. RunAtStart bool
  380. Schedule string
  381. } `ini:"cron.check_repo_stats"`
  382. ArchiveCleanup struct {
  383. Enabled bool
  384. RunAtStart bool
  385. Schedule string
  386. OlderThan time.Duration
  387. } `ini:"cron.archive_cleanup"`
  388. SyncExternalUsers struct {
  389. Enabled bool
  390. RunAtStart bool
  391. Schedule string
  392. UpdateExisting bool
  393. } `ini:"cron.sync_external_users"`
  394. DeletedBranchesCleanup struct {
  395. Enabled bool
  396. RunAtStart bool
  397. Schedule string
  398. OlderThan time.Duration
  399. } `ini:"cron.deleted_branches_cleanup"`
  400. }{
  401. UpdateMirror: struct {
  402. Enabled bool
  403. RunAtStart bool
  404. Schedule string
  405. }{
  406. Enabled: true,
  407. RunAtStart: false,
  408. Schedule: "@every 10m",
  409. },
  410. RepoHealthCheck: struct {
  411. Enabled bool
  412. RunAtStart bool
  413. Schedule string
  414. Timeout time.Duration
  415. Args []string `delim:" "`
  416. }{
  417. Enabled: true,
  418. RunAtStart: false,
  419. Schedule: "@every 24h",
  420. Timeout: 60 * time.Second,
  421. Args: []string{},
  422. },
  423. CheckRepoStats: struct {
  424. Enabled bool
  425. RunAtStart bool
  426. Schedule string
  427. }{
  428. Enabled: true,
  429. RunAtStart: true,
  430. Schedule: "@every 24h",
  431. },
  432. ArchiveCleanup: struct {
  433. Enabled bool
  434. RunAtStart bool
  435. Schedule string
  436. OlderThan time.Duration
  437. }{
  438. Enabled: true,
  439. RunAtStart: true,
  440. Schedule: "@every 24h",
  441. OlderThan: 24 * time.Hour,
  442. },
  443. SyncExternalUsers: struct {
  444. Enabled bool
  445. RunAtStart bool
  446. Schedule string
  447. UpdateExisting bool
  448. }{
  449. Enabled: true,
  450. RunAtStart: false,
  451. Schedule: "@every 24h",
  452. UpdateExisting: true,
  453. },
  454. DeletedBranchesCleanup: struct {
  455. Enabled bool
  456. RunAtStart bool
  457. Schedule string
  458. OlderThan time.Duration
  459. }{
  460. Enabled: true,
  461. RunAtStart: true,
  462. Schedule: "@every 24h",
  463. OlderThan: 24 * time.Hour,
  464. },
  465. }
  466. // Git settings
  467. Git = struct {
  468. Version string `ini:"-"`
  469. DisableDiffHighlight bool
  470. MaxGitDiffLines int
  471. MaxGitDiffLineCharacters int
  472. MaxGitDiffFiles int
  473. GCArgs []string `delim:" "`
  474. Timeout struct {
  475. Default int
  476. Migrate int
  477. Mirror int
  478. Clone int
  479. Pull int
  480. GC int `ini:"GC"`
  481. } `ini:"git.timeout"`
  482. }{
  483. DisableDiffHighlight: false,
  484. MaxGitDiffLines: 1000,
  485. MaxGitDiffLineCharacters: 5000,
  486. MaxGitDiffFiles: 100,
  487. GCArgs: []string{},
  488. Timeout: struct {
  489. Default int
  490. Migrate int
  491. Mirror int
  492. Clone int
  493. Pull int
  494. GC int `ini:"GC"`
  495. }{
  496. Default: int(git.DefaultCommandExecutionTimeout / time.Second),
  497. Migrate: 600,
  498. Mirror: 300,
  499. Clone: 300,
  500. Pull: 300,
  501. GC: 60,
  502. },
  503. }
  504. // Mirror settings
  505. Mirror struct {
  506. DefaultInterval time.Duration
  507. MinInterval time.Duration
  508. }
  509. // API settings
  510. API = struct {
  511. EnableSwagger bool
  512. MaxResponseItems int
  513. DefaultPagingNum int
  514. DefaultGitTreesPerPage int
  515. }{
  516. EnableSwagger: true,
  517. MaxResponseItems: 50,
  518. DefaultPagingNum: 30,
  519. DefaultGitTreesPerPage: 1000,
  520. }
  521. OAuth2 = struct {
  522. Enable bool
  523. AccessTokenExpirationTime int64
  524. RefreshTokenExpirationTime int64
  525. JWTSecretBytes []byte `ini:"-"`
  526. JWTSecretBase64 string `ini:"JWT_SECRET"`
  527. }{
  528. Enable: true,
  529. AccessTokenExpirationTime: 3600,
  530. RefreshTokenExpirationTime: 730,
  531. }
  532. U2F = struct {
  533. AppID string
  534. TrustedFacets []string
  535. }{}
  536. // Metrics settings
  537. Metrics = struct {
  538. Enabled bool
  539. Token string
  540. }{
  541. Enabled: false,
  542. Token: "",
  543. }
  544. // I18n settings
  545. Langs []string
  546. Names []string
  547. dateLangs map[string]string
  548. // Highlight settings are loaded in modules/template/highlight.go
  549. // Other settings
  550. ShowFooterBranding bool
  551. ShowFooterVersion bool
  552. ShowFooterTemplateLoadTime bool
  553. // Global setting objects
  554. Cfg *ini.File
  555. CustomPath string // Custom directory path
  556. CustomConf string
  557. CustomPID string
  558. ProdMode bool
  559. RunUser string
  560. IsWindows bool
  561. HasRobotsTxt bool
  562. InternalToken string // internal access token
  563. IterateBufferSize int
  564. ExternalMarkupParsers []MarkupParser
  565. // UILocation is the location on the UI, so that we can display the time on UI.
  566. // Currently only show the default time.Local, it could be added to app.ini after UI is ready
  567. UILocation = time.Local
  568. )
  569. // DateLang transforms standard language locale name to corresponding value in datetime plugin.
  570. func DateLang(lang string) string {
  571. name, ok := dateLangs[lang]
  572. if ok {
  573. return name
  574. }
  575. return "en"
  576. }
  577. func getAppPath() (string, error) {
  578. var appPath string
  579. var err error
  580. if IsWindows && filepath.IsAbs(os.Args[0]) {
  581. appPath = filepath.Clean(os.Args[0])
  582. } else {
  583. appPath, err = exec.LookPath(os.Args[0])
  584. }
  585. if err != nil {
  586. return "", err
  587. }
  588. appPath, err = filepath.Abs(appPath)
  589. if err != nil {
  590. return "", err
  591. }
  592. // Note: we don't use path.Dir here because it does not handle case
  593. // which path starts with two "/" in Windows: "//psf/Home/..."
  594. return strings.Replace(appPath, "\\", "/", -1), err
  595. }
  596. func getWorkPath(appPath string) string {
  597. workPath := ""
  598. giteaWorkPath := os.Getenv("GITEA_WORK_DIR")
  599. if len(giteaWorkPath) > 0 {
  600. workPath = giteaWorkPath
  601. } else {
  602. i := strings.LastIndex(appPath, "/")
  603. if i == -1 {
  604. workPath = appPath
  605. } else {
  606. workPath = appPath[:i]
  607. }
  608. }
  609. return strings.Replace(workPath, "\\", "/", -1)
  610. }
  611. func init() {
  612. IsWindows = runtime.GOOS == "windows"
  613. log.NewLogger(0, "console", `{"level": 0}`)
  614. var err error
  615. if AppPath, err = getAppPath(); err != nil {
  616. log.Fatal(4, "Failed to get app path: %v", err)
  617. }
  618. AppWorkPath = getWorkPath(AppPath)
  619. }
  620. func forcePathSeparator(path string) {
  621. if strings.Contains(path, "\\") {
  622. log.Fatal(4, "Do not use '\\' or '\\\\' in paths, instead, please use '/' in all places")
  623. }
  624. }
  625. // IsRunUserMatchCurrentUser returns false if configured run user does not match
  626. // actual user that runs the app. The first return value is the actual user name.
  627. // This check is ignored under Windows since SSH remote login is not the main
  628. // method to login on Windows.
  629. func IsRunUserMatchCurrentUser(runUser string) (string, bool) {
  630. if IsWindows {
  631. return "", true
  632. }
  633. currentUser := user.CurrentUsername()
  634. return currentUser, runUser == currentUser
  635. }
  636. func createPIDFile(pidPath string) {
  637. currentPid := os.Getpid()
  638. if err := os.MkdirAll(filepath.Dir(pidPath), os.ModePerm); err != nil {
  639. log.Fatal(4, "Failed to create PID folder: %v", err)
  640. }
  641. file, err := os.Create(pidPath)
  642. if err != nil {
  643. log.Fatal(4, "Failed to create PID file: %v", err)
  644. }
  645. defer file.Close()
  646. if _, err := file.WriteString(strconv.FormatInt(int64(currentPid), 10)); err != nil {
  647. log.Fatal(4, "Failed to write PID information: %v", err)
  648. }
  649. }
  650. // CheckLFSVersion will check lfs version, if not satisfied, then disable it.
  651. func CheckLFSVersion() {
  652. if LFS.StartServer {
  653. //Disable LFS client hooks if installed for the current OS user
  654. //Needs at least git v2.1.2
  655. binVersion, err := git.BinVersion()
  656. if err != nil {
  657. log.Fatal(4, "Error retrieving git version: %v", err)
  658. }
  659. if !version.Compare(binVersion, "2.1.2", ">=") {
  660. LFS.StartServer = false
  661. log.Error(4, "LFS server support needs at least Git v2.1.2")
  662. } else {
  663. git.GlobalCommandArgs = append(git.GlobalCommandArgs, "-c", "filter.lfs.required=",
  664. "-c", "filter.lfs.smudge=", "-c", "filter.lfs.clean=")
  665. }
  666. }
  667. }
  668. // NewContext initializes configuration context.
  669. // NOTE: do not print any log except error.
  670. func NewContext() {
  671. Cfg = ini.Empty()
  672. CustomPath = os.Getenv("GITEA_CUSTOM")
  673. if len(CustomPath) == 0 {
  674. CustomPath = path.Join(AppWorkPath, "custom")
  675. } else if !filepath.IsAbs(CustomPath) {
  676. CustomPath = path.Join(AppWorkPath, CustomPath)
  677. }
  678. if len(CustomPID) > 0 {
  679. createPIDFile(CustomPID)
  680. }
  681. if len(CustomConf) == 0 {
  682. CustomConf = path.Join(CustomPath, "conf/app.ini")
  683. } else if !filepath.IsAbs(CustomConf) {
  684. CustomConf = path.Join(CustomPath, CustomConf)
  685. }
  686. if com.IsFile(CustomConf) {
  687. if err := Cfg.Append(CustomConf); err != nil {
  688. log.Fatal(4, "Failed to load custom conf '%s': %v", CustomConf, err)
  689. }
  690. } else {
  691. log.Warn("Custom config '%s' not found, ignore this if you're running first time", CustomConf)
  692. }
  693. Cfg.NameMapper = ini.AllCapsUnderscore
  694. homeDir, err := com.HomeDir()
  695. if err != nil {
  696. log.Fatal(4, "Failed to get home directory: %v", err)
  697. }
  698. homeDir = strings.Replace(homeDir, "\\", "/", -1)
  699. LogLevel = getLogLevel("log", "LEVEL", "Info")
  700. LogRootPath = Cfg.Section("log").Key("ROOT_PATH").MustString(path.Join(AppWorkPath, "log"))
  701. forcePathSeparator(LogRootPath)
  702. RedirectMacaronLog = Cfg.Section("log").Key("REDIRECT_MACARON_LOG").MustBool(false)
  703. sec := Cfg.Section("server")
  704. AppName = Cfg.Section("").Key("APP_NAME").MustString("Gitea: Git with a cup of tea")
  705. Protocol = HTTP
  706. if sec.Key("PROTOCOL").String() == "https" {
  707. Protocol = HTTPS
  708. CertFile = sec.Key("CERT_FILE").String()
  709. KeyFile = sec.Key("KEY_FILE").String()
  710. } else if sec.Key("PROTOCOL").String() == "fcgi" {
  711. Protocol = FCGI
  712. } else if sec.Key("PROTOCOL").String() == "unix" {
  713. Protocol = UnixSocket
  714. UnixSocketPermissionRaw := sec.Key("UNIX_SOCKET_PERMISSION").MustString("666")
  715. UnixSocketPermissionParsed, err := strconv.ParseUint(UnixSocketPermissionRaw, 8, 32)
  716. if err != nil || UnixSocketPermissionParsed > 0777 {
  717. log.Fatal(4, "Failed to parse unixSocketPermission: %s", UnixSocketPermissionRaw)
  718. }
  719. UnixSocketPermission = uint32(UnixSocketPermissionParsed)
  720. }
  721. EnableLetsEncrypt = sec.Key("ENABLE_LETSENCRYPT").MustBool(false)
  722. LetsEncryptTOS = sec.Key("LETSENCRYPT_ACCEPTTOS").MustBool(false)
  723. if !LetsEncryptTOS && EnableLetsEncrypt {
  724. log.Warn("Failed to enable Let's Encrypt due to Let's Encrypt TOS not being accepted")
  725. EnableLetsEncrypt = false
  726. }
  727. LetsEncryptDirectory = sec.Key("LETSENCRYPT_DIRECTORY").MustString("https")
  728. LetsEncryptEmail = sec.Key("LETSENCRYPT_EMAIL").MustString("")
  729. Domain = sec.Key("DOMAIN").MustString("localhost")
  730. HTTPAddr = sec.Key("HTTP_ADDR").MustString("0.0.0.0")
  731. HTTPPort = sec.Key("HTTP_PORT").MustString("3000")
  732. defaultAppURL := string(Protocol) + "://" + Domain
  733. if (Protocol == HTTP && HTTPPort != "80") || (Protocol == HTTPS && HTTPPort != "443") {
  734. defaultAppURL += ":" + HTTPPort
  735. }
  736. AppURL = sec.Key("ROOT_URL").MustString(defaultAppURL)
  737. AppURL = strings.TrimRight(AppURL, "/") + "/"
  738. // Check if has app suburl.
  739. url, err := url.Parse(AppURL)
  740. if err != nil {
  741. log.Fatal(4, "Invalid ROOT_URL '%s': %s", AppURL, err)
  742. }
  743. // Suburl should start with '/' and end without '/', such as '/{subpath}'.
  744. // This value is empty if site does not have sub-url.
  745. AppSubURL = strings.TrimSuffix(url.Path, "/")
  746. AppSubURLDepth = strings.Count(AppSubURL, "/")
  747. // Check if Domain differs from AppURL domain than update it to AppURL's domain
  748. // TODO: Can be replaced with url.Hostname() when minimal GoLang version is 1.8
  749. urlHostname := strings.SplitN(url.Host, ":", 2)[0]
  750. if urlHostname != Domain && net.ParseIP(urlHostname) == nil {
  751. Domain = urlHostname
  752. }
  753. var defaultLocalURL string
  754. switch Protocol {
  755. case UnixSocket:
  756. defaultLocalURL = "http://unix/"
  757. case FCGI:
  758. defaultLocalURL = AppURL
  759. default:
  760. defaultLocalURL = string(Protocol) + "://"
  761. if HTTPAddr == "0.0.0.0" {
  762. defaultLocalURL += "localhost"
  763. } else {
  764. defaultLocalURL += HTTPAddr
  765. }
  766. defaultLocalURL += ":" + HTTPPort + "/"
  767. }
  768. LocalURL = sec.Key("LOCAL_ROOT_URL").MustString(defaultLocalURL)
  769. RedirectOtherPort = sec.Key("REDIRECT_OTHER_PORT").MustBool(false)
  770. PortToRedirect = sec.Key("PORT_TO_REDIRECT").MustString("80")
  771. OfflineMode = sec.Key("OFFLINE_MODE").MustBool()
  772. DisableRouterLog = sec.Key("DISABLE_ROUTER_LOG").MustBool()
  773. StaticRootPath = sec.Key("STATIC_ROOT_PATH").MustString(AppWorkPath)
  774. AppDataPath = sec.Key("APP_DATA_PATH").MustString(path.Join(AppWorkPath, "data"))
  775. EnableGzip = sec.Key("ENABLE_GZIP").MustBool()
  776. EnablePprof = sec.Key("ENABLE_PPROF").MustBool(false)
  777. PprofDataPath = sec.Key("PPROF_DATA_PATH").MustString(path.Join(AppWorkPath, "data/tmp/pprof"))
  778. if !filepath.IsAbs(PprofDataPath) {
  779. PprofDataPath = filepath.Join(AppWorkPath, PprofDataPath)
  780. }
  781. switch sec.Key("LANDING_PAGE").MustString("home") {
  782. case "explore":
  783. LandingPageURL = LandingPageExplore
  784. case "organizations":
  785. LandingPageURL = LandingPageOrganizations
  786. default:
  787. LandingPageURL = LandingPageHome
  788. }
  789. if len(SSH.Domain) == 0 {
  790. SSH.Domain = Domain
  791. }
  792. SSH.RootPath = path.Join(homeDir, ".ssh")
  793. serverCiphers := sec.Key("SSH_SERVER_CIPHERS").Strings(",")
  794. if len(serverCiphers) > 0 {
  795. SSH.ServerCiphers = serverCiphers
  796. }
  797. serverKeyExchanges := sec.Key("SSH_SERVER_KEY_EXCHANGES").Strings(",")
  798. if len(serverKeyExchanges) > 0 {
  799. SSH.ServerKeyExchanges = serverKeyExchanges
  800. }
  801. serverMACs := sec.Key("SSH_SERVER_MACS").Strings(",")
  802. if len(serverMACs) > 0 {
  803. SSH.ServerMACs = serverMACs
  804. }
  805. SSH.KeyTestPath = os.TempDir()
  806. if err = Cfg.Section("server").MapTo(&SSH); err != nil {
  807. log.Fatal(4, "Failed to map SSH settings: %v", err)
  808. }
  809. SSH.KeygenPath = sec.Key("SSH_KEYGEN_PATH").MustString("ssh-keygen")
  810. SSH.Port = sec.Key("SSH_PORT").MustInt(22)
  811. SSH.ListenPort = sec.Key("SSH_LISTEN_PORT").MustInt(SSH.Port)
  812. // When disable SSH, start builtin server value is ignored.
  813. if SSH.Disabled {
  814. SSH.StartBuiltinServer = false
  815. }
  816. if !SSH.Disabled && !SSH.StartBuiltinServer {
  817. if err := os.MkdirAll(SSH.RootPath, 0700); err != nil {
  818. log.Fatal(4, "Failed to create '%s': %v", SSH.RootPath, err)
  819. } else if err = os.MkdirAll(SSH.KeyTestPath, 0644); err != nil {
  820. log.Fatal(4, "Failed to create '%s': %v", SSH.KeyTestPath, err)
  821. }
  822. }
  823. SSH.MinimumKeySizeCheck = sec.Key("MINIMUM_KEY_SIZE_CHECK").MustBool()
  824. SSH.MinimumKeySizes = map[string]int{}
  825. minimumKeySizes := Cfg.Section("ssh.minimum_key_sizes").Keys()
  826. for _, key := range minimumKeySizes {
  827. if key.MustInt() != -1 {
  828. SSH.MinimumKeySizes[strings.ToLower(key.Name())] = key.MustInt()
  829. }
  830. }
  831. SSH.AuthorizedKeysBackup = sec.Key("SSH_AUTHORIZED_KEYS_BACKUP").MustBool(true)
  832. SSH.CreateAuthorizedKeysFile = sec.Key("SSH_CREATE_AUTHORIZED_KEYS_FILE").MustBool(true)
  833. SSH.ExposeAnonymous = sec.Key("SSH_EXPOSE_ANONYMOUS").MustBool(false)
  834. sec = Cfg.Section("server")
  835. if err = sec.MapTo(&LFS); err != nil {
  836. log.Fatal(4, "Failed to map LFS settings: %v", err)
  837. }
  838. LFS.ContentPath = sec.Key("LFS_CONTENT_PATH").MustString(filepath.Join(AppDataPath, "lfs"))
  839. if !filepath.IsAbs(LFS.ContentPath) {
  840. LFS.ContentPath = filepath.Join(AppWorkPath, LFS.ContentPath)
  841. }
  842. LFS.HTTPAuthExpiry = sec.Key("LFS_HTTP_AUTH_EXPIRY").MustDuration(20 * time.Minute)
  843. if LFS.StartServer {
  844. if err := os.MkdirAll(LFS.ContentPath, 0700); err != nil {
  845. log.Fatal(4, "Failed to create '%s': %v", LFS.ContentPath, err)
  846. }
  847. LFS.JWTSecretBytes = make([]byte, 32)
  848. n, err := base64.RawURLEncoding.Decode(LFS.JWTSecretBytes, []byte(LFS.JWTSecretBase64))
  849. if err != nil || n != 32 {
  850. LFS.JWTSecretBase64, err = generate.NewJwtSecret()
  851. if err != nil {
  852. log.Fatal(4, "Error generating JWT Secret for custom config: %v", err)
  853. return
  854. }
  855. // Save secret
  856. cfg := ini.Empty()
  857. if com.IsFile(CustomConf) {
  858. // Keeps custom settings if there is already something.
  859. if err := cfg.Append(CustomConf); err != nil {
  860. log.Error(4, "Failed to load custom conf '%s': %v", CustomConf, err)
  861. }
  862. }
  863. cfg.Section("server").Key("LFS_JWT_SECRET").SetValue(LFS.JWTSecretBase64)
  864. if err := os.MkdirAll(filepath.Dir(CustomConf), os.ModePerm); err != nil {
  865. log.Fatal(4, "Failed to create '%s': %v", CustomConf, err)
  866. }
  867. if err := cfg.SaveTo(CustomConf); err != nil {
  868. log.Fatal(4, "Error saving generated JWT Secret to custom config: %v", err)
  869. return
  870. }
  871. }
  872. }
  873. if err = Cfg.Section("oauth2").MapTo(&OAuth2); err != nil {
  874. log.Fatal(4, "Failed to OAuth2 settings: %v", err)
  875. return
  876. }
  877. if OAuth2.Enable {
  878. OAuth2.JWTSecretBytes = make([]byte, 32)
  879. n, err := base64.RawURLEncoding.Decode(OAuth2.JWTSecretBytes, []byte(OAuth2.JWTSecretBase64))
  880. if err != nil || n != 32 {
  881. OAuth2.JWTSecretBase64, err = generate.NewJwtSecret()
  882. if err != nil {
  883. log.Fatal(4, "error generating JWT secret: %v", err)
  884. return
  885. }
  886. cfg := ini.Empty()
  887. if com.IsFile(CustomConf) {
  888. if err := cfg.Append(CustomConf); err != nil {
  889. log.Error(4, "failed to load custom conf %s: %v", CustomConf, err)
  890. return
  891. }
  892. }
  893. cfg.Section("oauth2").Key("JWT_SECRET").SetValue(OAuth2.JWTSecretBase64)
  894. if err := os.MkdirAll(filepath.Dir(CustomConf), os.ModePerm); err != nil {
  895. log.Fatal(4, "failed to create '%s': %v", CustomConf, err)
  896. return
  897. }
  898. if err := cfg.SaveTo(CustomConf); err != nil {
  899. log.Fatal(4, "error saving generating JWT secret to custom config: %v", err)
  900. return
  901. }
  902. }
  903. }
  904. sec = Cfg.Section("security")
  905. InstallLock = sec.Key("INSTALL_LOCK").MustBool(false)
  906. SecretKey = sec.Key("SECRET_KEY").MustString("!#@FDEWREWR&*(")
  907. LogInRememberDays = sec.Key("LOGIN_REMEMBER_DAYS").MustInt(7)
  908. CookieUserName = sec.Key("COOKIE_USERNAME").MustString("gitea_awesome")
  909. CookieRememberName = sec.Key("COOKIE_REMEMBER_NAME").MustString("gitea_incredible")
  910. ReverseProxyAuthUser = sec.Key("REVERSE_PROXY_AUTHENTICATION_USER").MustString("X-WEBAUTH-USER")
  911. ReverseProxyAuthEmail = sec.Key("REVERSE_PROXY_AUTHENTICATION_EMAIL").MustString("X-WEBAUTH-EMAIL")
  912. MinPasswordLength = sec.Key("MIN_PASSWORD_LENGTH").MustInt(6)
  913. ImportLocalPaths = sec.Key("IMPORT_LOCAL_PATHS").MustBool(false)
  914. DisableGitHooks = sec.Key("DISABLE_GIT_HOOKS").MustBool(false)
  915. InternalToken = sec.Key("INTERNAL_TOKEN").String()
  916. if len(InternalToken) == 0 {
  917. InternalToken, err = generate.NewInternalToken()
  918. if err != nil {
  919. log.Fatal(4, "Error generate internal token: %v", err)
  920. }
  921. // Save secret
  922. cfgSave := ini.Empty()
  923. if com.IsFile(CustomConf) {
  924. // Keeps custom settings if there is already something.
  925. if err := cfgSave.Append(CustomConf); err != nil {
  926. log.Error(4, "Failed to load custom conf '%s': %v", CustomConf, err)
  927. }
  928. }
  929. cfgSave.Section("security").Key("INTERNAL_TOKEN").SetValue(InternalToken)
  930. if err := os.MkdirAll(filepath.Dir(CustomConf), os.ModePerm); err != nil {
  931. log.Fatal(4, "Failed to create '%s': %v", CustomConf, err)
  932. }
  933. if err := cfgSave.SaveTo(CustomConf); err != nil {
  934. log.Fatal(4, "Error saving generated JWT Secret to custom config: %v", err)
  935. }
  936. }
  937. IterateBufferSize = Cfg.Section("database").Key("ITERATE_BUFFER_SIZE").MustInt(50)
  938. LogSQL = Cfg.Section("database").Key("LOG_SQL").MustBool(true)
  939. DBConnectRetries = Cfg.Section("database").Key("DB_RETRIES").MustInt(10)
  940. DBConnectBackoff = Cfg.Section("database").Key("DB_RETRY_BACKOFF").MustDuration(3 * time.Second)
  941. sec = Cfg.Section("attachment")
  942. AttachmentPath = sec.Key("PATH").MustString(path.Join(AppDataPath, "attachments"))
  943. if !filepath.IsAbs(AttachmentPath) {
  944. AttachmentPath = path.Join(AppWorkPath, AttachmentPath)
  945. }
  946. AttachmentAllowedTypes = strings.Replace(sec.Key("ALLOWED_TYPES").MustString("image/jpeg,image/png,application/zip,application/gzip"), "|", ",", -1)
  947. AttachmentMaxSize = sec.Key("MAX_SIZE").MustInt64(4)
  948. AttachmentMaxFiles = sec.Key("MAX_FILES").MustInt(5)
  949. AttachmentEnabled = sec.Key("ENABLED").MustBool(true)
  950. TimeFormatKey := Cfg.Section("time").Key("FORMAT").MustString("RFC1123")
  951. TimeFormat = map[string]string{
  952. "ANSIC": time.ANSIC,
  953. "UnixDate": time.UnixDate,
  954. "RubyDate": time.RubyDate,
  955. "RFC822": time.RFC822,
  956. "RFC822Z": time.RFC822Z,
  957. "RFC850": time.RFC850,
  958. "RFC1123": time.RFC1123,
  959. "RFC1123Z": time.RFC1123Z,
  960. "RFC3339": time.RFC3339,
  961. "RFC3339Nano": time.RFC3339Nano,
  962. "Kitchen": time.Kitchen,
  963. "Stamp": time.Stamp,
  964. "StampMilli": time.StampMilli,
  965. "StampMicro": time.StampMicro,
  966. "StampNano": time.StampNano,
  967. }[TimeFormatKey]
  968. // When the TimeFormatKey does not exist in the previous map e.g.'2006-01-02 15:04:05'
  969. if len(TimeFormat) == 0 {
  970. TimeFormat = TimeFormatKey
  971. TestTimeFormat, _ := time.Parse(TimeFormat, TimeFormat)
  972. if TestTimeFormat.Format(time.RFC3339) != "2006-01-02T15:04:05Z" {
  973. log.Fatal(4, "Can't create time properly, please check your time format has 2006, 01, 02, 15, 04 and 05")
  974. }
  975. log.Trace("Custom TimeFormat: %s", TimeFormat)
  976. }
  977. RunUser = Cfg.Section("").Key("RUN_USER").MustString(user.CurrentUsername())
  978. // Does not check run user when the install lock is off.
  979. if InstallLock {
  980. currentUser, match := IsRunUserMatchCurrentUser(RunUser)
  981. if !match {
  982. log.Fatal(4, "Expect user '%s' but current user is: %s", RunUser, currentUser)
  983. }
  984. }
  985. SSH.BuiltinServerUser = Cfg.Section("server").Key("BUILTIN_SSH_SERVER_USER").MustString(RunUser)
  986. // Determine and create root git repository path.
  987. sec = Cfg.Section("repository")
  988. Repository.DisableHTTPGit = sec.Key("DISABLE_HTTP_GIT").MustBool()
  989. Repository.UseCompatSSHURI = sec.Key("USE_COMPAT_SSH_URI").MustBool()
  990. Repository.MaxCreationLimit = sec.Key("MAX_CREATION_LIMIT").MustInt(-1)
  991. RepoRootPath = sec.Key("ROOT").MustString(path.Join(homeDir, "gitea-repositories"))
  992. forcePathSeparator(RepoRootPath)
  993. if !filepath.IsAbs(RepoRootPath) {
  994. RepoRootPath = filepath.Join(AppWorkPath, RepoRootPath)
  995. } else {
  996. RepoRootPath = filepath.Clean(RepoRootPath)
  997. }
  998. ScriptType = sec.Key("SCRIPT_TYPE").MustString("bash")
  999. if err = Cfg.Section("repository").MapTo(&Repository); err != nil {
  1000. log.Fatal(4, "Failed to map Repository settings: %v", err)
  1001. } else if err = Cfg.Section("repository.editor").MapTo(&Repository.Editor); err != nil {
  1002. log.Fatal(4, "Failed to map Repository.Editor settings: %v", err)
  1003. } else if err = Cfg.Section("repository.upload").MapTo(&Repository.Upload); err != nil {
  1004. log.Fatal(4, "Failed to map Repository.Upload settings: %v", err)
  1005. } else if err = Cfg.Section("repository.local").MapTo(&Repository.Local); err != nil {
  1006. log.Fatal(4, "Failed to map Repository.Local settings: %v", err)
  1007. } else if err = Cfg.Section("repository.pull-request").MapTo(&Repository.PullRequest); err != nil {
  1008. log.Fatal(4, "Failed to map Repository.PullRequest settings: %v", err)
  1009. }
  1010. if !filepath.IsAbs(Repository.Upload.TempPath) {
  1011. Repository.Upload.TempPath = path.Join(AppWorkPath, Repository.Upload.TempPath)
  1012. }
  1013. sec = Cfg.Section("picture")
  1014. AvatarUploadPath = sec.Key("AVATAR_UPLOAD_PATH").MustString(path.Join(AppDataPath, "avatars"))
  1015. forcePathSeparator(AvatarUploadPath)
  1016. if !filepath.IsAbs(AvatarUploadPath) {
  1017. AvatarUploadPath = path.Join(AppWorkPath, AvatarUploadPath)
  1018. }
  1019. AvatarMaxWidth = sec.Key("AVATAR_MAX_WIDTH").MustInt(4096)
  1020. AvatarMaxHeight = sec.Key("AVATAR_MAX_HEIGHT").MustInt(3072)
  1021. switch source := sec.Key("GRAVATAR_SOURCE").MustString("gravatar"); source {
  1022. case "duoshuo":
  1023. GravatarSource = "http://gravatar.duoshuo.com/avatar/"
  1024. case "gravatar":
  1025. GravatarSource = "https://secure.gravatar.com/avatar/"
  1026. case "libravatar":
  1027. GravatarSource = "https://seccdn.libravatar.org/avatar/"
  1028. default:
  1029. GravatarSource = source
  1030. }
  1031. DisableGravatar = sec.Key("DISABLE_GRAVATAR").MustBool()
  1032. EnableFederatedAvatar = sec.Key("ENABLE_FEDERATED_AVATAR").MustBool(!InstallLock)
  1033. if OfflineMode {
  1034. DisableGravatar = true
  1035. EnableFederatedAvatar = false
  1036. }
  1037. if DisableGravatar {
  1038. EnableFederatedAvatar = false
  1039. }
  1040. if EnableFederatedAvatar || !DisableGravatar {
  1041. GravatarSourceURL, err = url.Parse(GravatarSource)
  1042. if err != nil {
  1043. log.Fatal(4, "Failed to parse Gravatar URL(%s): %v",
  1044. GravatarSource, err)
  1045. }
  1046. }
  1047. if EnableFederatedAvatar {
  1048. LibravatarService = libravatar.New()
  1049. if GravatarSourceURL.Scheme == "https" {
  1050. LibravatarService.SetUseHTTPS(true)
  1051. LibravatarService.SetSecureFallbackHost(GravatarSourceURL.Host)
  1052. } else {
  1053. LibravatarService.SetUseHTTPS(false)
  1054. LibravatarService.SetFallbackHost(GravatarSourceURL.Host)
  1055. }
  1056. }
  1057. if err = Cfg.Section("ui").MapTo(&UI); err != nil {
  1058. log.Fatal(4, "Failed to map UI settings: %v", err)
  1059. } else if err = Cfg.Section("markdown").MapTo(&Markdown); err != nil {
  1060. log.Fatal(4, "Failed to map Markdown settings: %v", err)
  1061. } else if err = Cfg.Section("admin").MapTo(&Admin); err != nil {
  1062. log.Fatal(4, "Fail to map Admin settings: %v", err)
  1063. } else if err = Cfg.Section("cron").MapTo(&Cron); err != nil {
  1064. log.Fatal(4, "Failed to map Cron settings: %v", err)
  1065. } else if err = Cfg.Section("git").MapTo(&Git); err != nil {
  1066. log.Fatal(4, "Failed to map Git settings: %v", err)
  1067. } else if err = Cfg.Section("api").MapTo(&API); err != nil {
  1068. log.Fatal(4, "Failed to map API settings: %v", err)
  1069. } else if err = Cfg.Section("metrics").MapTo(&Metrics); err != nil {
  1070. log.Fatal(4, "Failed to map Metrics settings: %v", err)
  1071. }
  1072. git.DefaultCommandExecutionTimeout = time.Duration(Git.Timeout.Default) * time.Second
  1073. sec = Cfg.Section("mirror")
  1074. Mirror.MinInterval = sec.Key("MIN_INTERVAL").MustDuration(10 * time.Minute)
  1075. Mirror.DefaultInterval = sec.Key("DEFAULT_INTERVAL").MustDuration(8 * time.Hour)
  1076. if Mirror.MinInterval.Minutes() < 1 {
  1077. log.Warn("Mirror.MinInterval is too low")
  1078. Mirror.MinInterval = 1 * time.Minute
  1079. }
  1080. if Mirror.DefaultInterval < Mirror.MinInterval {
  1081. log.Warn("Mirror.DefaultInterval is less than Mirror.MinInterval")
  1082. Mirror.DefaultInterval = time.Hour * 8
  1083. }
  1084. Langs = Cfg.Section("i18n").Key("LANGS").Strings(",")
  1085. if len(Langs) == 0 {
  1086. Langs = []string{
  1087. "en-US", "zh-CN", "zh-HK", "zh-TW", "de-DE", "fr-FR", "nl-NL", "lv-LV",
  1088. "ru-RU", "uk-UA", "ja-JP", "es-ES", "pt-BR", "pl-PL", "bg-BG", "it-IT",
  1089. "fi-FI", "tr-TR", "cs-CZ", "sr-SP", "sv-SE", "ko-KR"}
  1090. }
  1091. Names = Cfg.Section("i18n").Key("NAMES").Strings(",")
  1092. if len(Names) == 0 {
  1093. Names = []string{"English", "简体中文", "繁體中文(香港)", "繁體中文(台灣)", "Deutsch",
  1094. "français", "Nederlands", "latviešu", "русский", "Українська", "日本語",
  1095. "español", "português do Brasil", "polski", "български", "italiano",
  1096. "suomi", "Türkçe", "čeština", "српски", "svenska", "한국어"}
  1097. }
  1098. dateLangs = Cfg.Section("i18n.datelang").KeysHash()
  1099. ShowFooterBranding = Cfg.Section("other").Key("SHOW_FOOTER_BRANDING").MustBool(false)
  1100. ShowFooterVersion = Cfg.Section("other").Key("SHOW_FOOTER_VERSION").MustBool(true)
  1101. ShowFooterTemplateLoadTime = Cfg.Section("other").Key("SHOW_FOOTER_TEMPLATE_LOAD_TIME").MustBool(true)
  1102. UI.ShowUserEmail = Cfg.Section("ui").Key("SHOW_USER_EMAIL").MustBool(true)
  1103. HasRobotsTxt = com.IsFile(path.Join(CustomPath, "robots.txt"))
  1104. extensionReg := regexp.MustCompile(`\.\w`)
  1105. for _, sec := range Cfg.Section("markup").ChildSections() {
  1106. name := strings.TrimPrefix(sec.Name(), "markup.")
  1107. if name == "" {
  1108. log.Warn("name is empty, markup " + sec.Name() + "ignored")
  1109. continue
  1110. }
  1111. extensions := sec.Key("FILE_EXTENSIONS").Strings(",")
  1112. var exts = make([]string, 0, len(extensions))
  1113. for _, extension := range extensions {
  1114. if !extensionReg.MatchString(extension) {
  1115. log.Warn(sec.Name() + " file extension " + extension + " is invalid. Extension ignored")
  1116. } else {
  1117. exts = append(exts, extension)
  1118. }
  1119. }
  1120. if len(exts) == 0 {
  1121. log.Warn(sec.Name() + " file extension is empty, markup " + name + " ignored")
  1122. continue
  1123. }
  1124. command := sec.Key("RENDER_COMMAND").MustString("")
  1125. if command == "" {
  1126. log.Warn(" RENDER_COMMAND is empty, markup " + name + " ignored")
  1127. continue
  1128. }
  1129. ExternalMarkupParsers = append(ExternalMarkupParsers, MarkupParser{
  1130. Enabled: sec.Key("ENABLED").MustBool(false),
  1131. MarkupName: name,
  1132. FileExtensions: exts,
  1133. Command: command,
  1134. IsInputFile: sec.Key("IS_INPUT_FILE").MustBool(false),
  1135. })
  1136. }
  1137. sec = Cfg.Section("U2F")
  1138. U2F.TrustedFacets, _ = shellquote.Split(sec.Key("TRUSTED_FACETS").MustString(strings.TrimRight(AppURL, "/")))
  1139. U2F.AppID = sec.Key("APP_ID").MustString(strings.TrimRight(AppURL, "/"))
  1140. binVersion, err := git.BinVersion()
  1141. if err != nil {
  1142. log.Fatal(4, "Error retrieving git version: %v", err)
  1143. }
  1144. if version.Compare(binVersion, "2.9", ">=") {
  1145. // Explicitly disable credential helper, otherwise Git credentials might leak
  1146. git.GlobalCommandArgs = append(git.GlobalCommandArgs, "-c", "credential.helper=")
  1147. }
  1148. }
  1149. // NewServices initializes the services
  1150. func NewServices() {
  1151. newService()
  1152. newLogService()
  1153. NewXORMLogService(false)
  1154. newCacheService()
  1155. newSessionService()
  1156. newMailService()
  1157. newRegisterMailService()
  1158. newNotifyMailService()
  1159. newWebhookService()
  1160. newIndexerService()
  1161. }