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

setting.go 49 kB

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