Compare commits

..

48 Commits

Author SHA1 Message Date
Lauris BH
09bd05732d Changelog for release 1.2.3 (#2840) 2017-11-03 21:40:46 +08:00
Morlinest
de7a76a995 Fix order of comments (#2835) (#2839) 2017-11-03 13:16:26 +02:00
Antoine GIRARD
357d5a5a3d Backport to v1.2 of PR 2266 2467 2663 (#2788)
* Only check at least one email gpg key (#2266)

* Only require one email (possibly not yet validated)

* Update message error and check validation of commit

* Add integrations tests

* Complete integration for import

* Add pre-check/optimization

* Add some test (not finished)

* Finish

* Fix fixtures

* Fix typo

* Don't guess key ID

* Make repo private to no interfere with other tests (#2467)

* GPG key email verification no longer case sensitive (#2661) (#2663)

* GPG key email verification no longer case sensitive (#2661)

* case insensitive GPG key email verification now cached (#2661)

Signed-off-by: Julian Scholle <julian.scholle@googlemail.com>
2017-10-27 12:36:14 +08:00
Lauris BH
d81cf34e37 Changelog for release v1.2.2 (#2786) 2017-10-26 18:34:30 +03:00
Lauris BH
9902317679 Add checks for commits with missing author and time (#2771) (#2785)
* Add checks for commits with missing author and time

* Fix validate commits with emails if it has no Author
2017-10-26 22:24:11 +08:00
Paul Tötterman
33e164168f Fix sending mail with a non-latin display name. #2102 (#2559) (#2783)
* Fix sending mail with a non-latin display name. #2102

Signed-off-by: Rémi Saurel <contact@remi-saurel.com>

* Take into account the possibility that setting.MailService.From is in `name <email@address>` format. #2102

Signed-off-by: Rémi Saurel <contact@remi-saurel.com>
2017-10-26 10:44:20 +03:00
Michael Kuhn
f40ba68d57 Sync MaxGitDiffLineCharacters with conf/app.ini (#2779) (#2780)
MAX_GIT_DIFF_LINE_CHARACTERS was updated in #1845 but the corresponding
default value of MaxGitDiffLineCharacters was not changed. This can lead
to inconsistencies.
2017-10-25 12:45:29 +03:00
Lunny Xiao
cb0c8b8ae4 fix imports 2017-10-25 13:49:06 +08:00
Lunny Xiao
eba5945d2f some fixes 2017-10-25 13:28:47 +08:00
Lauris BH
4c67925531 Update vendor git (#2765) (#2772) 2017-10-24 02:04:22 +03:00
Lauris BH
3c60121ca7 Fix emojify image URL (#2769) (#2773) 2017-10-24 00:26:51 +02:00
Lauris BH
46bb1cf026 Changelog for v1.2.1 (#2716) 2017-10-16 16:27:22 +02:00
Lauris BH
13013e90f3 Fix PR, milestone and label functionality if issue unit is disabled (#2710) (#2714)
* Fix PR, milestone and label functionality if issue unit is disabled or not assigned to user

* Fix multi-actions in PR page

* Change error message

* Fix comment update and delete functionality in PR
2017-10-16 16:59:01 +03:00
Lunny Xiao
785ba171f4 Fix plain readme didn't render correctly on repo home page (#2705) (#2712)
* fix plain readme didn't render correctly on repo home page

* fix missing render

* remove unused template variables
2017-10-16 03:30:11 -05:00
Lauris BH
fb80265b52 Fix so that user can still fork his own repository to owned organizations (#2699) (#2707)
* Fix so that user can still fork his own repository to his organizations

* Fix to only use owned organizations

* Add integration test for forking own repository to owned organization
2017-10-15 19:40:33 +03:00
David Schneiderbauer
6fae585d28 fix .netrc authentication (#2700) (#2708)
* provide both possible authentication solutions

Signed-off-by: David Schneiderbauer <dschneiderbauer@gmail.com>
2017-10-15 18:50:28 +03:00
Lunny Xiao
670562a9c5 Fix slice out of bounds error in mailer (#2479) (#2696) 2017-10-13 22:59:03 +03:00
Lunny Xiao
ed07d8a308 Add release notes for v1.2.0 (#2683)
* add release notes for v1.2.0

* improve release notes for v1.2.0
2017-10-12 14:13:12 +08:00
David Schneiderbauer
74399f333f Backport of migration fixes (#2604) (#2677)
* Rewrite migrations to not depend on future code changes (#2604)

* v38 migration used an outdated version of RepoUnit model (#2602)

* change repoUnit model in migration

* fix v16 migration repo_unit table

* fix lint error

* move type definition inside function

* Fix migration from Gogs

* Refactor code

* add error check

* Additiomal fixes for migrations

* Add back nil check

* replace deprecated .Id with .ID

Signed-off-by: David Schneiderbauer <dschneiderbauer@gmail.com>

* change string map to interface map

Signed-off-by: David Schneiderbauer <dschneiderbauer@gmail.com>
2017-10-09 16:08:22 +03:00
David Schneiderbauer
d1cec5ecfa fix panic on gogs webhook creation (#2675) (#2676)
* fix panic on gogs webhook creation

Signed-off-by: David Schneiderbauer <dschneiderbauer@gmail.com>

* fix panic in gogs webhook edit

Signed-off-by: David Schneiderbauer <dschneiderbauer@gmail.com>
2017-10-09 08:58:49 +08:00
Lauris BH
73ad7d2ef3 Fixes 500 error on dashboard when using MSSQL (#2504) (#2662)
MSSQL rejects the query:
  SELECT "repository"."id" FROM "repository"
  INNER JOIN "team_repo" ON "team_repo".repo_id="repository".id AND
  "repository".is_mirror=1
  WHERE (
    ("repository".owner_id=2 AND "repository".is_private=0)
        OR team_repo.team_id IN (1)
        )
        GROUP BY "repository".id ORDER BY updated_unix DESC

when the order by term (updated_unix) is not included in the group by
term.
2017-10-05 21:08:40 +03:00
Lauris BH
5b36379172 Fix go get response if only app URL is custom in configuration (#2634) (#2640)
* Fix go get response if only app URL is custom in configuration

* Rewrite to update Domain setting to match AppURL
2017-10-03 06:29:19 +03:00
David Schneiderbauer
e38e502e20 Fix deletion of unprotected branches (#2630)
* fix deletion of unprotected branches

* fmt fix

* changed internal protected branch api

* fix lint error

Signed-off-by: David Schneiderbauer <dschneiderbauer@gmail.com>
2017-10-02 23:23:41 +03:00
David Schneiderbauer
3cc5b11b0d Backport of 2611 / Fix doubled issue tab introduced in migration v16 (#2622)
Signed-off-by: David Schneiderbauer <dschneiderbauer@gmail.com>
2017-10-01 09:18:49 +03:00
David Schneiderbauer
4c9bf91a2c v38 migration used an outdated version of RepoUnit model (#2602)
* change repoUnit model in migration

* fix v16 migration repo_unit table

* fix lint error

* move type definition inside function

Signed-off-by: David Schneiderbauer <dschneiderbauer@gmail.com>
2017-09-25 19:53:55 +03:00
Lunny Xiao
03ff7687e0 fix go get subpackage bug (#2584) (#2589)
* fix go get subpackage bug

* merge the duplicated funtions
2017-09-23 16:58:17 +03:00
Lunny Xiao
f646154ead add secrets for github release (#2588) 2017-09-23 20:17:51 +08:00
Lauris BH
a6d2f47a2b Add changelog for v1.2.0-rc4 (#2587) 2017-09-23 13:50:35 +03:00
Lauris BH
1837194882 Backport changes for latest drone (#2586) 2017-09-23 17:33:52 +08:00
Jonas Franz
9ca26432f6 Removing .drone.yml.sig (#2579)
Signed-off-by: Jonas Franz <info@jonasfranz.software>
2017-09-23 09:17:32 +08:00
Lauris BH
67595c0d0b Fix drone for tags (#2573) (#2576) 2017-09-22 20:00:52 +03:00
Lauris BH
6d03cf831e Add changelog for v1.2.0-rc3 (#2563) 2017-09-21 10:00:37 +03:00
Lauris BH
e232c49b10 Sync releases table with tags on push and for mirrors (#2459) (#2554)
* Sync releases table with tags on push and for mirrors

* Code style fixes

* Fix api to return only releases

* Optimize release creation and update
Minimize posibility of race conditions

* Fix release lower tag name updating

* handle tag reference update by addionally comparing commit id
2017-09-21 01:08:22 +03:00
Lauris BH
25e71ad41e Fix adding branch as protected to not allow pushing to it (#2556)
* Fix adding branch as protected to not allow pushing to it

* Fix can_push value to false in protected_branch (#2560)

* Fix integration test
2017-09-20 20:14:09 +03:00
Ethan Koenig
f014e42a06 Backport: Fix lint, fmt and integration testing errors (#2553)
* Fix lint errors

* Fix fmt errors (#2544)

* Hotfix for integration testing (#2473)

* Hotfix for integration testing
2017-09-20 19:30:20 +03:00
Lauris BH
d14a724b53 Remove go version check for make fmt (#2558) (#2561) 2017-09-20 20:42:08 +08:00
Jonas Franz
91788e0200 Restricting access to fork functioanlity to users with Code access (#2542)
Signed-off-by: Jonas Franz <info@jonasfranz.software>
2017-09-19 01:12:29 +02:00
Lauris BH
fc0c6f48c7 Add changelog for release v1.2.0-rc2 (#2469) 2017-09-06 14:05:35 +03:00
Lauris BH
002fa73460 Fix migration from pre-v15 to 1.2.0 (#2460) (#2465) 2017-09-05 21:03:30 +08:00
Lunny Xiao
2fdc649202 bug fixed 2017-09-04 14:28:50 +08:00
Lauris BH
0c910afe11 Fix releases to be counted from database not tags (#2389) (#2424) 2017-08-30 09:31:32 +08:00
Lunny Xiao
1cbe502cc2 fix duplicated feed (#2370) 2017-08-28 19:16:25 +02:00
Sandro Santilli
f916aa0fe3 Set version to 1.2.0-dev
1.2.0-dev is less than 1.2.0, according to semver
2017-08-27 23:02:48 +02:00
Lunny Xiao
04728b5b91 fix wrong changelog title (#2395) 2017-08-25 22:34:50 +08:00
Lunny Xiao
bbb0b8c17c add change log for release v1.2.0-rc1 (#2388) 2017-08-25 16:54:41 +08:00
Lunny Xiao
0938a2dca3 Fix missing collabrative repos (#2367) (#2382)
* fix missing collabrative repos

* fix bug of collabrative

* fix SQL quotes
2017-08-25 10:25:37 +08:00
Michael Lustfield
9df0eafa25 Move 3rd party js/css into public/vendor and document sources (#2383)
This commit cherry picks the following commits (master -> v1.2):
  a915a09
  874f9be
  233bbcf

Ref: https://github.com/go-gitea/gitea/issues/1484
Signed-off-by: Michael Lustfield <michael@lustfield.net>
2017-08-25 10:01:17 +08:00
Lunny Xiao
e13eef8cfe update translation from crowdin (#2368) (#2380) 2017-08-24 21:57:17 +08:00
718 changed files with 14427 additions and 46732 deletions

View File

@@ -1,44 +0,0 @@
repo: go-gitea/gitea
groups:
-
name: BREAKING
labels:
- kind/breaking
-
name: FEATURE
labels:
- kind/feature
-
name: BUGFIXES
labels:
- kind/bug
-
name: ENHANCEMENT
labels:
- kind/enhancement
- kind/refactor
- kind/ui
-
name: SECURITY
labels:
- kind/security
-
name: TESTING
labels:
- kind/testing
-
name: TRANSLATION
labels:
- kind/translation
-
name: BUILD
labels:
- kind/build
- kind/lint
-
name: DOCS
labels:
- kind/docs
-
name: MISC
default: true

View File

@@ -9,52 +9,6 @@ clone:
tags: true tags: true
pipeline: pipeline:
download_translations:
image: jonasfranz/crowdin
pull: true
secrets: [ crowdin_key ]
project_identifier: gitea
ignore_branch: true
download: true
export_dir: options/locale/
when:
event: [ push ]
branch: [ master ]
update-translations:
image: alpine:3.6
commands:
- mv ./options/locale/locale_en-US.ini ./options/
- sed -i -e 's/="/=/g' -e 's/"$$//g' ./options/locale/*.ini
- sed -i -e 's/\\\\"/"/g' ./options/locale/*.ini
- mv ./options/locale_en-US.ini ./options/locale/
when:
event: [ push ]
branch: [ master ]
git_push:
image: appleboy/drone-git-push
pull: true
secrets: [ git_push_ssh_key ]
remote: git@github.com:go-gitea/gitea.git
force: false
commit: true
commit_message: "[skip ci] Updated translations via Crowdin"
author_name: GiteaBot
author_email: teabot@gitea.io
when:
event: [ push ]
branch: [ master ]
pre-build:
image: webhippie/nodejs:latest
pull: true
commands:
- npm install
- make stylesheets-check
when:
event: [ push, tag, pull_request ]
build: build:
image: webhippie/golang:edge image: webhippie/golang:edge
pull: true pull: true
@@ -66,7 +20,7 @@ pipeline:
- make generate - make generate
- make vet - make vet
- make lint - make lint
- make fmt-check - make stylesheets-check
- make misspell-check - make misspell-check
- make test-vendor - make test-vendor
- make build - make build
@@ -76,46 +30,18 @@ pipeline:
test: test:
image: webhippie/golang:edge image: webhippie/golang:edge
pull: true pull: true
group: test
environment:
TAGS: bindata sqlite
GOPATH: /srv/app
commands:
- make unit-test-coverage
when:
event: [ push, pull_request ]
branch: [ master ]
test:
image: webhippie/golang:edge
pull: true
group: test
environment: environment:
TAGS: bindata sqlite TAGS: bindata sqlite
GOPATH: /srv/app GOPATH: /srv/app
commands: commands:
- make test - make test
when: when:
event: [ push, pull_request ] event: [ tag, pull_request ]
branch: [ release/* ]
test:
image: webhippie/golang:edge
pull: true
group: test
environment:
TAGS: bindata
GOPATH: /srv/app
commands:
- make test
when:
event: [ tag ]
# Commented until db locking have been resolved! # Commented until db locking have been resolved!
# test-sqlite: # test-sqlite:
# image: webhippie/golang:edge # image: webhippie/golang:edge
# pull: true # pull: true
# group: test
# environment: # environment:
# TAGS: bindata # TAGS: bindata
# GOPATH: /srv/app # GOPATH: /srv/app
@@ -127,32 +53,17 @@ pipeline:
test-mysql: test-mysql:
image: webhippie/golang:edge image: webhippie/golang:edge
pull: true pull: true
group: test
environment:
TAGS: bindata
GOPATH: /srv/app
commands:
- make integration-test-coverage
when:
event: [ push, pull_request ]
branch: [ master ]
test-mysql:
image: webhippie/golang:edge
pull: true
group: test
environment: environment:
TAGS: bindata TAGS: bindata
GOPATH: /srv/app GOPATH: /srv/app
commands: commands:
- make test-mysql - make test-mysql
when: when:
event: [ tag ] event: [ push, tag, pull_request ]
test-pgsql: test-pgsql:
image: webhippie/golang:edge image: webhippie/golang:edge
pull: true pull: true
group: test
environment: environment:
TAGS: bindata TAGS: bindata
GOPATH: /srv/app GOPATH: /srv/app
@@ -161,27 +72,6 @@ pipeline:
when: when:
event: [ push, tag, pull_request ] event: [ push, tag, pull_request ]
generate-coverage:
image: webhippie/golang:edge
pull: true
environment:
TAGS: bindata
GOPATH: /srv/app
commands:
- make coverage
when:
event: [ push, pull_request ]
branch: [ master ]
coverage:
image: robertstettner/drone-codecov
secrets: [ codecov_token ]
files:
- coverage.all
when:
event: [ push, pull_request ]
branch: [ master ]
static: static:
image: karalabe/xgo-latest:latest image: karalabe/xgo-latest:latest
pull: true pull: true
@@ -272,19 +162,6 @@ pipeline:
when: when:
event: [ tag ] event: [ tag ]
upload_translations:
image: jonasfranz/crowdin
pull: true
secrets: [ crowdin_key ]
project_identifier: gitea
ignore_branch: true
download: false
files:
locale_en-US.ini: options/locale/locale_en-US.ini
when:
event: [ push ]
branch: [ master ]
discord: discord:
image: appleboy/drone-discord:1.0.0 image: appleboy/drone-discord:1.0.0
pull: true pull: true

15
.gitignore vendored
View File

@@ -10,9 +10,6 @@ _test
# IntelliJ # IntelliJ
.idea .idea
# MS VSCode
.vscode
# Architecture specific extensions/prefixes # Architecture specific extensions/prefixes
*.[568vq] *.[568vq]
[568vq].out [568vq].out
@@ -30,7 +27,6 @@ _testmain.go
*.prof *.prof
*coverage.out *coverage.out
coverage.all
/modules/options/bindata.go /modules/options/bindata.go
/modules/public/bindata.go /modules/public/bindata.go
@@ -40,7 +36,6 @@ coverage.all
*.log *.log
/gitea /gitea
/debug
/integrations.test /integrations.test
/bin /bin
@@ -50,12 +45,4 @@ coverage.all
/indexers /indexers
/log /log
/public/img/avatar /public/img/avatar
/integrations/gitea-integration-mysql /integrations/gitea-integration
/integrations/gitea-integration-pgsql
/integrations/gitea-integration-sqlite
/integrations/indexers-mysql
/integrations/indexers-pgsql
/integrations/indexers-sqlite
/integrations/mysql.ini
/integrations/pgsql.ini
/node_modules

View File

@@ -1,252 +1,4 @@
# Changelog # Changelog
## [1.3.2](https://github.com/go-gitea/gitea/releases/tag/v1.3.2) - 2017-12-14
* BUGFIXES
* fix run web with -p push failed (#3154) (#3179)
* Fix source download link when no code unit allowed (#3166) (#3169)
* Allow adding collaborators with (fullname) (#3103) (#3168)
* Fix repo links (#3093) (#3163)
* Fix Uninitialized variable in ParsePatch (#3156) (#3162)
* Fix migration order v1.3 (#3157)
* Fix avatar URLs (#3069) (#3143)
## [1.3.1](https://github.com/go-gitea/gitea/releases/tag/v1.3.1) - 2017-12-08
* BUGFIXES
* Sanitize logs for mirror sync (#3057, #3082) (#3078)
* Fix missing branch in release bug (#3108) (#3117)
* Fix repo indexer and submodule bug (#3107) (#3110)
* Fix legacy URL redirects (#3100) (#3106)
* Fix redis session failed (#3086) (#3089)
* Fix issue list branch link broken (#3061) (#3070)
* Fix missing password length check when change password (#3039) (#3071)
## [1.3.0](https://github.com/go-gitea/gitea/releases/tag/v1.3.0) - 2017-11-29
* BREAKING
* Make URL scheme unambiguous (#2408)
* FEATURE
* Add branch overiew page (#2108)
* Code/repo search (#2582)
* Add Activity page to repository (#2674)
* Issue Timetracking (#2211)
* Add orgmode document type on file view and readme (#2525)
* Add external markup render support (#2570)
* Implementation of discord webhook (#2402)
* Webhooks for repo creation/deletion (#1663)
* Complete push webhooks (#2530)
* Add possibility to record branch information in an issue (#780)
* Create new branch from branch selection dropdown (#2130)
* Implementation of all repositories of a user from user->settings (#1740)
* Add LFS object verification step after upload (#2868)
* Configurable SSH cipher suite (#913)
* Disable custom Git Hooks globally via configuration file (#2450)
* Sync releases table with tags on push and for mirrors (#2459)
* BUGFIXES
* Fix label comments for French locale (#3017)
* Remove duplicate "Max Diff Lines" from config view (#3001)
* Fix over-escaped characters (#2992)
* Fix go-get, src and raw urls to new scheme (#2986)
* Fix error when add user has full name to team (#2975)
* Fix files/commits of merged PRs (#2970)
* Update golang x/crypto dependencies - Fix SSH transport fail (#2951)
* Fix memcache support when value is returned as string always (#2950)
* Fix issue link rendering in commit messages (#2897)
* Fix adding a new authentication source after selecting OAuth (#2889)
* Fix new branch creation to new url scheme (#2884)
* Allow spaces in username for LDAP users (#2880)
* Fix LFS not returning correct content length when requesting a range … (#2864)
* Fix fork repository cycle to self (#2860)
* Fix click create pull request button 404 (#2859)
* Fix API raw file content access for default branch (#2849)
* Clean repository ROOT directory name with filepath.Clean (#2846)
* Fix API raw requests for commits and tags (#2841)
* Fix order of comments (#2835)
* Issue content should not be updated when closing with comment (#2833)
* Fix ordering in app.ini and fix run mode option (#2829)
* Fix redirect url of legacy commits route (#2825)
* Fix commits page url (#2823)
* Fix wrong translations (#2818)
* Fix dropdown menu position when explore repos (#2808)
* Fix Git LFS object/repo link storage in database and small refactoring (#2803)
* Use relative URLs for avatars on the dashboard (#2800)
* Add checks for commits with missing author and time (#2771)
* Fix emojify image URL (#2769)
* Hide unactive on explore users and some refactors (#2741)
* Fix IE unsupported javascript construction in branch dropdown (#2736)
* Only update mirror last update after successful sync (#2730)
* Fix semantic-ui style conflict with v-cloak (#2722)
* Fixing wrong translation on sort type oldest/latest (#2720)
* Fix PR, milestone and label functionality if issue unit is disabled (#2710)
* Fix plain readme didn't render correctly on repo home page (#2705)
* Fix organization removal from watch table migration (#2703)
* Fix repository search function (#2689)
* fix panic on gogs webhook creation (#2675)
* Fix orgnization user watch repository (#2670)
* GPG key email verification no longer case sensitive (#2661) (#2663)
* Fix index column deletion (#2651)
* table `pull_request` wasn't updated correctly (#2649)
* Fix go get response if only app URL is custom in configuration (#2634)
* Fix doubled issue tab introduced in migration v16 (#2611)
* Rewrite migrations to not depend on future code changes (#2604)
* Fix implementation of repo Home func (#2601)
* Fix translation upload to crowdin (#2599)
* Reduce usage of allcols on update (#2596)
* fix go get subpackage bug (#2584)
* Fix broken migration to add can_push field back to table (#2574)
* fix readme view bug (#2566)
* Fix sending mail with a non-latin display name. #2102 (#2559)
* Restricting access to fork functioanlity to users with Code access (#2534)
* fix updated update on public key (#2514)
* Added bucket name to s3 drone plugin (#2505)
* fixes 500 error on dashboard when using MSSQL (#2504)
* fix wrong rendering of commit detail page (#2503)
* Hotfix: Add time manually adds time in nanoseconds (#2499)
* Remove repository mirrors from "collaborative" list (#2497)
* fix release failed since the wrong token name (#2496)
* Fix slice out of bounds error in mailer (#2479)
* Fix #2470 (#2477)
* fix orgnization webhooks (#2422)
* fix webhook test (#2415)
* fix missing orgnization discord webhook (#2414)
* Fix route handler order (#2409)
* Prevent sending emails and notifications to inactive users (#2384)
* Move themes to plugin directory. Fixes #2372 (#2375)
* fix duplicated feed (#2370)
* Fix missing collabrative repos (#2367)
* Only check at least one email gpg key (#2266)
* don't check minimum key size when disabled (#1754)
* Fix run command race (#1470)
* fix .netrc authentication (#2700)
* Fix so that user can still fork his own repository to his organizations (#2699)
* Fix can_push value to false in protected_branch (#2560)
* Fix copy in email templates (#2801)
* Fix inconsistencies in user settings UI (#2901)
* Fix attachments icon size on zoom in/out (#2853)
* Fix ignored errors in API route (#2850)
* Fix activity css conflit with semantic ui (#2758)
* Fix notifications tabs according to semantic-ui docs (#2733)
* Fix typos in app.ini (#2732)
* Fix duplicated rel attribute (#2549)
* Fix tests code to prevent some runtime errors (#2381)
* ENHANCEMENT
* Memory usage improvements and lower minimal git requirement to 1.7.2 (#3013) (#3028)
* Set OpenID support on by default when installing new instance (#3010) (#3027)
* Use api.TrackedTime in API (#2807)
* Configurable SSH key exchange algorithm and MAC suite (#2806)
* Add Safari pinned tab icon (#2799)
* Improve force push detect when push (#2798)
* Add wrapping to long diff lines (#2789)
* Link members and repositories count to each page on org home. (#2787)
* Show Sendmail settings on admin config page (#2782)
* Add commit count caching (#2774)
* Use identicon image for default gravatar. (#2767)
* Add default ssh ciphers (#2761)
* Remove manual of unsupported option (#2757)
* Add search mode option to /api/repo/search (#2756)
* Move swagger-ui under /api/v1 (#2746)
* Add support for extra sendmail arguments (#2731)
* Use buffersize to reduce database connection when iterate (#2724)
* Render plain text README.txt monospaced (#2721)
* Integration test for activity page (#2704)
* Merge password and 2fa page on user settings (#2695)
* Allow custom SSH user in UI for built-in SSH server (#2617) (#2678)
* Refactor duplicated code in repo handlers (#2657)
* Replace deprecated Id method with ID (#2655)
* Remove redudant functions and code (#2652)
* hide navbar when only 1 sign-in method is available (#2444) (#2648)
* Change default sort order (#2647)
* Change pull description text (#2075) (#2646)
* Remove direct user adding to organization members (#2641)
* Use session when creating user (#2638)
* Use Semantic UI's Search component for user and repo search (#2636)
* Use AfterLoad instead of AfterSet on Structs (#2628)
* Remove redudant CheckUnit calls in router (#2627)
* Remove repo unit index (#2621)
* Remove redudant issue LoadAttributes() calls (#2614)
* Make indexer code more reusable (#2590)
* Use custom type and constants to hold available order by options (#2572)
* Use named ActionType constants in template helper (#2545)
* Make basic functionality work without JavaScript (#2541)
* Ctrl + Enter to submit forms (#2540)
* Automatically regenerate indexer for incompatible versions (#2524)
* Set default lfs content path to data/lfs (#2521)
* Convert spaces to tabs in footer.tmpl (#2520)
* Sort repository tree entries in natural way (#2506)
* Open external wiki in new window (#2489)
* Use created & updated instead BeforeInsert & BeforeUpdate (#2482)
* Hide branch on pull request view or create UI (#2454)
* improve protected branch to add whitelist support (#2451)
* some refactors for issue and comments (#2419)
* Restructure markup & markdown to prepare for multiple markup language… (#2411)
* Improve issue search (#2387)
* Add UseCompatSSHURI setting (#2356)
* Use custom search for each filter type in dashboard (#2343)
* Failed authentication are now properly logged (#2334)
* Add environment variable support for Docker image (#2201)
* Set session and indexers' data files rel to AppDataPath (#2192)
* Display commit status on landing page of repo (#1784)
* TESTING
* Add integration test for logging out (#2892)
* Integration test for user deleting account (#2891)
* Use different directories for session files in integration tests (#2834)
* Add deleted_branch table fixture (#2832)
* Include HTTP method in test error message (#2815)
* Add repository search unit and integration tests (#2575)
* Expand fixtures (#2571)
* Fix /api/repo/search integration tests (#2550)
* Make integration tests more user-friendly (#2536)
* Fix unit test race condition (#2516)
* Add missing fixture to clean gpg_key table (#2494)
* Hotfix for integration testing (#2473)
* Make repo private to not interfere with other tests (#2467)
* Error message for integration test (#2410)
* Fix "index out of range" runtime error in repo_list tests (#2376)
* Add git clone test on integration test (#1682)
* TRANSLATION
* Fix localization texts that contain semicolon (#2900)
* Fix activity locale (#2709)
* Update translation from crowdin (#2368)
* BUILD
* change the email and name to GitBot account. (#2848)
* Fix removing backslash before quotes in translations (#2831)
* add gitea remote in drone. (#2817)
* add remote name for git push. (#2816)
* Launch Gitea with custom UID/GID for 'git' user (fixes #2286) (#2791)
* Download and pushing translations (#2727)
* Automatic update of translations (#2585)
* Add pre-build step for nodejs stuff (#2581)
* Compress css with nodejs (#2580)
* Remove go version check for make fmt (#2558)
* Fix lint errors (#2547)
* Always run fmt check in CI (#2546)
* Fix fmt errors (#2544)
* add codecov.io service. (#2493)
* Fix some tests : make coverage -> test (#2492)
* Fix fmt error in mailer (#2490)
* Allow changing integration test database connection using env variables (#2484)
* Add changelog config file for generate changelog (#2461)
* Changes for latest DroneCI (#2362)
* Use standard lessc and minify CSS using Node.js (#2337)
* DOCS
* Update screenshots on README (#2910)
* Gogs -> Gitea (#2909)
* Update swagger documentation (#2899)
* Fix typo (#2810)
* Fix Polish language name spelling (#2766)
* Fix Various Grammar Issues and Adjust Unnatural Wording (#2737)
* Add maintainer label for docker file (#2658)
* Link to gitea-specific Vagrant example (#2624)
* add release notes of v1.1.4 (#2463)
* Wrap most paragraphs to 80 columns (#2396)
* Update CONTRIBUTING following #2329 discussion (#2394)
* Update hard-coded version to 1.3.0+dev (#2390)
* Clarify Translation Process. Also fix branch names (#2378)
* Admin grammar fixes and improvements (#2056)
* MISC
* Sync MaxGitDiffLineCharacters with conf/app.ini (#2779)
* Dockerfile: Updated alpine image to 3.6. (#2486)
* Basic VSCode configuration for building and debugging (#2483)
* Added vendor dir for js/css libs; Documented sources (#1484) (#2241)
## [1.2.3](https://github.com/go-gitea/gitea/releases/tag/v1.2.3) - 2017-11-03 ## [1.2.3](https://github.com/go-gitea/gitea/releases/tag/v1.2.3) - 2017-11-03
* BUGFIXES * BUGFIXES
* Only require one email when validating GPG key (#2266, #2467, #2663) (#2788) * Only require one email when validating GPG key (#2266, #2467, #2663) (#2788)
@@ -748,15 +500,6 @@
* Move user_follow to separate file (#1210) * Move user_follow to separate file (#1210)
* Reduce conditionals in signin/signup inner forms (#1138) * Reduce conditionals in signin/signup inner forms (#1138)
## [1.1.4](https://github.com/go-gitea/gitea/releases/tag/v1.1.4) - 2017-09-04
* BUGFIXES
* Fix rendering of external links (#2292) (#2315)
* Fix deleted milestone bug (#1942) (#2300)
* fix 500 error when view an issue which's milestone deleted (#2297) (#2299)
* Fix SHA1 hash linking (#2143) (#2293)
* back port from #1709 (#2291)
## [1.1.3](https://github.com/go-gitea/gitea/releases/tag/v1.1.3) - 2017-08-03 ## [1.1.3](https://github.com/go-gitea/gitea/releases/tag/v1.1.3) - 2017-08-03
* BUGFIXES * BUGFIXES

View File

@@ -8,7 +8,6 @@
- [Discuss your design](#discuss-your-design) - [Discuss your design](#discuss-your-design)
- [Testing redux](#testing-redux) - [Testing redux](#testing-redux)
- [Vendoring](#vendoring) - [Vendoring](#vendoring)
- [Translation](#translation)
- [Code review](#code-review) - [Code review](#code-review)
- [Styleguide](#styleguide) - [Styleguide](#styleguide)
- [Sign your work](#sign-your-work) - [Sign your work](#sign-your-work)
@@ -20,107 +19,47 @@
## Introduction ## Introduction
This document explains how to contribute changes to the Gitea project. This document explains how to contribute changes to the Gitea project. It assumes you have followed the [installation instructions](https://docs.gitea.io/en-us/). Sensitive security-related issues should be reported to [security@gitea.io](mailto:security@gitea.io).
It assumes you have followed the
[installation instructions](https://docs.gitea.io/en-us/).
Sensitive security-related issues should be reported to
[security@gitea.io](mailto:security@gitea.io).
For configuring IDE or code editor to develop Gitea see [IDE and code editor configuration](contrib/ide/)
## Bug reports ## Bug reports
Please search the issues on the issue tracker with a variety of keywords Please search the issues on the issue tracker with a variety of keywords to ensure your bug is not already reported.
to ensure your bug is not already reported.
If unique, [open an issue](https://github.com/go-gitea/gitea/issues/new) If unique, [open an issue](https://github.com/go-gitea/gitea/issues/new) and answer the questions so we can understand and reproduce the problematic behavior.
and answer the questions so we can understand and reproduce the
problematic behavior.
To show us that the issue you are having is in Gitea itself, please To show us that the issue you are having is in Gitea itself, please write clear, concise instructions so we can reproduce the behavior (even if it seems obvious). The more detailed and specific you are, the faster we can fix the issue. Check out [How to Report Bugs Effectively](http://www.chiark.greenend.org.uk/~sgtatham/bugs.html).
write clear, concise instructions so we can reproduce the behavior—
even if it seems obvious. The more detailed and specific you are,
the faster we can fix the issue. Check out [How to Report Bugs
Effectively](http://www.chiark.greenend.org.uk/~sgtatham/bugs.html).
Please be kind, remember that Gitea comes at no cost to you, and you're Please be kind, remember that Gitea comes at no cost to you, and you're getting free help.
getting free help.
## Discuss your design ## Discuss your design
The project welcomes submissions. If you want to change or add something, The project welcomes submissions but please let everyone know what you're working on if you want to change or add something to the Gitea repositories.
please let everyone know what you're working on—[file an issue](https://github.com/go-gitea/gitea/issues/new)!
Significant changes must go through the [change proposal process](https://github.com/go-gitea/proposals)
before they can be accepted.
This process gives everyone a chance to validate the design, helps Before starting to write something new for the Gitea project, please [file an issue](https://github.com/go-gitea/gitea/issues/new). Significant changes must go through the [change proposal process](https://github.com/go-gitea/proposals) before they can be accepted.
prevent duplication of effort, and ensures that the idea fits inside
the goals for the project and tools. It also checks that the design is This process gives everyone a chance to validate the design, helps prevent duplication of effort, and ensures that the idea fits inside the goals for the project and tools. It also checks that the design is sound before code is written; the code review tool is not the place for high-level discussions.
sound before code is written; the code review tool is not the place for
high-level discussions.
## Testing redux ## Testing redux
Before sending code out for review, run all the tests for the Before sending code out for review, run all the tests for the whole tree to make sure the changes don't break other usage and keep the compatibility on upgrade. To make sure you are running the test suite exactly like we do, you should install the CLI for [Drone CI](https://github.com/drone/drone), as we are using the server for continous testing, following [these instructions](http://readme.drone.io/usage/getting-started-cli). After that you can simply call `drone exec` within your working directory and it will try to run the test suite locally.
whole tree to make sure the changes don't break other usage
and keep the compatibility on upgrade. To make sure you are
running the test suite exactly like we do, you should install
the CLI for [Drone CI](https://github.com/drone/drone), as
we are using the server for continous testing, following [these
instructions](http://readme.drone.io/usage/getting-started-cli). After that,
you can simply call `drone exec` within your working directory and it will try
to run the test suite locally.
## Vendoring ## Vendoring
We keep a cached copy of dependencies within the `vendor/` directory, We keep a cached copy of dependencies within the `vendor/` directory, managing updates via [govendor](http://github.com/kardianos/govendor).
managing updates via [govendor](http://github.com/kardianos/govendor).
Pull requests should only include `vendor/` updates if they are part of Pull requests should only include `vendor/` updates if they are part of the same change, be it a bugfix or a feature addition.
the same change, be it a bugfix or a feature addition.
The `vendor/` update needs to be justified as part of the PR description, The `vendor/` update needs to be justified as part of the PR description, and must be verified by the reviewers and/or merger to always reference an existing upstream commit.
and must be verified by the reviewers and/or merger to always reference
an existing upstream commit.
## Translation
We do all translation work inside [Crowdin](https://crowdin.com/project/gitea).
The only translation that is maintained in this git repository is
[`en_US.ini`](https://github.com/go-gitea/gitea/blob/master/options/locale/locale_en-US.ini)
and is synced regularily to Crowdin. Once a translation has reached
A SATISFACTORY PERCENTAGE it will be synced back into this repo and
included in the next released version.
## Building Gitea
Generally, the go build tools are installed as-needed in the `Makefile`.
An exception are the tools to build the CSS and images.
- To build CSS: Install [Node.js](https://nodejs.org/en/download/package-manager)
with `npm` and then run `npm install` and `make stylesheets`.
- To build Images: ImageMagick, inkscape and zopflipng binaries must be
available in your `PATH` to run `make generate-images`.
## Code review ## Code review
Changes to Gitea must be reviewed before they are acceptedno matter who Changes to Gitea must be reviewed before they are accepted, no matter who makes the change even if it is an owner or a maintainer. We use GitHub's pull request workflow to do that and we also use [LGTM](http://lgtm.co) to ensure every PR is reviewed by at least 2 maintainers.
makes the change, even if they are an owner or a maintainer. We use GitHub's
pull request workflow to do that. And, we also use [LGTM](http://lgtm.co)
to ensure every PR is reviewed by at least 2 maintainers.
Please try to make your pull request easy to review for us. And, please read Please try to make your pull request easy to review for us. Please read the "[How to get faster PR reviews](https://github.com/kubernetes/community/blob/master/contributors/devel/faster_reviews.md)" guide, it has lots of useful tips for any project you may want to contribute. Some of the key points:
the *[How to get faster PR reviews](https://github.com/kubernetes/community/blob/master/contributors/devel/faster_reviews.md)* guide;
it has lots of useful tips for any project you may want to contribute.
Some of the key points:
* Make small pull requests. The smaller, the faster to review and the * Make small pull requests. The smaller, the faster to review and the more likely it will be merged soon.
more likely it will be merged soon. * Don't make changes unrelated to your PR. Maybe there are typos on some comments, maybe refactoring would be welcome on a function... but if that is not related to your PR, please make *another* PR for that.
* Don't make changes unrelated to your PR. Maybe there are typos on * Split big pull requests into multiple small ones. An incremental change will be faster to review than a huge PR.
some comments, maybe refactoring would be welcome on a function... but
if that is not related to your PR, please make *another* PR for that.
* Split big pull requests into multiple small ones. An incremental change
will be faster to review than a huge PR.
## Styleguide ## Styleguide
@@ -141,86 +80,37 @@ import (
) )
``` ```
## Sign-off your work ## Sign your work
The sign-off is a simple line at the end of the explanation for the The sign-off is a simple line at the end of the explanation for the patch. Your signature certifies that you wrote the patch or otherwise have the right to pass it on as an open-source patch. The rules are pretty simple: If you can certify [DCO](DCO), then you just add a line to every git commit message:
patch. Your signature certifies that you wrote the patch or otherwise
have the right to pass it on as an open-source patch. The rules are
pretty simple: If you can certify [DCO](DCO), then you just add a line
to every git commit message:
``` ```
Signed-off-by: Joe Smith <joe.smith@email.com> Signed-off-by: Joe Smith <joe.smith@email.com>
``` ```
Please use your real name; we really dislike pseudonyms or anonymous Please use your real name, we really dislike pseudonyms or anonymous contributions. We are in the open-source world without secrets. If you set your `user.name` and `user.email` git configs, you can sign your commit automatically with `git commit -s`.
contributions. We are in the open-source world without secrets. If you
set your `user.name` and `user.email` git configs, you can sign-off your
commit automatically with `git commit -s`.
## Release Cycle ## Release Cycle
We adopted a release schedule to streamline the process of working We adopted a release schedule to streamline the process of working on, finishing, and issuing releases. The overall goal is to make a major release every two months, which breaks down into one month of general development followed by one month of testing and polishing known as the release freeze. A release is maintained by issuing minor releases to only correct critical problems such as crashes or security issues. All the feature pull requests should be merged in the first month of one release period.
on, finishing, and issuing releases. The overall goal is to make a
minor release every two months, which breaks down into one month of
general development followed by one month of testing and polishing
known as the release freeze. All the feature pull requests should be
merged in the first month of one release period. And, during the frozen
period, a corresponding release branch is open for fixes backported from
master. Release candidates are made during this period for user testing to
obtain a final version that is maintained in this branch. A release is
maintained by issuing patch releases to only correct critical problems
such as crashes or security issues.
Major release cycles are bimonthly. They always begin on the 25th and end on The current release cycle is aligned to start on December 25 to February 24, next is February 25 to April 24, and etc. On this cycle, we also maybe publish the previous release minor version. For example, the current release version is v1.1, but we maybe also publish v1.0.2. When we publish v1.2, then we will stop publish v1.0.3.
the 24th (i.e., the 25th of December to February 24th).
During a development cycle, we may also publish any necessary minor releases
for the previous version. For example, if the latest, published release is
v1.2, then minor changes for the previous release—e.g., v1.1.0 -> v1.1.1—are
still possible.
## Maintainers ## Maintainers
To make sure every PR is checked, we have [team To make sure every PR is checked, we have [team maintainers](MAINTAINERS). Every PR **MUST** be reviewed by at least two maintainers (or owners) before it can get merged. A maintainer should be a contributor of Gitea (or Gogs) and contributed at least 4 accepted PRs. A contributor should apply as a maintainer in the [Discord](https://discord.gg/NsatcWJ) #develop channel. The owners or the team maintainers may invite the contributor. A maintainer should spend some time on code reviews. If a maintainer has no time to do that, they should apply to leave the maintainers team and we will give them the honor of being a member of the [advisors team](https://github.com/orgs/go-gitea/teams/advisors). Of course, if an advisor has time to code review, we will gladly welcome them back to the maintainers team. If a maintainer is inactive for more than 3 months and forgets to leave the maintainers team, the owners may move him or her from the maintainers team to the advisors team.
maintainers](MAINTAINERS). Every PR **MUST** be reviewed by at least
two maintainers (or owners) before it can get merged. A maintainer
should be a contributor of Gitea (or Gogs) and contributed at least
4 accepted PRs. A contributor should apply as a maintainer in the
[Discord](https://discord.gg/NsatcWJ) #develop channel. The owners
or the team maintainers may invite the contributor. A maintainer
should spend some time on code reviews. If a maintainer has no
time to do that, they should apply to leave the maintainers team
and we will give them the honor of being a member of the [advisors
team](https://github.com/orgs/go-gitea/teams/advisors). Of course, if
an advisor has time to code review, we will gladly welcome them back
to the maintainers team. If a maintainer is inactive for more than 3
months and forgets to leave the maintainers team, the owners may move
him or her from the maintainers team to the advisors team.
## Owners ## Owners
Since Gitea is a pure community organization without any company support, Since Gitea is a pure community organization without any company support, to keep the development healthy we will elect three owners every year. All contributors may vote to elect up to three candidates, one of which will be the main owner, and the other two the assistant owners. When the new owners have been elected, the old owners will give up ownership to the newly elected owners. If an owner is unable to do so, the other owners will assist in ceding ownership to the newly elected owners.
to keep the development healthy we will elect three owners every year. All
contributors may vote to elect up to three candidates, one of which will
be the main owner, and the other two the assistant owners. When the new
owners have been elected, the old owners will give up ownership to the
newly elected owners. If an owner is unable to do so, the other owners
will assist in ceding ownership to the newly elected owners.
After the election, the new owners should proactively agree After the election, the new owners should proactively agree with our [CONTRIBUTING](CONTRIBUTING.md) requirements in the [Discord](https://discord.gg/NsatcWJ) #general channel. Below are the words to speak:
with our [CONTRIBUTING](CONTRIBUTING.md) requirements in the
[Discord](https://discord.gg/NsatcWJ) #general channel. Below are the
words to speak:
``` ```
I'm honored to having been elected an owner of Gitea, I agree with I'm honored to having been elected an owner of Gitea, I agree with [CONTRIBUTING](CONTRIBUTING.md). I will spend part of my time on Gitea and lead the development of Gitea.
[CONTRIBUTING](CONTRIBUTING.md). I will spend part of my time on Gitea
and lead the development of Gitea.
``` ```
To honor the past owners, here's the history of the owners and the time To honor the past owners, here's the history of the owners and the time they served:
they served:
* 2016-11-04 ~ 2017-12-31 * 2016-11-04 ~ 2017-12-31
* [Lunny Xiao](https://github.com/lunny) <xiaolunwen@gmail.com> * [Lunny Xiao](https://github.com/lunny) <xiaolunwen@gmail.com>
@@ -229,16 +119,9 @@ they served:
## Versions ## Versions
Gitea has the `master` branch as a tip branch and has version branches Gitea has the `master` branch as a tip branch and has version branches such as `v0.9`. `v0.9` is a release branch and we will tag `v0.9.0` for binary download. If `v0.9.0` has bugs, we will accept pull requests on the `v0.9` branch and publish a `v0.9.1` tag, after bringing the bug fix also to the master branch.
such as `release/v0.9`. `release/v0.9` is a release branch and we will
tag `v0.9.0` for binary download. If `v0.9.0` has bugs, we will accept
pull requests on the `release/v0.9` branch and publish a `v0.9.1` tag,
after bringing the bug fix also to the master branch.
Since the `master` branch is a tip version, if you wish to use Gitea Since the `master` branch is a tip version, if you wish to use Gitea in production, please download the latest release tag version. All the branches will be protected via GitHub, all the PRs to every branch must be reviewed by two maintainers and must pass the automatic tests.
in production, please download the latest release tag version. All the
branches will be protected via GitHub, all the PRs to every branch must
be reviewed by two maintainers and must pass the automatic tests.
## Copyright ## Copyright
@@ -250,6 +133,4 @@ Code that you contribute should use the standard copyright header:
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
``` ```
Files in the repository contain copyright from the year they are added Files in the repository contain copyright from the year they are added to the year they are last changed. If the copyright author is changed, just paste the header below the old one.
to the year they are last changed. If the copyright author is changed,
just paste the header below the old one.

View File

@@ -1,6 +1,5 @@
FROM alpine:3.6 FROM alpine:3.5
MAINTAINER Thomas Boerger <thomas@webhippie.de>
LABEL maintainer="The Gitea Authors"
EXPOSE 22 3000 EXPOSE 22 3000
@@ -14,7 +13,6 @@ RUN apk --no-cache add \
s6 \ s6 \
curl \ curl \
openssh \ openssh \
gettext \
tzdata tzdata
RUN addgroup \ RUN addgroup \
-S -g 1000 \ -S -g 1000 \

View File

@@ -1,6 +1,4 @@
FROM multiarch/alpine:aarch64-v3.6 FROM multiarch/alpine:aarch64-v3.5
LABEL maintainer="The Gitea Authors"
EXPOSE 22 3000 EXPOSE 22 3000
@@ -14,7 +12,6 @@ RUN apk --no-cache add \
s6 \ s6 \
curl \ curl \
openssh \ openssh \
gettext \
tzdata tzdata
RUN addgroup \ RUN addgroup \
-S -g 1000 \ -S -g 1000 \

View File

@@ -1,6 +1,5 @@
FROM multiarch/alpine:armhf-v3.6 FROM multiarch/alpine:armhf-v3.5
MAINTAINER Thomas Boerger <thomas@webhippie.de>
LABEL maintainer="The Gitea Authors"
EXPOSE 22 3000 EXPOSE 22 3000
@@ -14,7 +13,6 @@ RUN apk --no-cache add \
s6 \ s6 \
curl \ curl \
openssh \ openssh \
gettext \
tzdata tzdata
RUN addgroup \ RUN addgroup \
-S -g 1000 \ -S -g 1000 \

View File

@@ -16,5 +16,3 @@ Patrick G <geek1011@outlook.com> (@geek1011)
Antoine Girard <sapk@sapk.fr> (@sapk) Antoine Girard <sapk@sapk.fr> (@sapk)
Lauris Bukšis-Haberkorns <lauris@nix.lv> (@lafriks) Lauris Bukšis-Haberkorns <lauris@nix.lv> (@lafriks)
Jonas Östanbäck <jonas.ostanback@gmail.com> (@cez81) Jonas Östanbäck <jonas.ostanback@gmail.com> (@cez81)
David Schneiderbauer <dschneiderbauer@gmail.com> (@daviian)
Peter Žeby <morlinest@gmail.com> (@morlinest)

View File

@@ -15,6 +15,7 @@ else
endif endif
BINDATA := modules/{options,public,templates}/bindata.go BINDATA := modules/{options,public,templates}/bindata.go
STYLESHEETS := $(wildcard public/less/index.less public/less/_*.less)
DOCKER_TAG := gitea/gitea:latest DOCKER_TAG := gitea/gitea:latest
GOFILES := $(shell find . -name "*.go" -type f ! -path "./vendor/*" ! -path "*/bindata.go") GOFILES := $(shell find . -name "*.go" -type f ! -path "./vendor/*" ! -path "*/bindata.go")
GOFMT ?= gofmt -s GOFMT ?= gofmt -s
@@ -31,15 +32,6 @@ TAGS ?=
TMPDIR := $(shell mktemp -d 2>/dev/null || mktemp -d -t 'gitea-temp') TMPDIR := $(shell mktemp -d 2>/dev/null || mktemp -d -t 'gitea-temp')
TEST_MYSQL_HOST ?= mysql:3306
TEST_MYSQL_DBNAME ?= testgitea
TEST_MYSQL_USERNAME ?= root
TEST_MYSQL_PASSWORD ?=
TEST_PGSQL_HOST ?= pgsql:5432
TEST_PGSQL_DBNAME ?= testgitea
TEST_PGSQL_USERNAME ?= postgres
TEST_PGSQL_PASSWORD ?= postgres
ifeq ($(OS), Windows_NT) ifeq ($(OS), Windows_NT)
EXECUTABLE := gitea.exe EXECUTABLE := gitea.exe
else else
@@ -62,11 +54,7 @@ all: build
.PHONY: clean .PHONY: clean
clean: clean:
$(GO) clean -i ./... $(GO) clean -i ./...
rm -rf $(EXECUTABLE) $(DIST) $(BINDATA) \ rm -rf $(EXECUTABLE) $(DIST) $(BINDATA) integrations*.test
integrations*.test \
integrations/gitea-integration-pgsql/ integrations/gitea-integration-mysql/ integrations/gitea-integration-sqlite/ \
integrations/indexers-mysql/ integrations/indexers-pgsql integrations/indexers-sqlite \
integrations/mysql.ini integrations/pgsql.ini
.PHONY: fmt .PHONY: fmt
fmt: fmt:
@@ -89,6 +77,8 @@ generate-swagger:
$(GO) get -u github.com/go-swagger/go-swagger/cmd/swagger; \ $(GO) get -u github.com/go-swagger/go-swagger/cmd/swagger; \
fi fi
swagger generate spec -o ./public/swagger.v1.json swagger generate spec -o ./public/swagger.v1.json
$(SED_INPLACE) "s;\".ref\": \"#/definitions/GPGKey\";\"type\": \"object\";g" ./public/swagger.v1.json
$(SED_INPLACE) "s;^ \".ref\": \"#/definitions/Repository\"; \"type\": \"object\";g" ./public/swagger.v1.json
.PHONY: errcheck .PHONY: errcheck
errcheck: errcheck:
@@ -129,19 +119,18 @@ fmt-check:
fi; fi;
.PHONY: test .PHONY: test
test: test: fmt-check
$(GO) test $(PACKAGES) $(GO) test $(PACKAGES)
.PHONY: coverage .PHONY: test-coverage
coverage: test-coverage: unit-test-coverage integration-test-coverage
@hash gocovmerge > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ @hash gocovmerge > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
$(GO) get -u github.com/wadey/gocovmerge; \ $(GO) get -u github.com/wadey/gocovmerge; \
fi fi
echo "mode: set" > coverage.all
for PKG in $(PACKAGES); do\ for PKG in $(PACKAGES); do\
touch $$GOPATH/src/$$PKG/coverage.out;\
egrep "$$PKG[^/]*\.go" integration.coverage.out > int.coverage.out;\ egrep "$$PKG[^/]*\.go" integration.coverage.out > int.coverage.out;\
gocovmerge $$GOPATH/src/$$PKG/coverage.out int.coverage.out > pkg.coverage.out;\ gocovmerge $$GOPATH/src/$$PKG/coverage.out int.coverage.out > pkg.coverage.out;\
grep -h -v "^mode:" pkg.coverage.out >> coverage.all;\
mv pkg.coverage.out $$GOPATH/src/$$PKG/coverage.out;\ mv pkg.coverage.out $$GOPATH/src/$$PKG/coverage.out;\
rm int.coverage.out;\ rm int.coverage.out;\
done; done;
@@ -167,48 +156,34 @@ test-vendor:
test-sqlite: integrations.sqlite.test test-sqlite: integrations.sqlite.test
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/sqlite.ini ./integrations.sqlite.test GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/sqlite.ini ./integrations.sqlite.test
generate-ini:
sed -e 's|{{TEST_MYSQL_HOST}}|${TEST_MYSQL_HOST}|g' \
-e 's|{{TEST_MYSQL_DBNAME}}|${TEST_MYSQL_DBNAME}|g' \
-e 's|{{TEST_MYSQL_USERNAME}}|${TEST_MYSQL_USERNAME}|g' \
-e 's|{{TEST_MYSQL_PASSWORD}}|${TEST_MYSQL_PASSWORD}|g' \
integrations/mysql.ini.tmpl > integrations/mysql.ini
sed -e 's|{{TEST_PGSQL_HOST}}|${TEST_PGSQL_HOST}|g' \
-e 's|{{TEST_PGSQL_DBNAME}}|${TEST_PGSQL_DBNAME}|g' \
-e 's|{{TEST_PGSQL_USERNAME}}|${TEST_PGSQL_USERNAME}|g' \
-e 's|{{TEST_PGSQL_PASSWORD}}|${TEST_PGSQL_PASSWORD}|g' \
integrations/pgsql.ini.tmpl > integrations/pgsql.ini
.PHONY: test-mysql .PHONY: test-mysql
test-mysql: integrations.mysql.test generate-ini test-mysql: integrations.test
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql.ini ./integrations.mysql.test GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql.ini ./integrations.test
.PHONY: test-pgsql .PHONY: test-pgsql
test-pgsql: integrations.pgsql.test generate-ini test-pgsql: integrations.test
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/pgsql.ini ./integrations.pgsql.test GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/pgsql.ini ./integrations.test
.PHONY: bench-sqlite .PHONY: bench-sqlite
bench-sqlite: integrations.sqlite.test bench-sqlite: integrations.sqlite.test
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/sqlite.ini ./integrations.sqlite.test -test.bench . GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/sqlite.ini ./integrations.sqlite.test -test.bench .
.PHONY: bench-mysql .PHONY: bench-mysql
bench-mysql: integrations.mysql.test generate-ini bench-mysql: integrations.test
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql.ini ./integrations.mysql.test -test.bench . GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql.ini ./integrations.test -test.bench .
.PHONY: bench-pgsql .PHONY: bench-pgsql
bench-pgsql: integrations.pgsql.test generate-ini bench-pgsql: integrations.test
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/pgsql.ini ./integrations.pgsql.test -test.bench . GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/pgsql.ini ./integrations.test -test.bench .
.PHONY: integration-test-coverage .PHONY: integration-test-coverage
integration-test-coverage: integrations.cover.test generate-ini integration-test-coverage: integrations.cover.test
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql.ini ./integrations.cover.test -test.coverprofile=integration.coverage.out GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql.ini ./integrations.cover.test -test.coverprofile=integration.coverage.out
integrations.mysql.test: $(SOURCES) integrations.test: $(SOURCES)
$(GO) test -c code.gitea.io/gitea/integrations -o integrations.mysql.test $(GO) test -c code.gitea.io/gitea/integrations
integrations.pgsql.test: $(SOURCES)
$(GO) test -c code.gitea.io/gitea/integrations -o integrations.pgsql.test
integrations.sqlite.test: $(SOURCES) integrations.sqlite.test: $(SOURCES)
$(GO) test -c code.gitea.io/gitea/integrations -o integrations.sqlite.test -tags 'sqlite' $(GO) test -c code.gitea.io/gitea/integrations -o integrations.sqlite.test -tags 'sqlite'
@@ -287,25 +262,31 @@ public/js/index.js: $(JAVASCRIPTS)
cat $< >| $@ cat $< >| $@
.PHONY: stylesheets-check .PHONY: stylesheets-check
stylesheets-check: generate-stylesheets stylesheets-check: stylesheets
@diff=$$(git diff public/css/index.css); \ @diff=$$(git diff public/css/index.css); \
if [ -n "$$diff" ]; then \ if [ -n "$$diff" ]; then \
echo "Please run 'make generate-stylesheets' and commit the result:"; \ echo "Please run 'make stylesheets' and commit the result:"; \
echo "$${diff}"; \ echo "$${diff}"; \
exit 1; \ exit 1; \
fi; fi;
.PHONY: generate-stylesheets .PHONY: stylesheets
generate-stylesheets: stylesheets: public/css/index.css
node_modules/.bin/lessc --no-ie-compat --clean-css public/less/index.less public/css/index.css
.IGNORE: public/css/index.css
public/css/index.css: $(STYLESHEETS)
@which lessc > /dev/null; if [ $$? -ne 0 ]; then \
$(GO) get -u github.com/kib357/less-go/lessc; \
fi
lessc -i $< -o $@
.PHONY: swagger-ui .PHONY: swagger-ui
swagger-ui: swagger-ui:
rm -Rf public/vendor/assets/swagger-ui rm -Rf public/vendor/assets/swagger-ui
git clone --depth=10 -b v3.3.2 --single-branch https://github.com/swagger-api/swagger-ui.git $(TMPDIR)/swagger-ui git clone --depth=10 -b v3.0.7 --single-branch https://github.com/swagger-api/swagger-ui.git $(TMPDIR)/swagger-ui
mv $(TMPDIR)/swagger-ui/dist public/vendor/assets/swagger-ui mv $(TMPDIR)/swagger-ui/dist public/vendor/assets/swagger-ui
rm -Rf $(TMPDIR)/swagger-ui rm -Rf $(TMPDIR)/swagger-ui
$(SED_INPLACE) "s;http://petstore.swagger.io/v2/swagger.json;../../../swagger.v1.json;g" public/vendor/assets/swagger-ui/index.html $(SED_INPLACE) "s;http://petstore.swagger.io/v2/swagger.json;../../swagger.v1.json;g" public/assets/swagger-ui/index.html
.PHONY: update-translations .PHONY: update-translations
update-translations: update-translations:

View File

@@ -6,45 +6,30 @@
[![Join the Discord chat at https://discord.gg/NsatcWJ](https://img.shields.io/discord/322538954119184384.svg)](https://discord.gg/NsatcWJ) [![Join the Discord chat at https://discord.gg/NsatcWJ](https://img.shields.io/discord/322538954119184384.svg)](https://discord.gg/NsatcWJ)
[![Join the Matrix chat at https://matrix.to/#/#gitea:matrix.org](https://img.shields.io/badge/matrix-%23gitea%3Amatrix.org-7bc9a4.svg)](https://matrix.to/#/#gitea:matrix.org) [![Join the Matrix chat at https://matrix.to/#/#gitea:matrix.org](https://img.shields.io/badge/matrix-%23gitea%3Amatrix.org-7bc9a4.svg)](https://matrix.to/#/#gitea:matrix.org)
[![](https://images.microbadger.com/badges/image/gitea/gitea.svg)](https://microbadger.com/images/gitea/gitea "Get your own image badge on microbadger.com") [![](https://images.microbadger.com/badges/image/gitea/gitea.svg)](https://microbadger.com/images/gitea/gitea "Get your own image badge on microbadger.com")
[![codecov](https://codecov.io/gh/go-gitea/gitea/branch/master/graph/badge.svg)](https://codecov.io/gh/go-gitea/gitea) [![Coverage Status](https://coverage.gitea.io/badges/go-gitea/gitea/coverage.svg)](https://coverage.gitea.io/go-gitea/gitea)
[![Go Report Card](https://goreportcard.com/badge/code.gitea.io/gitea)](https://goreportcard.com/report/code.gitea.io/gitea) [![Go Report Card](https://goreportcard.com/badge/code.gitea.io/gitea)](https://goreportcard.com/report/code.gitea.io/gitea)
[![GoDoc](https://godoc.org/code.gitea.io/gitea?status.svg)](https://godoc.org/code.gitea.io/gitea) [![GoDoc](https://godoc.org/code.gitea.io/gitea?status.svg)](https://godoc.org/code.gitea.io/gitea)
[![Release](https://github-release-version.herokuapp.com/github/go-gitea/gitea/release.svg?style=flat)](https://github.com/go-gitea/gitea/releases/latest) [![Release](https://github-release-version.herokuapp.com/github/go-gitea/gitea/release.svg?style=flat)](https://github.com/go-gitea/gitea/releases/latest)
| | | | | | | |
|:---:|:---:|:---:| |:---:|:---:|:---:|
|![Dashboard](https://image.ibb.co/dms6DG/1.png)|![Repository](https://image.ibb.co/m6MSLw/2.png)|![Commits History](https://image.ibb.co/cjrSLw/3.png)| |![Dashboard](https://i.imgur.com/3iEQsux.jpg)|![Repository](https://i.imgur.com/glqFnj8.jpg)|![Commits History](https://i.imgur.com/ad1FEpi.jpg)|
|![Branches](https://image.ibb.co/e6vbDG/4.png)|![Issues](https://image.ibb.co/bJTJSb/5.png)|![Pull Request View](https://image.ibb.co/e02dSb/6.png)| |![Profile](https://i.imgur.com/q81EcGa.jpg)|![Admin Dashboard](https://i.imgur.com/L2CQeN0.jpg)|![Diff](https://i.imgur.com/cNuvMum.jpg)|
|![Releases](https://image.ibb.co/cUzgfw/7.png)|![Activity](https://image.ibb.co/eZgGDG/8.png)|![Wiki](https://image.ibb.co/dYV9YG/9.png)| |![Issues](https://i.imgur.com/xCYRqaF.jpg)|![Releases](https://i.imgur.com/ILpRBCe.jpg)|![Organization](https://i.imgur.com/0BHnrcL.jpg)|
|![Diff](https://image.ibb.co/ewA9YG/10.png)|![Organization](https://image.ibb.co/ceOwDG/11.png)|![Profile](https://image.ibb.co/c44Q7b/12.png)|
## Purpose ## Purpose
The goal of this project is to make the easiest, fastest, and most The goal of this project is to make the easiest, fastest, and most painless way of setting up a self-hosted Git service. Using Go, this can be done with an independent binary distribution across **all platforms** which Go supports, including Linux, macOS, and Windows on x86, amd64, ARM and PowerPC architectures. Want to try it before doing anything else? Do it [with the online demo](https://try.gitea.io/)! This project has been [forked](https://blog.gitea.io/2016/12/welcome-to-gitea/) from [Gogs](https://gogs.io).
painless way of setting up a self-hosted Git service.
Using Go, this can be done with an independent binary distribution across
**all platforms** which Go supports, including Linux, macOS, and Windows
on x86, amd64, ARM and PowerPC architectures.
Want to try it before doing anything else?
Do it [with the online demo](https://try.gitea.io/)!
This project has been
[forked](https://blog.gitea.io/2016/12/welcome-to-gitea/) from
[Gogs](https://gogs.io) since 2016.11 but changed a lot.
## Notes ## Notes
1. **YOU MUST READ THE [CONTRIBUTORS GUIDE](CONTRIBUTING.md) BEFORE STARTING TO WORK ON A PULL REQUEST.** 1. **YOU MUST READ THE [CONTRIBUTORS GUIDE](CONTRIBUTING.md) BEFORE STARTING TO WORK ON A PULL REQUEST.**
2. If you have found a vulnerability in the project, please write privately to **security@gitea.io**. Thanks! 2. If you found a vulnerability in the project, please write privately to **security@gitea.io**. Thanks!
3. If you're interested in using our APIs, we have experimental support with [documentation](https://godoc.org/code.gitea.io/sdk/gitea). 3. If you're interested in using our APIs, we have experimental support with [documentation](https://godoc.org/code.gitea.io/sdk/gitea).
## Docs ## Docs
For more information and instructions about how to install Gitea, please look For more information and instructions about how to install Gitea please look at our [documentation](https://docs.gitea.io/en-us/). If you cannot find some specific information, then head over to our [Discord server](https://discord.gg/NsatcWJ) or [Matrix room](https://matrix.to/#/#gitea:matrix.org) to chat with us or use the [forum](https://discourse.gitea.io/).
at our [documentation](https://docs.gitea.io/en-us/). If you have questions
that are not covered by the documentation, you can get in contact with us on
our [Discord server](https://discord.gg/NsatcWJ),
[Matrix room](https://matrix.to/#/#gitea:matrix.org),
or [forum](https://discourse.gitea.io/)!
## Contributing ## Contributing
@@ -58,6 +43,4 @@ Fork -> Patch -> Push -> Pull Request
## License ## License
This project is licensed under the MIT License. This project is licensed under the MIT License. See the [LICENSE](https://github.com/go-gitea/gitea/blob/master/LICENSE) file for the full license text.
See the [LICENSE](https://github.com/go-gitea/gitea/blob/master/LICENSE) file
for the full license text.

View File

@@ -12,10 +12,9 @@
| | | | | | | |
|:---:|:---:|:---:| |:---:|:---:|:---:|
|![Dashboard](https://image.ibb.co/dms6DG/1.png)|![Repository](https://image.ibb.co/m6MSLw/2.png)|![Commits History](https://image.ibb.co/cjrSLw/3.png)| |![Dashboard](https://i.imgur.com/3iEQsux.jpg)|![Repository](https://i.imgur.com/glqFnj8.jpg)|![Commits History](https://i.imgur.com/ad1FEpi.jpg)|
|![Branches](https://image.ibb.co/e6vbDG/4.png)|![Issues](https://image.ibb.co/bJTJSb/5.png)|![Pull Request View](https://image.ibb.co/e02dSb/6.png)| |![Profile](https://i.imgur.com/q81EcGa.jpg)|![Admin Dashboard](https://i.imgur.com/L2CQeN0.jpg)|![Diff](https://i.imgur.com/cNuvMum.jpg)|
|![Releases](https://image.ibb.co/cUzgfw/7.png)|![Activity](https://image.ibb.co/eZgGDG/8.png)|![Wiki](https://image.ibb.co/dYV9YG/9.png)| |![Issues](https://i.imgur.com/xCYRqaF.jpg)|![Releases](https://i.imgur.com/ILpRBCe.jpg)|![Organization](https://i.imgur.com/0BHnrcL.jpg)|
|![Diff](https://image.ibb.co/ewA9YG/10.png)|![Organization](https://image.ibb.co/ceOwDG/11.png)|![Profile](https://image.ibb.co/c44Q7b/12.png)|
## 目标 ## 目标

View File

@@ -126,7 +126,10 @@ func runDump(ctx *cli.Context) error {
var sessionAbsPath string var sessionAbsPath string
if setting.SessionConfig.Provider == "file" { if setting.SessionConfig.Provider == "file" {
sessionAbsPath = setting.SessionConfig.ProviderConfig if len(setting.SessionConfig.ProviderConfig) == 0 {
setting.SessionConfig.ProviderConfig = "data/sessions"
}
sessionAbsPath, _ = filepath.Abs(setting.SessionConfig.ProviderConfig)
} }
if err := zipAddDirectoryExclude(z, "data", setting.AppDataPath, sessionAbsPath); err != nil { if err := zipAddDirectoryExclude(z, "data", setting.AppDataPath, sessionAbsPath); err != nil {
log.Fatalf("Failed to include data directory: %v", err) log.Fatalf("Failed to include data directory: %v", err)

View File

@@ -84,10 +84,9 @@ func runHookPreReceive(c *cli.Context) error {
// the environment setted on serv command // the environment setted on serv command
repoID, _ := strconv.ParseInt(os.Getenv(models.ProtectedBranchRepoID), 10, 64) repoID, _ := strconv.ParseInt(os.Getenv(models.ProtectedBranchRepoID), 10, 64)
isWiki := (os.Getenv(models.EnvRepoIsWiki) == "true") isWiki := (os.Getenv(models.EnvRepoIsWiki) == "true")
username := os.Getenv(models.EnvRepoUsername) //username := os.Getenv(models.EnvRepoUsername)
reponame := os.Getenv(models.EnvRepoName) //reponame := os.Getenv(models.EnvRepoName)
userIDStr := os.Getenv(models.EnvPusherID) //repoPath := models.RepoPath(username, reponame)
repoPath := models.RepoPath(username, reponame)
buf := bytes.NewBuffer(nil) buf := bytes.NewBuffer(nil)
scanner := bufio.NewScanner(os.Stdin) scanner := bufio.NewScanner(os.Stdin)
@@ -105,10 +104,22 @@ func runHookPreReceive(c *cli.Context) error {
continue continue
} }
oldCommitID := string(fields[0]) //oldCommitID := string(fields[0])
newCommitID := string(fields[1]) newCommitID := string(fields[1])
refFullName := string(fields[2]) refFullName := string(fields[2])
// FIXME: when we add feature to protected branch to deny force push, then uncomment below
/*var isForce bool
// detect force push
if git.EmptySHA != oldCommitID {
output, err := git.NewCommand("rev-list", oldCommitID, "^"+newCommitID).RunInDir(repoPath)
if err != nil {
fail("Internal error", "Fail to detect force push: %v", err)
} else if len(output) > 0 {
isForce = true
}
}*/
branchName := strings.TrimPrefix(refFullName, git.BranchPrefix) branchName := strings.TrimPrefix(refFullName, git.BranchPrefix)
protectBranch, err := private.GetProtectedBranchBy(repoID, branchName) protectBranch, err := private.GetProtectedBranchBy(repoID, branchName)
if err != nil { if err != nil {
@@ -116,27 +127,12 @@ func runHookPreReceive(c *cli.Context) error {
} }
if protectBranch != nil && protectBranch.IsProtected() { if protectBranch != nil && protectBranch.IsProtected() {
// detect force push
if git.EmptySHA != oldCommitID {
output, err := git.NewCommand("rev-list", "--max-count=1", oldCommitID, "^"+newCommitID).RunInDir(repoPath)
if err != nil {
fail("Internal error", "Fail to detect force push: %v", err)
} else if len(output) > 0 {
fail(fmt.Sprintf("branch %s is protected from force push", branchName), "")
}
}
// check and deletion // check and deletion
if newCommitID == git.EmptySHA { if newCommitID == git.EmptySHA {
fail(fmt.Sprintf("branch %s is protected from deletion", branchName), "") fail(fmt.Sprintf("branch %s is protected from deletion", branchName), "")
} else { } else if !protectBranch.CanPush {
userID, _ := strconv.ParseInt(userIDStr, 10, 64)
canPush, err := private.CanUserPush(protectBranch.ID, userID)
if err != nil {
fail("Internal error", "Fail to detect user can push: %v", err)
} else if !canPush {
fail(fmt.Sprintf("protected branch %s can not be pushed to", branchName), "") fail(fmt.Sprintf("protected branch %s can not be pushed to", branchName), "")
} //fail(fmt.Sprintf("branch %s is protected from force push", branchName), "")
} }
} }
} }

View File

@@ -50,9 +50,9 @@ func setup(logPath string) error {
models.LoadConfigs() models.LoadConfigs()
if setting.UseSQLite3 || setting.UseTiDB { if setting.UseSQLite3 || setting.UseTiDB {
workPath := setting.AppWorkPath workDir, _ := setting.WorkDir()
if err := os.Chdir(workPath); err != nil { if err := os.Chdir(workDir); err != nil {
log.GitLogger.Fatal(4, "Failed to change directory %s: %v", workPath, err) log.GitLogger.Fatal(4, "Failed to change directory %s: %v", workDir, err)
} }
} }

View File

@@ -14,15 +14,12 @@ import (
"strings" "strings"
"code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/markup/external"
"code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/routers" "code.gitea.io/gitea/routers"
"code.gitea.io/gitea/routers/routes" "code.gitea.io/gitea/routers/routes"
"github.com/Unknwon/com"
context2 "github.com/gorilla/context" context2 "github.com/gorilla/context"
"github.com/urfave/cli" "github.com/urfave/cli"
ini "gopkg.in/ini.v1"
) )
// CmdWeb represents the available web sub-command. // CmdWeb represents the available web sub-command.
@@ -62,8 +59,6 @@ func runWeb(ctx *cli.Context) error {
routers.GlobalInit() routers.GlobalInit()
external.RegisterParsers()
m := routes.NewMacaron() m := routes.NewMacaron()
routes.RegisterRoutes(m) routes.RegisterRoutes(m)
@@ -71,34 +66,6 @@ func runWeb(ctx *cli.Context) error {
if ctx.IsSet("port") { if ctx.IsSet("port") {
setting.AppURL = strings.Replace(setting.AppURL, setting.HTTPPort, ctx.String("port"), 1) setting.AppURL = strings.Replace(setting.AppURL, setting.HTTPPort, ctx.String("port"), 1)
setting.HTTPPort = ctx.String("port") setting.HTTPPort = ctx.String("port")
switch setting.Protocol {
case setting.UnixSocket:
case setting.FCGI:
default:
// Save LOCAL_ROOT_URL if port changed
cfg := ini.Empty()
if com.IsFile(setting.CustomConf) {
// Keeps custom settings if there is already something.
if err := cfg.Append(setting.CustomConf); err != nil {
return fmt.Errorf("Failed to load custom conf '%s': %v", setting.CustomConf, err)
}
}
defaultLocalURL := string(setting.Protocol) + "://"
if setting.HTTPAddr == "0.0.0.0" {
defaultLocalURL += "localhost"
} else {
defaultLocalURL += setting.HTTPAddr
}
defaultLocalURL += ":" + setting.HTTPPort + "/"
cfg.Section("server").Key("LOCAL_ROOT_URL").SetValue(defaultLocalURL)
if err := cfg.SaveTo(setting.CustomConf); err != nil {
return fmt.Errorf("Error saving generated JWT Secret to custom config: %v", err)
}
}
} }
var listenAddr string var listenAddr string

53
conf/app.ini vendored
View File

@@ -23,8 +23,6 @@ PULL_REQUEST_QUEUE_LENGTH = 1000
PREFERRED_LICENSES = Apache License 2.0,MIT License PREFERRED_LICENSES = Apache License 2.0,MIT License
; Disable ability to interact with repositories by HTTP protocol ; Disable ability to interact with repositories by HTTP protocol
DISABLE_HTTP_GIT = false DISABLE_HTTP_GIT = false
; Force ssh:// clone url instead of scp-style uri when default SSH port is used
USE_COMPAT_SSH_URI = false
[repository.editor] [repository.editor]
; List of file extensions that should have line wraps in the CodeMirror editor ; List of file extensions that should have line wraps in the CodeMirror editor
@@ -113,8 +111,6 @@ LOCAL_ROOT_URL = %(PROTOCOL)s://%(HTTP_ADDR)s:%(HTTP_PORT)s/
DISABLE_SSH = false DISABLE_SSH = false
; Whether use builtin SSH server or not. ; Whether use builtin SSH server or not.
START_SSH_SERVER = false START_SSH_SERVER = false
; Username to use for builtin SSH server. If blank, then it is the value of RUN_USER.
BUILTIN_SSH_SERVER_USER =
; Domain name to be exposed in clone URL ; Domain name to be exposed in clone URL
SSH_DOMAIN = %(DOMAIN)s SSH_DOMAIN = %(DOMAIN)s
; Network interface builtin SSH server listens on ; Network interface builtin SSH server listens on
@@ -125,15 +121,6 @@ SSH_PORT = 22
SSH_LISTEN_PORT = %(SSH_PORT)s SSH_LISTEN_PORT = %(SSH_PORT)s
; Root path of SSH directory, default is '~/.ssh', but you have to use '/home/git/.ssh'. ; Root path of SSH directory, default is '~/.ssh', but you have to use '/home/git/.ssh'.
SSH_ROOT_PATH = SSH_ROOT_PATH =
; For built-in SSH server only, choose the ciphers to support for SSH connections,
; for system SSH this setting has no effect
SSH_SERVER_CIPHERS = aes128-ctr, aes192-ctr, aes256-ctr, aes128-gcm@openssh.com, arcfour256, arcfour128
; For built-in SSH server only, choose the key exchange algorithms to support for SSH connections,
; for system SSH this setting has no effect
SSH_SERVER_KEY_EXCHANGES = diffie-hellman-group1-sha1, diffie-hellman-group14-sha1, ecdh-sha2-nistp256, ecdh-sha2-nistp384, ecdh-sha2-nistp521, curve25519-sha256@libssh.org
; For built-in SSH server only, choose the MACs to support for SSH connections,
; for system SSH this setting has no effect
SSH_SERVER_MACS = hmac-sha2-256-etm@openssh.com, hmac-sha2-256, hmac-sha1, hmac-sha1-96
; Directory to create temporary files when test public key using ssh-keygen, ; Directory to create temporary files when test public key using ssh-keygen,
; default is system temporary directory. ; default is system temporary directory.
SSH_KEY_TEST_PATH = SSH_KEY_TEST_PATH =
@@ -193,16 +180,10 @@ SSL_MODE = disable
PATH = data/gitea.db PATH = data/gitea.db
; For "sqlite3" only. Query timeout ; For "sqlite3" only. Query timeout
SQLITE_TIMEOUT = 500 SQLITE_TIMEOUT = 500
; For iterate buffer, default is 50
ITERATE_BUFFER_SIZE = 50
[indexer] [indexer]
ISSUE_INDEXER_PATH = indexers/issues.bleve ISSUE_INDEXER_PATH = indexers/issues.bleve
; repo indexer by default disabled, since it uses a lot of disk space
REPO_INDEXER_ENABLED = false
REPO_INDEXER_PATH = indexers/repos.bleve
UPDATE_BUFFER_LEN = 20 UPDATE_BUFFER_LEN = 20
MAX_FILE_SIZE = 1048576
[admin] [admin]
; Disable regular (non-admin) users to create organizations ; Disable regular (non-admin) users to create organizations
@@ -223,8 +204,6 @@ REVERSE_PROXY_AUTHENTICATION_USER = X-WEBAUTH-USER
MIN_PASSWORD_LENGTH = 6 MIN_PASSWORD_LENGTH = 6
; True when users are allowed to import local server paths ; True when users are allowed to import local server paths
IMPORT_LOCAL_PATHS = false IMPORT_LOCAL_PATHS = false
; Prevent all users (including admin) from creating custom git hooks
DISABLE_GIT_HOOKS = false
[openid] [openid]
; ;
@@ -255,7 +234,7 @@ ENABLE_OPENID_SIGNIN = true
; Example value: trusted.domain.org trusted.domain.net ; Example value: trusted.domain.org trusted.domain.net
WHITELISTED_URIS = WHITELISTED_URIS =
; Forbidden URI patterns (POSIX regexp). ; Forbidden URI patterns (POSIX regexp).
; Space separated. ; Space sepaated.
; Only used if WHITELISTED_URIS is blank. ; Only used if WHITELISTED_URIS is blank.
; Example value: loadaverage.org/badguy stackexchange.com/.*spammer ; Example value: loadaverage.org/badguy stackexchange.com/.*spammer
BLACKLISTED_URIS = BLACKLISTED_URIS =
@@ -284,12 +263,6 @@ DEFAULT_KEEP_EMAIL_PRIVATE = false
; Default value for AllowCreateOrganization ; Default value for AllowCreateOrganization
; New user will have rights set to create organizations depending on this setting ; New user will have rights set to create organizations depending on this setting
DEFAULT_ALLOW_CREATE_ORGANIZATION = true DEFAULT_ALLOW_CREATE_ORGANIZATION = true
; Default value for EnableTimetracking
; Repositories will use timetracking by default depending on this setting
DEFAULT_ENABLE_TIMETRACKING = true
; Default value for AllowOnlyContributorsToTrackTime
; Only users with write permissions could track time if this is true
DEFAULT_ALLOW_ONLY_CONTRIBUTORS_TO_TRACK_TIME = true
; Default value for the domain part of the user's email address in the git log ; Default value for the domain part of the user's email address in the git log
; if he has set KeepEmailPrivate true. The user's email replaced with a ; if he has set KeepEmailPrivate true. The user's email replaced with a
; concatenation of the user name in lower case, "@" and NO_REPLY_ADDRESS. ; concatenation of the user name in lower case, "@" and NO_REPLY_ADDRESS.
@@ -335,10 +308,8 @@ PASSWD =
SEND_AS_PLAIN_TEXT = false SEND_AS_PLAIN_TEXT = false
; Enable sendmail (override SMTP) ; Enable sendmail (override SMTP)
USE_SENDMAIL = false USE_SENDMAIL = false
; Specify an alternative sendmail binary ; Specifiy an alternative sendmail binary
SENDMAIL_PATH = sendmail SENDMAIL_PATH = sendmail
; Specify any extra sendmail arguments
SENDMAIL_ARGS =
[cache] [cache]
; Either "memory", "redis", or "memcache", default is "memory" ; Either "memory", "redis", or "memcache", default is "memory"
@@ -349,9 +320,6 @@ INTERVAL = 60
; redis: network=tcp,addr=:6379,password=macaron,db=0,pool_size=100,idle_timeout=180 ; redis: network=tcp,addr=:6379,password=macaron,db=0,pool_size=100,idle_timeout=180
; memcache: `127.0.0.1:11211` ; memcache: `127.0.0.1:11211`
HOST = HOST =
; Time to keep items in cache if not used, default is 16 hours.
; Setting it to 0 disables caching
ITEM_TTL = 16h
[session] [session]
; Either "memory", "file", or "redis", default is "memory" ; Either "memory", "file", or "redis", default is "memory"
@@ -382,7 +350,7 @@ GRAVATAR_SOURCE = gravatar
DISABLE_GRAVATAR = false DISABLE_GRAVATAR = false
; Federated avatar lookup uses DNS to discover avatar associated ; Federated avatar lookup uses DNS to discover avatar associated
; with emails, see https://www.libravatar.org ; with emails, see https://www.libravatar.org
; This value will be forced to be false in offline mode or Gravatar is disabled. ; This value will be forced to be false in offline mode or Gravatar is disbaled.
ENABLE_FEDERATED_AVATAR = false ENABLE_FEDERATED_AVATAR = false
[attachment] [attachment]
@@ -398,7 +366,7 @@ MAX_SIZE = 4
MAX_FILES = 5 MAX_FILES = 5
[time] [time]
; Specifies the format for fully outputted dates. Defaults to RFC1123 ; Specifies the format for fully outputed dates. Defaults to RFC1123
; Special supported values are ANSIC, UnixDate, RubyDate, RFC822, RFC822Z, RFC850, RFC1123, RFC1123Z, RFC3339, RFC3339Nano, Kitchen, Stamp, StampMilli, StampMicro and StampNano ; Special supported values are ANSIC, UnixDate, RubyDate, RFC822, RFC822Z, RFC850, RFC1123, RFC1123Z, RFC3339, RFC3339Nano, Kitchen, Stamp, StampMilli, StampMicro and StampNano
; For more information about the format see http://golang.org/pkg/time/#pkg-constants ; For more information about the format see http://golang.org/pkg/time/#pkg-constants
FORMAT = FORMAT =
@@ -496,7 +464,7 @@ OLDER_THAN = 24h
; Synchronize external user data (only LDAP user synchronization is supported) ; Synchronize external user data (only LDAP user synchronization is supported)
[cron.sync_external_users] [cron.sync_external_users]
; Synchronize external user data when starting server (default false) ; Syncronize external user data when starting server (default false)
RUN_AT_START = false RUN_AT_START = false
; Interval as a duration between each synchronization (default every 24h) ; Interval as a duration between each synchronization (default every 24h)
SCHEDULE = @every 24h SCHEDULE = @every 24h
@@ -537,7 +505,7 @@ MAX_RESPONSE_ITEMS = 50
[i18n] [i18n]
LANGS = en-US,zh-CN,zh-HK,zh-TW,de-DE,fr-FR,nl-NL,lv-LV,ru-RU,ja-JP,es-ES,pt-BR,pl-PL,bg-BG,it-IT,fi-FI,tr-TR,cs-CZ,sr-SP,sv-SE,ko-KR LANGS = en-US,zh-CN,zh-HK,zh-TW,de-DE,fr-FR,nl-NL,lv-LV,ru-RU,ja-JP,es-ES,pt-BR,pl-PL,bg-BG,it-IT,fi-FI,tr-TR,cs-CZ,sr-SP,sv-SE,ko-KR
NAMES = English,简体中文,繁體中文(香港),繁體中文(台灣),Deutsch,Français,Nederlands,Latviešu,Русский,日本語,Español,Português do Brasil,polski,български,Italiano,Suomalainen,Türkçe,čeština,Српски,Svenska,한국어 NAMES = English,简体中文,繁體中文(香港),繁體中文(台灣),Deutsch,Français,Nederlands,Latviešu,Русский,日本語,Español,Português do Brasil,Polski,български,Italiano,Suomalainen,Türkçe,čeština,Српски,Svenska,한국어
; Used for datetimepicker ; Used for datetimepicker
[i18n.datelang] [i18n.datelang]
@@ -573,12 +541,3 @@ SHOW_FOOTER_BRANDING = false
SHOW_FOOTER_VERSION = true SHOW_FOOTER_VERSION = true
; Show time of template execution in the footer ; Show time of template execution in the footer
SHOW_FOOTER_TEMPLATE_LOAD_TIME = true SHOW_FOOTER_TEMPLATE_LOAD_TIME = true
[markup.asciidoc]
ENABLED = false
; List of file extensions that should be rendered by an external command
FILE_EXTENSIONS = .adoc,.asciidoc
; External command to render all matching extensions
RENDER_COMMAND = "asciidoc --out-file=- -"
; Input is not a standard input but a file
IS_INPUT_FILE = false

View File

@@ -1,12 +0,0 @@
# IDE and code editor configuration
## Table of Contents
- [IDE and code editor configuration](#ide-and-code-editor-configuration)
- [Microsoft Visual Studio Code](#microsoft-visual-studio-code)
## Microsoft Visual Studio Code
Download Microsoft Visual Studio Code at https://code.visualstudio.com/ and follow instructions at https://code.visualstudio.com/docs/languages/go to setup Go extension for it.
Create new directory `.vscode` in Gitea root folder and copy contents of folder [contrib/ide/vscode](vscode/) to it. You can now use `Ctrl`+`Shift`+`B` to build gitea executable and `F5` to run it in debug mode.
Supported on Debian, Ubuntu, Red Hat, Fedora, SUSE Linux, MacOS and Microsoft Windows.

View File

@@ -1,31 +0,0 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "go",
"request": "launch",
"mode": "debug",
"buildFlags": "",
"port": 2345,
"host": "127.0.0.1",
"program": "${workspaceRoot}/main.go",
"env": {},
"args": ["web"],
"showLog": true
},
{
"name": "Launch (with SQLite3)",
"type": "go",
"request": "launch",
"mode": "debug",
"buildFlags": "-tags=\"sqlite\"",
"port": 2345,
"host": "127.0.0.1",
"program": "${workspaceRoot}/main.go",
"env": {},
"args": ["web"],
"showLog": true
}
]
}

View File

@@ -1,51 +0,0 @@
{
"version": "2.0.0",
"tasks": [
{
"taskName": "Build",
"type": "shell",
"command": "go",
"group": "build",
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared"
},
"args": ["build"],
"linux": {
"args": [ "-o", "gitea", "${workspaceRoot}/main.go" ]
},
"osx": {
"args": [ "-o", "gitea", "${workspaceRoot}/main.go" ]
},
"windows": {
"args": [ "-o", "gitea.exe", "\"${workspaceRoot}\\main.go\""]
},
"problemMatcher": ["$go"]
},
{
"taskName": "Build (with SQLite3)",
"type": "shell",
"command": "go",
"group": "build",
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared"
},
"args": ["build", "-tags=\"sqlite\""],
"linux": {
"args": ["-o", "gitea", "${workspaceRoot}/main.go"]
},
"osx": {
"args": ["-o", "gitea", "${workspaceRoot}/main.go"]
},
"windows": {
"args": ["-o", "gitea.exe", "\"${workspaceRoot}\\main.go\""]
},
"problemMatcher": ["$go"]
}
]
}

View File

@@ -0,0 +1,25 @@
@ECHO off
:: This script relies on nssm.exe to work.
:: Please, download it and make it available on the system path,
:: or copy it to the gogs path.
:: https://nssm.cc/download
:: This script itself should run in the gogs path, too.
:: In case of startup failure, please read carefully the log file.
:: Make sure Gitea work running manually with "gitea web" before running
:: this script.
:: And, please, read carefully the installation docs first:
:: https://gogs.io/docs/installation
:: To unistall the service, run "nssm remove gogs" and restart Windows.
:: Set the folder where you extracted Gitea. Omit the last slash.
SET gogspath=C:\gogs
nssm install gogs "%gogspath%\gogs.exe"
nssm set gogs AppParameters "web"
nssm set gogs Description "A painless self-hosted Git service."
nssm set gogs DisplayName "Gitea - Git with a cup of tea"
nssm set gogs Start SERVICE_DELAYED_AUTO_START
nssm set gogs AppStdout "%gogspath%\gogs.log"
nssm start gogs
pause

View File

@@ -12,29 +12,7 @@ fi
if [ ! -f /data/gitea/conf/app.ini ]; then if [ ! -f /data/gitea/conf/app.ini ]; then
mkdir -p /data/gitea/conf mkdir -p /data/gitea/conf
cp /etc/templates/app.ini /data/gitea/conf/app.ini
# Set INSTALL_LOCK to true only if SECRET_KEY is not empty and
# INSTALL_LOCK is empty
if [ -n "$SECRET_KEY" ] && [ -z "$INSTALL_LOCK" ]; then
INSTALL_LOCK=true
fi
# Substitude the environment variables in the template
APP_NAME=${APP_NAME:-"Gitea: Git with a cup of tea"} \
RUN_MODE=${RUN_MODE:-"dev"} \
SSH_DOMAIN=${SSH_DOMAIN:-"localhost"} \
HTTP_PORT=${HTTP_PORT:-"3000"} \
ROOT_URL=${ROOT_URL:-""} \
DISABLE_SSH=${DISABLE_SSH:-"false"} \
SSH_PORT=${SSH_PORT:-"22"} \
DB_TYPE=${DB_TYPE:-"sqlite3"} \
DB_HOST=${DB_HOST:-"localhost:3306"} \
DB_NAME=${DB_NAME:-"gitea"} \
DB_USER=${DB_USER:-"root"} \
DB_PASSWD=${DB_PASSWD:-""} \
INSTALL_LOCK=${INSTALL_LOCK:-"false"} \
SECRET_KEY=${SECRET_KEY:-""} \
envsubst < /etc/templates/app.ini > /data/gitea/conf/app.ini
fi fi
chown -R git:git /data/gitea /app/gitea /data/git chown -R git:git /data/gitea /app/gitea /data/git

View File

@@ -1,6 +1,3 @@
APP_NAME = $APP_NAME
RUN_MODE = $RUN_MODE
[repository] [repository]
ROOT = /data/git/repositories ROOT = /data/git/repositories
@@ -9,19 +6,10 @@ TEMP_PATH = /data/gitea/uploads
[server] [server]
APP_DATA_PATH = /data/gitea APP_DATA_PATH = /data/gitea
SSH_DOMAIN = $SSH_DOMAIN
HTTP_PORT = $HTTP_PORT
ROOT_URL = $ROOT_URL
DISABLE_SSH = $DISABLE_SSH
SSH_PORT = $SSH_PORT
[database] [database]
DB_TYPE = sqlite3
PATH = /data/gitea/gitea.db PATH = /data/gitea/gitea.db
DB_TYPE = $DB_TYPE
HOST = $DB_HOST
NAME = $DB_NAME
USER = $DB_USER
PASSWD = $DB_PASSWD
[session] [session]
PROVIDER_CONFIG = /data/gitea/sessions PROVIDER_CONFIG = /data/gitea/sessions
@@ -34,7 +22,3 @@ PATH = /data/gitea/attachments
[log] [log]
ROOT_PATH = /data/gitea/log ROOT_PATH = /data/gitea/log
[security]
INSTALL_LOCK = $INSTALL_LOCK
SECRET_KEY = $SECRET_KEY

View File

@@ -1,16 +1,5 @@
#!/bin/sh #!/bin/sh
## Change GID for USER?
if [ -n "${USER_GID}" ] && [ "${USER_GID}" != "`id -g ${USER}`" ]; then
sed -i -e "s/^${USER}:\([^:]*\):[0-9]*/${USER}:\1:${USER_GID}/" /etc/group
sed -i -e "s/^${USER}:\([^:]*\):\([0-9]*\):[0-9]*/${USER}:\1:\2:${USER_GID}/" /etc/passwd
fi
## Change UID for USER?
if [ -n "${USER_UID}" ] && [ "${USER_UID}" != "`id -u ${USER}`" ]; then
sed -i -e "s/^${USER}:\([^:]*\):[0-9]*:\([0-9]*\)/${USER}:\1:${USER_UID}:\2/" /etc/passwd
fi
for FOLDER in /data/gitea/conf /data/gitea/log /data/git /data/ssh; do for FOLDER in /data/gitea/conf /data/gitea/log /data/git /data/ssh; do
mkdir -p ${FOLDER} mkdir -p ${FOLDER}
done done

View File

@@ -54,9 +54,8 @@ func TestAPIReplaceIssueLabels(t *testing.T) {
resp := session.MakeRequest(t, req, http.StatusOK) resp := session.MakeRequest(t, req, http.StatusOK)
var apiLabels []*api.Label var apiLabels []*api.Label
DecodeJSON(t, resp, &apiLabels) DecodeJSON(t, resp, &apiLabels)
if assert.Len(t, apiLabels, 1) { assert.Len(t, apiLabels, 1)
assert.EqualValues(t, label.ID, apiLabels[0].ID) assert.EqualValues(t, label.ID, apiLabels[0].ID)
}
models.AssertCount(t, &models.IssueLabel{IssueID: issue.ID}, 1) models.AssertCount(t, &models.IssueLabel{IssueID: issue.ID}, 1)
models.AssertExistsAndLoadBean(t, &models.IssueLabel{IssueID: issue.ID, LabelID: label.ID}) models.AssertExistsAndLoadBean(t, &models.IssueLabel{IssueID: issue.ID, LabelID: label.ID})

View File

@@ -1,31 +0,0 @@
// Copyright 2017 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package integrations
import (
"net/http"
"testing"
"code.gitea.io/gitea/models"
)
func TestAPIReposRaw(t *testing.T) {
prepareTestEnv(t)
user := models.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User)
// Login as User2.
session := loginUser(t, user.Name)
for _, ref := range [...]string{
"master", // Branch
"v1.1", // Tag
"65f1bf27bc3bf70f64657658635e66094edbcb4d", // Commit
} {
req := NewRequestf(t, "GET", "/api/v1/repos/%s/repo1/raw/%s/README.md", user.Name, ref)
session.MakeRequest(t, req, http.StatusOK)
}
// Test default branch
req := NewRequestf(t, "GET", "/api/v1/repos/%s/repo1/raw/README.md", user.Name)
session.MakeRequest(t, req, http.StatusOK)
}

View File

@@ -5,8 +5,8 @@
package integrations package integrations
import ( import (
"fmt"
"net/http" "net/http"
"strings"
"testing" "testing"
"code.gitea.io/gitea/models" "code.gitea.io/gitea/models"
@@ -33,166 +33,23 @@ func TestAPIUserReposNotLogin(t *testing.T) {
} }
} }
func TestAPISearchRepo(t *testing.T) { type searchResponseBody struct {
ok bool
data []api.Repository
}
func TestAPISearchRepoNotLogin(t *testing.T) {
prepareTestEnv(t) prepareTestEnv(t)
const keyword = "test" const keyword = "test"
req := NewRequestf(t, "GET", "/api/v1/repos/search?q=%s", keyword) req := NewRequestf(t, "GET", "/api/v1/repos/search?q=%s", keyword)
resp := MakeRequest(t, req, http.StatusOK) resp := MakeRequest(t, req, http.StatusOK)
var body api.SearchResults var body searchResponseBody
DecodeJSON(t, resp, &body) DecodeJSON(t, resp, &body)
assert.NotEmpty(t, body.Data) for _, repo := range body.data {
for _, repo := range body.Data { assert.True(t, strings.Contains(repo.Name, keyword))
assert.Contains(t, repo.Name, keyword)
assert.False(t, repo.Private)
} }
user := models.AssertExistsAndLoadBean(t, &models.User{ID: 15}).(*models.User)
user2 := models.AssertExistsAndLoadBean(t, &models.User{ID: 16}).(*models.User)
user3 := models.AssertExistsAndLoadBean(t, &models.User{ID: 18}).(*models.User)
user4 := models.AssertExistsAndLoadBean(t, &models.User{ID: 20}).(*models.User)
orgUser := models.AssertExistsAndLoadBean(t, &models.User{ID: 17}).(*models.User)
// Map of expected results, where key is user for login
type expectedResults map[*models.User]struct {
count int
repoOwnerID int64
repoName string
includesPrivate bool
}
testCases := []struct {
name, requestURL string
expectedResults
}{
{name: "RepositoriesMax50", requestURL: "/api/v1/repos/search?limit=50", expectedResults: expectedResults{
nil: {count: 15},
user: {count: 15},
user2: {count: 15}},
},
{name: "RepositoriesMax10", requestURL: "/api/v1/repos/search?limit=10", expectedResults: expectedResults{
nil: {count: 10},
user: {count: 10},
user2: {count: 10}},
},
{name: "RepositoriesDefaultMax10", requestURL: "/api/v1/repos/search", expectedResults: expectedResults{
nil: {count: 10},
user: {count: 10},
user2: {count: 10}},
},
{name: "RepositoriesByName", requestURL: fmt.Sprintf("/api/v1/repos/search?q=%s", "big_test_"), expectedResults: expectedResults{
nil: {count: 7, repoName: "big_test_"},
user: {count: 7, repoName: "big_test_"},
user2: {count: 7, repoName: "big_test_"}},
},
{name: "RepositoriesAccessibleAndRelatedToUser", requestURL: fmt.Sprintf("/api/v1/repos/search?uid=%d", user.ID), expectedResults: expectedResults{
nil: {count: 4},
user: {count: 8, includesPrivate: true},
user2: {count: 4}},
},
{name: "RepositoriesAccessibleAndRelatedToUser2", requestURL: fmt.Sprintf("/api/v1/repos/search?uid=%d", user2.ID), expectedResults: expectedResults{
nil: {count: 1},
user: {count: 1},
user2: {count: 2, includesPrivate: true}},
},
{name: "RepositoriesAccessibleAndRelatedToUser3", requestURL: fmt.Sprintf("/api/v1/repos/search?uid=%d", user3.ID), expectedResults: expectedResults{
nil: {count: 1},
user: {count: 1},
user2: {count: 1},
user3: {count: 4, includesPrivate: true}},
},
{name: "RepositoriesOwnedByOrganization", requestURL: fmt.Sprintf("/api/v1/repos/search?uid=%d", orgUser.ID), expectedResults: expectedResults{
nil: {count: 1, repoOwnerID: orgUser.ID},
user: {count: 2, repoOwnerID: orgUser.ID, includesPrivate: true},
user2: {count: 1, repoOwnerID: orgUser.ID}},
},
{name: "RepositoriesAccessibleAndRelatedToUser4", requestURL: fmt.Sprintf("/api/v1/repos/search?uid=%d", user4.ID), expectedResults: expectedResults{
nil: {count: 3},
user: {count: 3},
user4: {count: 6, includesPrivate: true}}},
{name: "RepositoriesAccessibleAndRelatedToUser4/SearchModeSource", requestURL: fmt.Sprintf("/api/v1/repos/search?uid=%d&mode=%s", user4.ID, "source"), expectedResults: expectedResults{
nil: {count: 0},
user: {count: 0},
user4: {count: 0, includesPrivate: true}}},
{name: "RepositoriesAccessibleAndRelatedToUser4/SearchModeFork", requestURL: fmt.Sprintf("/api/v1/repos/search?uid=%d&mode=%s", user4.ID, "fork"), expectedResults: expectedResults{
nil: {count: 1},
user: {count: 1},
user4: {count: 2, includesPrivate: true}}},
{name: "RepositoriesAccessibleAndRelatedToUser4/SearchModeFork/Exclusive", requestURL: fmt.Sprintf("/api/v1/repos/search?uid=%d&mode=%s&exclusive=1", user4.ID, "fork"), expectedResults: expectedResults{
nil: {count: 1},
user: {count: 1},
user4: {count: 2, includesPrivate: true}}},
{name: "RepositoriesAccessibleAndRelatedToUser4/SearchModeMirror", requestURL: fmt.Sprintf("/api/v1/repos/search?uid=%d&mode=%s", user4.ID, "mirror"), expectedResults: expectedResults{
nil: {count: 2},
user: {count: 2},
user4: {count: 4, includesPrivate: true}}},
{name: "RepositoriesAccessibleAndRelatedToUser4/SearchModeMirror/Exclusive", requestURL: fmt.Sprintf("/api/v1/repos/search?uid=%d&mode=%s&exclusive=1", user4.ID, "mirror"), expectedResults: expectedResults{
nil: {count: 1},
user: {count: 1},
user4: {count: 2, includesPrivate: true}}},
{name: "RepositoriesAccessibleAndRelatedToUser4/SearchModeCollaborative", requestURL: fmt.Sprintf("/api/v1/repos/search?uid=%d&mode=%s", user4.ID, "collaborative"), expectedResults: expectedResults{
nil: {count: 0},
user: {count: 0},
user4: {count: 0, includesPrivate: true}}},
}
for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) {
for userToLogin, expected := range testCase.expectedResults {
var session *TestSession
var testName string
var userID int64
if userToLogin != nil && userToLogin.ID > 0 {
testName = fmt.Sprintf("LoggedUser%d", userToLogin.ID)
session = loginUser(t, userToLogin.Name)
userID = userToLogin.ID
} else {
testName = "AnonymousUser"
session = emptyTestSession(t)
}
t.Run(testName, func(t *testing.T) {
request := NewRequest(t, "GET", testCase.requestURL)
response := session.MakeRequest(t, request, http.StatusOK)
var body api.SearchResults
DecodeJSON(t, response, &body)
assert.Len(t, body.Data, expected.count)
for _, repo := range body.Data {
r := getRepo(t, repo.ID)
hasAccess, err := models.HasAccess(userID, r, models.AccessModeRead)
assert.NoError(t, err)
assert.True(t, hasAccess)
assert.NotEmpty(t, repo.Name)
if len(expected.repoName) > 0 {
assert.Contains(t, repo.Name, expected.repoName)
}
if expected.repoOwnerID > 0 {
assert.Equal(t, expected.repoOwnerID, repo.Owner.ID)
}
if !expected.includesPrivate {
assert.False(t, repo.Private)
}
}
})
}
})
}
}
var repoCache = make(map[int64]*models.Repository)
func getRepo(t *testing.T, repoID int64) *models.Repository {
if _, ok := repoCache[repoID]; !ok {
repoCache[repoID] = models.AssertExistsAndLoadBean(t, &models.Repository{ID: repoID}).(*models.Repository)
}
return repoCache[repoID]
} }
func TestAPIViewRepo(t *testing.T) { func TestAPIViewRepo(t *testing.T) {

View File

@@ -1,79 +0,0 @@
// Copyright 2017 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package integrations
import (
"net/http"
"net/url"
"testing"
"github.com/PuerkitoBio/goquery"
"github.com/Unknwon/i18n"
"github.com/stretchr/testify/assert"
)
func TestViewBranches(t *testing.T) {
prepareTestEnv(t)
req := NewRequest(t, "GET", "/user2/repo1/branches")
resp := MakeRequest(t, req, http.StatusOK)
htmlDoc := NewHTMLParser(t, resp.Body)
_, exists := htmlDoc.doc.Find(".delete-branch-button").Attr("data-url")
assert.False(t, exists, "The template has changed")
}
func TestDeleteBranch(t *testing.T) {
prepareTestEnv(t)
deleteBranch(t)
}
func TestUndoDeleteBranch(t *testing.T) {
prepareTestEnv(t)
deleteBranch(t)
htmlDoc, name := branchAction(t, ".undo-button")
assert.Contains(t,
htmlDoc.doc.Find(".ui.positive.message").Text(),
i18n.Tr("en", "repo.branch.restore_success", name),
)
}
func deleteBranch(t *testing.T) {
htmlDoc, name := branchAction(t, ".delete-branch-button")
assert.Contains(t,
htmlDoc.doc.Find(".ui.positive.message").Text(),
i18n.Tr("en", "repo.branch.deletion_success", name),
)
}
func branchAction(t *testing.T, button string) (*HTMLDoc, string) {
session := loginUser(t, "user2")
req := NewRequest(t, "GET", "/user2/repo1/branches")
resp := session.MakeRequest(t, req, http.StatusOK)
htmlDoc := NewHTMLParser(t, resp.Body)
link, exists := htmlDoc.doc.Find(button).Attr("data-url")
assert.True(t, exists, "The template has changed")
htmlDoc = NewHTMLParser(t, resp.Body)
req = NewRequestWithValues(t, "POST", link, map[string]string{
"_csrf": getCsrf(htmlDoc.doc),
})
resp = session.MakeRequest(t, req, http.StatusOK)
url, err := url.Parse(link)
assert.NoError(t, err)
req = NewRequest(t, "GET", "/user2/repo1/branches")
resp = session.MakeRequest(t, req, http.StatusOK)
return NewHTMLParser(t, resp.Body), url.Query()["name"][0]
}
func getCsrf(doc *goquery.Document) string {
csrf, _ := doc.Find("meta[name=\"_csrf\"]").Attr("content")
return csrf
}

View File

@@ -5,26 +5,13 @@
package integrations package integrations
import ( import (
"fmt"
"net/http" "net/http"
"testing" "testing"
"code.gitea.io/gitea/models" "code.gitea.io/gitea/models"
) )
func assertUserDeleted(t *testing.T, userID int64) { func TestDeleteUser(t *testing.T) {
models.AssertNotExistsBean(t, &models.User{ID: userID})
models.AssertNotExistsBean(t, &models.Follow{UserID: userID})
models.AssertNotExistsBean(t, &models.Follow{FollowID: userID})
models.AssertNotExistsBean(t, &models.Repository{OwnerID: userID})
models.AssertNotExistsBean(t, &models.Access{UserID: userID})
models.AssertNotExistsBean(t, &models.OrgUser{UID: userID})
models.AssertNotExistsBean(t, &models.IssueUser{UID: userID})
models.AssertNotExistsBean(t, &models.TeamUser{UID: userID})
models.AssertNotExistsBean(t, &models.Star{UID: userID})
}
func TestAdminDeleteUser(t *testing.T) {
prepareTestEnv(t) prepareTestEnv(t)
session := loginUser(t, "user1") session := loginUser(t, "user1")
@@ -35,36 +22,6 @@ func TestAdminDeleteUser(t *testing.T) {
}) })
session.MakeRequest(t, req, http.StatusOK) session.MakeRequest(t, req, http.StatusOK)
assertUserDeleted(t, 8) models.AssertNotExistsBean(t, &models.User{ID: 8})
models.CheckConsistencyFor(t, &models.User{}) models.CheckConsistencyFor(t, &models.User{})
} }
func TestUserDeleteAccount(t *testing.T) {
prepareTestEnv(t)
session := loginUser(t, "user8")
csrf := GetCSRF(t, session, "/user/settings/delete")
urlStr := fmt.Sprintf("/user/settings/delete?password=%s", userPassword)
req := NewRequestWithValues(t, "POST", urlStr, map[string]string{
"_csrf": csrf,
})
session.MakeRequest(t, req, http.StatusFound)
assertUserDeleted(t, 8)
models.CheckConsistencyFor(t, &models.User{})
}
func TestUserDeleteAccountStillOwnRepos(t *testing.T) {
prepareTestEnv(t)
session := loginUser(t, "user2")
csrf := GetCSRF(t, session, "/user/settings/delete")
urlStr := fmt.Sprintf("/user/settings/delete?password=%s", userPassword)
req := NewRequestWithValues(t, "POST", urlStr, map[string]string{
"_csrf": csrf,
})
session.MakeRequest(t, req, http.StatusFound)
// user should not have been deleted, because the user still owns repos
models.AssertExistsAndLoadBean(t, &models.User{ID: 2})
}

View File

@@ -43,15 +43,16 @@ func TestCreateFileOnProtectedBranch(t *testing.T) {
csrf := GetCSRF(t, session, "/user2/repo1/settings/branches") csrf := GetCSRF(t, session, "/user2/repo1/settings/branches")
// Change master branch to protected // Change master branch to protected
req := NewRequestWithValues(t, "POST", "/user2/repo1/settings/branches/master", map[string]string{ req := NewRequestWithValues(t, "POST", "/user2/repo1/settings/branches?action=protected_branch", map[string]string{
"_csrf": csrf, "_csrf": csrf,
"protected": "on", "branchName": "master",
"canPush": "false",
}) })
resp := session.MakeRequest(t, req, http.StatusFound) resp := session.MakeRequest(t, req, http.StatusOK)
// Check if master branch has been locked successfully // Check if master branch has been locked successfully
flashCookie := session.GetCookie("macaron_flash") flashCookie := session.GetCookie("macaron_flash")
assert.NotNil(t, flashCookie) assert.NotNil(t, flashCookie)
assert.EqualValues(t, "success%3DBranch%2Bmaster%2Bprotect%2Boptions%2Bchanged%2Bsuccessfully.", flashCookie.Value) assert.EqualValues(t, flashCookie.Value, "success%3Dmaster%2BLocked%2Bsuccessfully")
// Request editor page // Request editor page
req = NewRequest(t, "GET", "/user2/repo1/_new/master/") req = NewRequest(t, "GET", "/user2/repo1/_new/master/")
@@ -73,23 +74,12 @@ func TestCreateFileOnProtectedBranch(t *testing.T) {
resp = session.MakeRequest(t, req, http.StatusOK) resp = session.MakeRequest(t, req, http.StatusOK)
// Check body for error message // Check body for error message
assert.Contains(t, string(resp.Body), "Can not commit to protected branch &#39;master&#39;.") assert.Contains(t, string(resp.Body), "Can not commit to protected branch &#39;master&#39;.")
// remove the protected branch
csrf = GetCSRF(t, session, "/user2/repo1/settings/branches")
// Change master branch to protected
req = NewRequestWithValues(t, "POST", "/user2/repo1/settings/branches/master", map[string]string{
"_csrf": csrf,
"protected": "off",
})
resp = session.MakeRequest(t, req, http.StatusFound)
// Check if master branch has been locked successfully
flashCookie = session.GetCookie("macaron_flash")
assert.NotNil(t, flashCookie)
assert.EqualValues(t, "success%3DBranch%2Bmaster%2Bprotect%2Boptions%2Bremoved%2Bsuccessfully", flashCookie.Value)
} }
func testEditFile(t *testing.T, session *TestSession, user, repo, branch, filePath, newContent string) *TestResponse { func testEditFile(t *testing.T, session *TestSession, user, repo, branch, filePath string) *TestResponse {
newContent := "Hello, World (Edited)\n"
// Get to the 'edit this file' page // Get to the 'edit this file' page
req := NewRequest(t, "GET", path.Join(user, repo, "_edit", branch, filePath)) req := NewRequest(t, "GET", path.Join(user, repo, "_edit", branch, filePath))
resp := session.MakeRequest(t, req, http.StatusOK) resp := session.MakeRequest(t, req, http.StatusOK)
@@ -111,14 +101,16 @@ func testEditFile(t *testing.T, session *TestSession, user, repo, branch, filePa
resp = session.MakeRequest(t, req, http.StatusFound) resp = session.MakeRequest(t, req, http.StatusFound)
// Verify the change // Verify the change
req = NewRequest(t, "GET", path.Join(user, repo, "raw/branch", branch, filePath)) req = NewRequest(t, "GET", path.Join(user, repo, "raw", branch, filePath))
resp = session.MakeRequest(t, req, http.StatusOK) resp = session.MakeRequest(t, req, http.StatusOK)
assert.EqualValues(t, newContent, string(resp.Body)) assert.EqualValues(t, newContent, string(resp.Body))
return resp return resp
} }
func testEditFileToNewBranch(t *testing.T, session *TestSession, user, repo, branch, targetBranch, filePath, newContent string) *TestResponse { func testEditFileToNewBranch(t *testing.T, session *TestSession, user, repo, branch, targetBranch, filePath string) *TestResponse {
newContent := "Hello, World (Edited)\n"
// Get to the 'edit this file' page // Get to the 'edit this file' page
req := NewRequest(t, "GET", path.Join(user, repo, "_edit", branch, filePath)) req := NewRequest(t, "GET", path.Join(user, repo, "_edit", branch, filePath))
@@ -142,7 +134,7 @@ func testEditFileToNewBranch(t *testing.T, session *TestSession, user, repo, bra
resp = session.MakeRequest(t, req, http.StatusFound) resp = session.MakeRequest(t, req, http.StatusFound)
// Verify the change // Verify the change
req = NewRequest(t, "GET", path.Join(user, repo, "raw/branch", targetBranch, filePath)) req = NewRequest(t, "GET", path.Join(user, repo, "raw", targetBranch, filePath))
resp = session.MakeRequest(t, req, http.StatusOK) resp = session.MakeRequest(t, req, http.StatusOK)
assert.EqualValues(t, newContent, string(resp.Body)) assert.EqualValues(t, newContent, string(resp.Body))
@@ -152,11 +144,11 @@ func testEditFileToNewBranch(t *testing.T, session *TestSession, user, repo, bra
func TestEditFile(t *testing.T) { func TestEditFile(t *testing.T) {
prepareTestEnv(t) prepareTestEnv(t)
session := loginUser(t, "user2") session := loginUser(t, "user2")
testEditFile(t, session, "user2", "repo1", "master", "README.md", "Hello, World (Edited)\n") testEditFile(t, session, "user2", "repo1", "master", "README.md")
} }
func TestEditFileToNewBranch(t *testing.T) { func TestEditFileToNewBranch(t *testing.T) {
prepareTestEnv(t) prepareTestEnv(t)
session := loginUser(t, "user2") session := loginUser(t, "user2")
testEditFileToNewBranch(t, session, "user2", "repo1", "master", "feature/test", "README.md", "Hello, World (Edited)\n") testEditFileToNewBranch(t, session, "user2", "repo1", "master", "feature/test", "README.md")
} }

View File

@@ -1,60 +0,0 @@
// Copyright 2017 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package integrations
import (
"context"
"fmt"
"io/ioutil"
"net"
"net/http"
"os"
"path/filepath"
"testing"
"time"
"code.gitea.io/git"
"github.com/Unknwon/com"
"github.com/stretchr/testify/assert"
)
func onGiteaWebRun(t *testing.T, callback func(*testing.T, string)) {
s := http.Server{
Handler: mac,
}
listener, err := net.Listen("tcp", "")
assert.NoError(t, err)
defer func() {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
s.Shutdown(ctx)
cancel()
}()
go s.Serve(listener)
_, port, err := net.SplitHostPort(listener.Addr().String())
assert.NoError(t, err)
callback(t, fmt.Sprintf("http://localhost:%s/", port))
}
func TestClone_ViaHTTP_NoLogin(t *testing.T) {
prepareTestEnv(t)
onGiteaWebRun(t, func(t *testing.T, urlPrefix string) {
dstPath, err := ioutil.TempDir("", "repo1")
assert.NoError(t, err)
defer os.RemoveAll(dstPath)
err = git.Clone(fmt.Sprintf("%suser2/repo1.git", urlPrefix),
dstPath, git.CloneRepoOptions{})
assert.NoError(t, err)
assert.True(t, com.IsExist(filepath.Join(dstPath, "README.md")))
})
}

Some files were not shown because too many files have changed in this diff Show More