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 48 kB

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