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