forked from Gitlink/gitea-1120-rc1
Merge branch 'develop_zx'
This commit is contained in:
commit
c042ac5342
|
@ -96,3 +96,14 @@ prime/
|
|||
|
||||
# Make evidence files
|
||||
/.make_evidence
|
||||
|
||||
gitea.bat
|
||||
linux.bat
|
||||
release.rar
|
||||
sql.rar
|
||||
sql
|
||||
release
|
||||
gitea.rar
|
||||
modules/repofiles/content_back
|
||||
vendor/*
|
||||
gitea.exe~
|
|
@ -0,0 +1,108 @@
|
|||
# Compiled Object files, Static and Dynamic libs (Shared Objects)
|
||||
*.o
|
||||
*.a
|
||||
*.so
|
||||
|
||||
# Folders
|
||||
_obj
|
||||
_test
|
||||
|
||||
# IntelliJ
|
||||
.idea
|
||||
|
||||
# MS VSCode
|
||||
.vscode
|
||||
__debug_bin
|
||||
|
||||
# Architecture specific extensions/prefixes
|
||||
*.[568vq]
|
||||
[568vq].out
|
||||
|
||||
*.cgo1.go
|
||||
*.cgo2.c
|
||||
_cgo_defun.c
|
||||
_cgo_gotypes.go
|
||||
_cgo_export.*
|
||||
|
||||
_testmain.go
|
||||
|
||||
*.exe
|
||||
*.test
|
||||
*.prof
|
||||
|
||||
*coverage.out
|
||||
coverage.all
|
||||
|
||||
/modules/options/bindata.go
|
||||
/modules/options/bindata.go.hash
|
||||
/modules/public/bindata.go
|
||||
/modules/public/bindata.go.hash
|
||||
/modules/templates/bindata.go
|
||||
/modules/templates/bindata.go.hash
|
||||
|
||||
*.db
|
||||
*.log
|
||||
|
||||
/gitea
|
||||
/gitea-vet
|
||||
/debug
|
||||
/integrations.test
|
||||
|
||||
/bin
|
||||
/dist
|
||||
/custom/*
|
||||
!/custom/conf
|
||||
/custom/conf/*
|
||||
!/custom/conf/app.example.ini
|
||||
/data
|
||||
/indexers
|
||||
/log
|
||||
/public/img/avatar
|
||||
/integrations/gitea-integration-mysql
|
||||
/integrations/gitea-integration-mysql8
|
||||
/integrations/gitea-integration-pgsql
|
||||
/integrations/gitea-integration-sqlite
|
||||
/integrations/gitea-integration-mssql
|
||||
/integrations/indexers-mysql
|
||||
/integrations/indexers-mysql8
|
||||
/integrations/indexers-pgsql
|
||||
/integrations/indexers-sqlite
|
||||
/integrations/indexers-mssql
|
||||
/integrations/sqlite.ini
|
||||
/integrations/mysql.ini
|
||||
/integrations/mysql8.ini
|
||||
/integrations/pgsql.ini
|
||||
/integrations/mssql.ini
|
||||
/node_modules
|
||||
/yarn.lock
|
||||
/public/js
|
||||
/public/serviceworker.js
|
||||
/public/css
|
||||
/public/fonts
|
||||
/public/img/webpack
|
||||
/web_src/fomantic/build
|
||||
/VERSION
|
||||
/.air
|
||||
|
||||
# Snapcraft
|
||||
snap/.snapcraft/
|
||||
parts/
|
||||
stage/
|
||||
prime/
|
||||
*.snap
|
||||
*.snap-build
|
||||
*_source.tar.bz2
|
||||
.DS_Store
|
||||
|
||||
# Make evidence files
|
||||
/.make_evidence
|
||||
|
||||
gitea.bat
|
||||
linux.bat
|
||||
release.rar
|
||||
sql.rar
|
||||
sql
|
||||
release
|
||||
gitea.rar
|
||||
modules/repofiles/content_back
|
||||
vendor/*
|
2
build.go
2
build.go
|
@ -27,6 +27,6 @@ import (
|
|||
// for vet
|
||||
_ "gitea.com/jolheiser/gitea-vet"
|
||||
|
||||
// for swagger
|
||||
// for `swagger`
|
||||
_ "github.com/go-swagger/go-swagger/cmd/swagger"
|
||||
)
|
||||
|
|
49
go.mod
49
go.mod
|
@ -19,16 +19,23 @@ require (
|
|||
gitea.com/macaron/toolbox v0.0.0-20190822013122-05ff0fc766b7
|
||||
github.com/BurntSushi/toml v0.3.1
|
||||
github.com/PuerkitoBio/goquery v1.5.1
|
||||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
|
||||
github.com/RoaringBitmap/roaring v0.4.23 // indirect
|
||||
github.com/alecthomas/chroma v0.8.0
|
||||
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 // indirect
|
||||
github.com/aymerick/douceur v0.2.0 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/bgentry/speakeasy v0.1.0 // indirect
|
||||
github.com/blevesearch/bleve v1.0.7
|
||||
github.com/couchbase/gomemcached v0.0.0-20191004160342-7b5da2ec40b2 // indirect
|
||||
github.com/couchbase/goutils v0.0.0-20191018232750-b49639060d85 // indirect
|
||||
github.com/cznic/b v0.0.0-20181122101859-a26611c4d92d // indirect
|
||||
github.com/cznic/mathutil v0.0.0-20181122101859-297441e03548 // indirect
|
||||
github.com/cznic/strutil v0.0.0-20181122101858-275e90344537 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/denisenkom/go-mssqldb v0.0.0-20200428022330-06a60b6afbbc
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible
|
||||
github.com/dlclark/regexp2 v1.2.0 // indirect
|
||||
github.com/dustin/go-humanize v1.0.0
|
||||
github.com/editorconfig/editorconfig-core-go/v2 v2.1.1
|
||||
github.com/emirpasic/gods v1.12.0
|
||||
|
@ -36,39 +43,64 @@ require (
|
|||
github.com/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51 // indirect
|
||||
github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 // indirect
|
||||
github.com/facebookgo/subset v0.0.0-20150612182917-8dac2c3c4870 // indirect
|
||||
github.com/fatih/color v1.9.0 // indirect
|
||||
github.com/fatih/structtag v1.2.0 // indirect
|
||||
github.com/gliderlabs/ssh v0.2.2
|
||||
github.com/glycerine/go-unsnap-stream v0.0.0-20190901134440-81cf024a9e0a // indirect
|
||||
github.com/go-enry/go-enry/v2 v2.5.2
|
||||
github.com/go-git/gcfg v1.5.0 // indirect
|
||||
github.com/go-git/go-billy/v5 v5.0.0
|
||||
github.com/go-git/go-git/v5 v5.1.0
|
||||
github.com/go-macaron/gzip v0.0.0-20200329073552-98214d7a897e // indirect
|
||||
github.com/go-macaron/toolbox v0.0.0-20200329073429-4401f4ce0f55 // indirect
|
||||
github.com/go-openapi/analysis v0.19.5 // indirect
|
||||
github.com/go-openapi/errors v0.19.2 // indirect
|
||||
github.com/go-openapi/inflect v0.19.0 // indirect
|
||||
github.com/go-openapi/jsonreference v0.19.3 // indirect
|
||||
github.com/go-openapi/loads v0.19.3 // indirect
|
||||
github.com/go-openapi/runtime v0.19.5 // indirect
|
||||
github.com/go-openapi/spec v0.19.3 // indirect
|
||||
github.com/go-openapi/strfmt v0.19.3 // indirect
|
||||
github.com/go-openapi/swag v0.19.5 // indirect
|
||||
github.com/go-openapi/validate v0.19.3 // indirect
|
||||
github.com/go-redis/redis v6.15.2+incompatible
|
||||
github.com/go-sql-driver/mysql v1.5.0
|
||||
github.com/go-stack/stack v1.8.0 // indirect
|
||||
github.com/go-swagger/go-swagger v0.21.0
|
||||
github.com/go-testfixtures/testfixtures/v3 v3.2.0
|
||||
github.com/gobwas/glob v0.2.3
|
||||
github.com/gogs/chardet v0.0.0-20191104214054-4b6791f73a28
|
||||
github.com/gogs/cron v0.0.0-20171120032916-9f6c956d3e14
|
||||
github.com/golang/gddo v0.0.0-20190419222130-af0f2af80721 // indirect
|
||||
github.com/golang/protobuf v1.4.1 // indirect
|
||||
github.com/golang/snappy v0.0.1 // indirect
|
||||
github.com/google/go-github/v32 v32.1.0
|
||||
github.com/google/go-querystring v1.0.0 // indirect
|
||||
github.com/google/uuid v1.1.1
|
||||
github.com/gorilla/context v1.1.1
|
||||
github.com/gorilla/css v1.0.0 // indirect
|
||||
github.com/gorilla/handlers v1.4.2 // indirect
|
||||
github.com/hashicorp/go-retryablehttp v0.6.6 // indirect
|
||||
github.com/huandu/xstrings v1.3.0
|
||||
github.com/issue9/assert v1.3.2 // indirect
|
||||
github.com/issue9/identicon v1.0.1
|
||||
github.com/jaytaylor/html2text v0.0.0-20160923191438-8fb95d837f7d
|
||||
github.com/jessevdk/go-flags v1.4.0 // indirect
|
||||
github.com/jmhodges/levigo v1.0.0 // indirect
|
||||
github.com/kballard/go-shellquote v0.0.0-20170619183022-cd60e84ee657
|
||||
github.com/keybase/go-crypto v0.0.0-20200123153347-de78d2cb44f4
|
||||
github.com/klauspost/compress v1.10.2
|
||||
github.com/klauspost/compress v1.10.3
|
||||
github.com/kr/pretty v0.1.0 // indirect
|
||||
github.com/lafriks/xormstore v1.3.2
|
||||
github.com/lib/pq v1.7.0
|
||||
github.com/lunny/dingtalk_webhook v0.0.0-20171025031554-e3534c89ef96
|
||||
github.com/lunny/log v0.0.0-20160921050905-7887c61bf0de // indirect
|
||||
github.com/lunny/nodb v0.0.0-20160621015157-fc1ef06ad4af // indirect
|
||||
github.com/mailru/easyjson v0.7.0 // indirect
|
||||
github.com/markbates/goth v1.61.2
|
||||
github.com/mattn/go-isatty v0.0.12
|
||||
github.com/mattn/go-sqlite3 v2.0.2+incompatible
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
|
||||
github.com/mcuadros/go-version v0.0.0-20190308113854-92cdf37c5b75
|
||||
github.com/mgechev/dots v0.0.0-20190921121421-c36f7dcfbb81
|
||||
github.com/mgechev/revive v1.0.2
|
||||
|
@ -78,21 +110,30 @@ require (
|
|||
github.com/msteinert/pam v0.0.0-20151204160544-02ccfbfaf0cc
|
||||
github.com/nfnt/resize v0.0.0-20160724205520-891127d8d1b5
|
||||
github.com/niklasfasching/go-org v0.1.9
|
||||
github.com/olekukonko/tablewriter v0.0.4 // indirect
|
||||
github.com/oliamb/cutter v0.2.2
|
||||
github.com/olivere/elastic/v7 v7.0.9
|
||||
github.com/philhofer/fwd v1.0.0 // indirect
|
||||
github.com/pierrec/lz4 v2.0.5+incompatible // indirect
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/pquerna/otp v1.2.0
|
||||
github.com/prometheus/client_golang v1.1.0
|
||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4 // indirect
|
||||
github.com/prometheus/common v0.6.0 // indirect
|
||||
github.com/prometheus/procfs v0.0.4 // indirect
|
||||
github.com/quasoft/websspi v1.0.0
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20190321074620-2f0d2b0e0001 // indirect
|
||||
github.com/sergi/go-diff v1.1.0
|
||||
github.com/shurcooL/httpfs v0.0.0-20190527155220-6a4d4a70508b // indirect
|
||||
github.com/shurcooL/vfsgen v0.0.0-20181202132449-6a9ea43bcacd
|
||||
github.com/siddontang/go-snappy v0.0.0-20140704025258-d8f7bb82a96d // indirect
|
||||
github.com/spf13/viper v1.4.0 // indirect
|
||||
github.com/stretchr/testify v1.4.0
|
||||
github.com/syndtr/goleveldb v1.0.0 // indirect
|
||||
github.com/tecbot/gorocksdb v0.0.0-20181010114359-8752a9433481 // indirect
|
||||
github.com/tinylib/msgp v1.1.2 // indirect
|
||||
github.com/toqueteos/webbrowser v1.2.0 // indirect
|
||||
github.com/tstranex/u2f v1.0.0
|
||||
github.com/unknwon/com v1.0.1
|
||||
github.com/unknwon/i18n v0.0.0-20190805065654-5c6446a380b6
|
||||
|
@ -103,19 +144,25 @@ require (
|
|||
github.com/yuin/goldmark v1.2.1
|
||||
github.com/yuin/goldmark-highlighting v0.0.0-20200307114337-60d527fdb691
|
||||
github.com/yuin/goldmark-meta v0.0.0-20191126180153-f0638e958b60
|
||||
go.mongodb.org/mongo-driver v1.1.1 // indirect
|
||||
golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9
|
||||
golang.org/x/mod v0.2.0 // indirect
|
||||
golang.org/x/net v0.0.0-20200602114024-627f9648deb9
|
||||
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
|
||||
golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1
|
||||
golang.org/x/text v0.3.2
|
||||
golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1 // indirect
|
||||
golang.org/x/tools v0.0.0-20200325010219-a49f79bcc224
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 // indirect
|
||||
google.golang.org/appengine v1.6.5 // indirect
|
||||
google.golang.org/protobuf v1.22.0 // indirect
|
||||
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
|
||||
gopkg.in/asn1-ber.v1 v1.0.0-20150924051756-4e86f4367175 // indirect
|
||||
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
|
||||
gopkg.in/ini.v1 v1.52.0
|
||||
gopkg.in/ldap.v3 v3.0.2
|
||||
gopkg.in/macaron.v1 v1.4.0 // indirect
|
||||
gopkg.in/warnings.v0 v0.1.2 // indirect
|
||||
gopkg.in/yaml.v2 v2.3.0
|
||||
mvdan.cc/xurls/v2 v2.1.0
|
||||
strk.kbt.io/projects/go/libravatar v0.0.0-20191008002943-06d1c002b251
|
||||
|
|
19
go.sum
19
go.sum
|
@ -237,6 +237,12 @@ github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2
|
|||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
||||
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
||||
github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas=
|
||||
github.com/go-macaron/gzip v0.0.0-20200329073552-98214d7a897e h1:PlmAvovRGUTW15weOGR3gny33PCUL2Ko65rN1w1XBog=
|
||||
github.com/go-macaron/gzip v0.0.0-20200329073552-98214d7a897e/go.mod h1:1if9hBU2ZPlrmuwN27VIn11Ur9OXBiZDLDPmCKbb7N4=
|
||||
github.com/go-macaron/inject v0.0.0-20160627170012-d8a0b8677191 h1:NjHlg70DuOkcAMqgt0+XA+NHwtu66MkTVVgR4fFWbcI=
|
||||
github.com/go-macaron/inject v0.0.0-20160627170012-d8a0b8677191/go.mod h1:VFI2o2q9kYsC4o7VP1HrEVosiZZTd+MVT3YZx4gqvJw=
|
||||
github.com/go-macaron/toolbox v0.0.0-20200329073429-4401f4ce0f55 h1:aDDZ2v9fvO9xGIw+WkmOm65f4jImmRgv7QKqLe8u5bU=
|
||||
github.com/go-macaron/toolbox v0.0.0-20200329073429-4401f4ce0f55/go.mod h1:YFNJ/JT4yLnpuIXTFef30SZkxGHUczjGZGFaZpPcdn0=
|
||||
github.com/go-openapi/analysis v0.0.0-20180825180245-b006789cd277/go.mod h1:k70tL6pCuVxPJOHXQ+wIac1FUrvNkHolPie/cLEU6hI=
|
||||
github.com/go-openapi/analysis v0.17.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik=
|
||||
github.com/go-openapi/analysis v0.18.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik=
|
||||
|
@ -448,6 +454,8 @@ github.com/klauspost/compress v1.9.2 h1:LfVyl+ZlLlLDeQ/d2AqfGIIH4qEDu0Ed2S5GyhCW
|
|||
github.com/klauspost/compress v1.9.2/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
|
||||
github.com/klauspost/compress v1.10.2 h1:Znfn6hXZAHaLPNnlqUYRrBSReFHYybslgv4PTiyz6P0=
|
||||
github.com/klauspost/compress v1.10.2/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
|
||||
github.com/klauspost/compress v1.10.3 h1:OP96hzwJVBIHYU52pVTI6CczrxPvrGfgqF9N5eTO0Q8=
|
||||
github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
|
||||
github.com/klauspost/cpuid v1.2.0/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
|
||||
github.com/klauspost/pgzip v1.2.1 h1:oIPZROsWuPHpOdMVWLuJZXwgjhrW8r1yEX8UqMyeNHM=
|
||||
github.com/klauspost/pgzip v1.2.1/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs=
|
||||
|
@ -636,6 +644,7 @@ github.com/smartystreets/goconvey v0.0.0-20181108003508-044398e4856c/go.mod h1:X
|
|||
github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
|
||||
github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337 h1:WN9BUFbdyOsSH/XohnWpXOlq9NBD5sGAB2FciQMUEe8=
|
||||
github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
|
||||
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
|
||||
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
|
||||
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
|
||||
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
|
||||
|
@ -711,8 +720,6 @@ github.com/yuin/goldmark v1.1.7/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec
|
|||
github.com/yuin/goldmark v1.1.22/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.1.25 h1:isv+Q6HQAmmL2Ofcmg8QauBmDPlUUnSoNhEcC940Rds=
|
||||
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.1.32 h1:5tjfNdR2ki3yYQ842+eX2sQHeiwpKJ0RnHO4IYOc4V8=
|
||||
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.2.1 h1:ruQGxdhGHe7FWOJPT0mKs5+pD2Xs1Bm/kdGlHO04FmM=
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark-highlighting v0.0.0-20200307114337-60d527fdb691 h1:VWSxtAiQNh3zgHJpdpkpVYjTPqRE3P6UZCOPa1nRDio=
|
||||
|
@ -830,6 +837,7 @@ golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/go.mod h1:h1NjWce9XRLGQEsW7w
|
|||
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190730183949-1393eb018365/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190801041406-cbf593c0f2f3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190804053845-51ab0e2deafa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190907184412-d223b2b6db03/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191010194322-b09406accb47 h1:/XfQ9z7ib8eEJX2hdgFTZJ/ntt0swNk5oYBziWeTCvY=
|
||||
|
@ -870,6 +878,7 @@ golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgw
|
|||
golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20190617190820-da514acc4774/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20190802220118-1d1727260058/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI=
|
||||
golang.org/x/tools v0.0.0-20190907020128-2ca718005c18/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20200225230052-807dcd883420 h1:4RJNOV+2rLxMEfr6QIpC7GEv9MjD6ApGXTCLrNF9+eA=
|
||||
|
@ -942,6 +951,12 @@ gopkg.in/ini.v1 v1.52.0 h1:j+Lt/M1oPPejkniCg1TkWE2J3Eh1oZTsHSXzMTzUXn4=
|
|||
gopkg.in/ini.v1 v1.52.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||
gopkg.in/ldap.v3 v3.0.2 h1:R6RBtabK6e1GO0eQKtkyOFbAHO73QesLzI2w2DZ6b9w=
|
||||
gopkg.in/ldap.v3 v3.0.2/go.mod h1:oxD7NyBuxchC+SgJDE1Q5Od05eGt29SDQVBmV+HYbzw=
|
||||
gopkg.in/macaron.v1 v1.3.4 h1:HvIscOwxhFhx3swWM/979wh2QMYyuXrNmrF9l+j3HZs=
|
||||
gopkg.in/macaron.v1 v1.3.4/go.mod h1:/RoHTdC8ALpyJ3+QR36mKjwnT1F1dyYtsGM9Ate6ZFI=
|
||||
gopkg.in/macaron.v1 v1.3.5 h1:FUA16VFBojxzfU75KqWrV/6BPv9O2R1GnybSGRie9QQ=
|
||||
gopkg.in/macaron.v1 v1.3.5/go.mod h1:uMZCFccv9yr5TipIalVOyAyZQuOH3OkmXvgcWwhJuP4=
|
||||
gopkg.in/macaron.v1 v1.4.0 h1:RJHC09fAnQ8tuGUiZNjG0uyL1BWSdSWd9SpufIcEArQ=
|
||||
gopkg.in/macaron.v1 v1.4.0/go.mod h1:uMZCFccv9yr5TipIalVOyAyZQuOH3OkmXvgcWwhJuP4=
|
||||
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
|
||||
gopkg.in/square/go-jose.v2 v2.3.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
set go111module=on
|
||||
set GOOS=linux
|
||||
set GOARCH=amd64
|
||||
go build -tags='bindata' -o release\linux\gitea
|
|
@ -0,0 +1,5 @@
|
|||
set go111module=on
|
||||
SET GOOS=darwin
|
||||
SET GOARCH=amd64
|
||||
go build -tags='bindata' -o release\mac\gitea
|
||||
|
|
@ -0,0 +1,157 @@
|
|||
package models
|
||||
|
||||
import "strings"
|
||||
|
||||
// GetFeedsOptions options for retrieving feeds
|
||||
type GetContributorsOptionsExt struct {
|
||||
RepoId int64
|
||||
UserId int64
|
||||
}
|
||||
|
||||
type ContributorsDto struct {
|
||||
Contributions int64 `json:"contributions"`
|
||||
ID int64 `json:"id"`
|
||||
Login string `json:"login"`
|
||||
//Type string `json:"type"`
|
||||
}
|
||||
|
||||
func GetContributors(opt GetContributorsOptionsExt) (interface{}, error) {
|
||||
sql:=
|
||||
`select a.act_user_id as id ,
|
||||
u.name as login,
|
||||
count(act_user_id) as contributions
|
||||
from action a
|
||||
left join user u on a.act_user_id=u.id
|
||||
where repo_id=? and user_id=?
|
||||
group by repo_id,act_user_id `
|
||||
|
||||
result:=make([]ContributorsDto,0,0)
|
||||
err:=x.SQL(sql,opt.RepoId,opt.UserId).Find(&result)
|
||||
return result,err
|
||||
}
|
||||
|
||||
|
||||
|
||||
type GetGetActivityOptions struct {
|
||||
FromDateUnix int64 `json:"-"`
|
||||
ToDateUnix int64 `json:"-"`
|
||||
FromDate string `json:"from_date"`
|
||||
ToDate string `json:"to_date"`
|
||||
Top int64 `json:"-"`
|
||||
}
|
||||
|
||||
|
||||
type PlatformDTO struct {
|
||||
Id int64 `json:"-"`
|
||||
Name string `json:"-"`
|
||||
TotalCount int64 `json:"total_count"`
|
||||
ActiveCount int64 `json:"active_count"`
|
||||
}
|
||||
|
||||
//平台所需数据;
|
||||
func GetActivity(opt *GetGetActivityOptions) (interface{}, error) {
|
||||
//sql:=
|
||||
// `select a.id,a.name,ifNull(b.active_count,0) as active_count,t.total_count
|
||||
// from ( select 11 as id ,'PullRequest' name union
|
||||
// select 5 as id, 'Commit' name
|
||||
// ) a
|
||||
// left join (
|
||||
// select op_type, count(op_type) as active_count
|
||||
// from action a
|
||||
// where (a.op_type=11 or a.op_type=5)
|
||||
// and (created_unix>=? and created_unix<=?)
|
||||
// group by a.op_type
|
||||
// ) b on a.id=b.op_type
|
||||
// left join (
|
||||
// select op_type, count(op_type) as total_count
|
||||
// from action a
|
||||
// where (a.op_type=11 or a.op_type=5)
|
||||
// group by a.op_type
|
||||
// ) t on a.id=t.op_type
|
||||
//`
|
||||
|
||||
sql:=`select a.id,a.name,ifNull(b.active_count,0) as active_count,b.total_count
|
||||
from ( select 11 as id ,'PullRequest' name
|
||||
union
|
||||
select 5 as id, 'Commit' name
|
||||
) a
|
||||
left join (
|
||||
select op_type,count(op_type) as total_count,
|
||||
sum(case when a.created_unix>=? and a.created_unix<=?
|
||||
then 1 else 0 end
|
||||
) as active_count
|
||||
from action a
|
||||
where (a.op_type=11 or a.op_type=5)
|
||||
group by a.op_type
|
||||
) b on a.id=b.op_type`
|
||||
|
||||
datalist:=make([]PlatformDTO,0,0)
|
||||
err:=x.SQL(sql,opt.FromDateUnix,opt.ToDateUnix).Find(&datalist)
|
||||
if err !=nil {
|
||||
return nil ,err
|
||||
}
|
||||
|
||||
convertMap:=make(map[string]interface{})
|
||||
for i:=0;i<=len(datalist)-1;i++{
|
||||
convertMap[strings.ToLower(datalist[i].Name)]=datalist[i]
|
||||
}
|
||||
//convertMap["param"]=opt
|
||||
|
||||
return convertMap,err
|
||||
}
|
||||
|
||||
|
||||
type ProjectDTO struct {
|
||||
Id int64 `json:"-"`
|
||||
Name string `json:"name"`
|
||||
TotalCount int64 `json:"total_count"`
|
||||
ActiveCount int64 `json:"active_count"`
|
||||
}
|
||||
|
||||
|
||||
//项目所需数据-按项目统计 top 5
|
||||
func GetActivityProject(opt *GetGetActivityOptions) (interface{}, error) {
|
||||
sql:=
|
||||
`select repo_id as id,r.name,
|
||||
count(op_type) as total_count,
|
||||
sum(case when a.created_unix>=? and a.created_unix<=?
|
||||
then 1 else 0 end
|
||||
) as active_count
|
||||
from action a
|
||||
left join repository r on a.repo_id=r.id
|
||||
where (a.op_type=5)
|
||||
group by a.repo_id
|
||||
order by total_count desc
|
||||
limit ?
|
||||
`
|
||||
|
||||
datalist:=make([]ProjectDTO,0,0)
|
||||
err:=x.SQL(sql,opt.FromDateUnix,opt.ToDateUnix,opt.Top).Find(&datalist)
|
||||
return datalist,err
|
||||
}
|
||||
|
||||
|
||||
//项目所需数据-按开发者统计 top 5
|
||||
func GetActivityDevelop(opt *GetGetActivityOptions) (interface{}, error) {
|
||||
sql:=
|
||||
`select u.name as develop_name,
|
||||
count(op_type) as total_count,
|
||||
sum(case when (a.created_unix>=? and a.created_unix<=?) then 1 else 0 end ) as active_count
|
||||
from action a
|
||||
left join user u on a.act_user_id=u.id
|
||||
where (a.op_type=5)
|
||||
group by a.act_user_id
|
||||
order by total_count desc
|
||||
limit ? `
|
||||
|
||||
datalist:=make([]DevelopDTO,0,0)
|
||||
err:=x.SQL(sql,opt.FromDateUnix,opt.ToDateUnix,opt.Top).Find(&datalist)
|
||||
return datalist,err
|
||||
}
|
||||
|
||||
type DevelopDTO struct {
|
||||
DevelopName string `json:"develop_name"`
|
||||
TotalCount int64 `json:"total_count"`
|
||||
ActiveCount int64 `json:"active_count"`
|
||||
|
||||
}
|
|
@ -161,6 +161,7 @@ func NewTestEngine() (err error) {
|
|||
|
||||
x.SetMapper(names.GonicMapper{})
|
||||
x.SetLogger(NewXORMLogger(!setting.ProdMode))
|
||||
|
||||
x.ShowSQL(!setting.ProdMode)
|
||||
return x.StoreEngine("InnoDB").Sync2(tables...)
|
||||
}
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
// Copyright 2014 The Gogs Authors. All rights reserved.
|
||||
// Copyright 2019 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 models
|
||||
|
||||
import "xorm.io/builder"
|
||||
|
||||
// GetLatestReleaseByRepoID returns the latest release for a repository
|
||||
func GetLatestReleaseByRepoIDExt(repoID int64) (*Release, error) {
|
||||
cond := builder.NewCond().
|
||||
And(builder.Eq{"repo_id": repoID}).
|
||||
And(builder.Eq{"is_draft": false}).
|
||||
And(builder.Eq{"is_prerelease": false})
|
||||
|
||||
rel := new(Release)
|
||||
has, err := x.
|
||||
Desc("created_unix", "id").
|
||||
Where(cond).
|
||||
Get(rel)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if !has {
|
||||
return nil, ErrReleaseNotExist{0, "latest"}
|
||||
}
|
||||
|
||||
return rel, nil
|
||||
}
|
|
@ -102,6 +102,7 @@ func (repo *Repository) GetTopLanguageStats(limit int) (LanguageStatList, error)
|
|||
})
|
||||
}
|
||||
topstats.loadAttributes()
|
||||
|
||||
return topstats, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -101,7 +101,8 @@ type User struct {
|
|||
Name string `xorm:"UNIQUE NOT NULL"`
|
||||
FullName string
|
||||
// Email is the primary email address (to be used for communication)
|
||||
Email string `xorm:"NOT NULL"`
|
||||
Email string `xorm:"NOT NULL INDEX"`
|
||||
//Email string `xorm:"NOT NULL"`
|
||||
KeepEmailPrivate bool
|
||||
EmailNotificationsPreference string `xorm:"VARCHAR(20) NOT NULL DEFAULT 'enabled'"`
|
||||
Passwd string `xorm:"NOT NULL"`
|
||||
|
|
|
@ -737,8 +737,8 @@ func RepoRefByType(refType RepoRefType) macaron.Handler {
|
|||
ctx.Repo.BranchName = refName
|
||||
if refType.RefTypeIncludesBranches() && ctx.Repo.GitRepo.IsBranchExist(refName) {
|
||||
ctx.Repo.IsViewBranch = true
|
||||
|
||||
ctx.Repo.Commit, err = ctx.Repo.GitRepo.GetBranchCommit(refName)
|
||||
//fmt.Println("****:GetBranchCommit:",ctx.Repo.Commit, err)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetBranchCommit", err)
|
||||
return
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
// Copyright 2015 The Gogs 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 convert
|
||||
|
||||
import (
|
||||
"code.gitea.io/gitea/models"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
)
|
||||
|
||||
// ToOrganization convert models.User to api.Organization
|
||||
func ToOrganizationExt(org *models.User) *api.OrganizationExt {
|
||||
return &api.OrganizationExt{
|
||||
ID: org.ID,
|
||||
AvatarURL: org.AvatarLink(),
|
||||
UserName: org.Name,
|
||||
FullName: org.FullName,
|
||||
Description: org.Description,
|
||||
Website: org.Website,
|
||||
Location: org.Location,
|
||||
Visibility: org.Visibility.String(),
|
||||
RepoAdminChangeTeamAccess: org.RepoAdminChangeTeamAccess,
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
// Copyright 2015 The Gogs Authors. All rights reserved.
|
||||
// Copyright 2019 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 git
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
)
|
||||
|
||||
// 自定义:多协程查询版本库,减小查询延时; add by hcxm
|
||||
func (repo *Repository) GetTagInfosExt(page, pageSize int) ([]*Tag, error) {
|
||||
// TODO this a slow implementation, makes one git command per tag
|
||||
stdout, err := NewCommand("tag").RunInDir(repo.Path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
tagNames := strings.Split(strings.TrimRight(stdout, "\n"), "\n")
|
||||
if page != 0 {
|
||||
skip := (page - 1) * pageSize
|
||||
if skip >= len(tagNames) {
|
||||
return nil, nil
|
||||
}
|
||||
if (len(tagNames) - skip) < pageSize {
|
||||
pageSize = len(tagNames) - skip
|
||||
}
|
||||
tagNames = tagNames[skip : skip+pageSize]
|
||||
}
|
||||
|
||||
grp:= &sync.WaitGroup{}
|
||||
var tags = make([]*Tag, 0, len(tagNames))
|
||||
for _, tagName := range tagNames {
|
||||
tagName = strings.TrimSpace(tagName)
|
||||
if len(tagName) == 0 {
|
||||
continue
|
||||
}
|
||||
grp.Add(1)
|
||||
go func(tagsExt *[]*Tag,tagName string,grp *sync.WaitGroup) {
|
||||
defer func() {
|
||||
grp.Done()
|
||||
}()
|
||||
tag, err := repo.GetTag(tagName)
|
||||
if err != nil {
|
||||
fmt.Println("repo.GetTag:",err)
|
||||
return
|
||||
}
|
||||
tag.Name = tagName
|
||||
*tagsExt = append(*tagsExt, tag)
|
||||
}(&tags,tagName,grp)
|
||||
}
|
||||
grp.Wait()
|
||||
sortTagsByTime(tags)
|
||||
return tags, nil
|
||||
}
|
|
@ -5,10 +5,12 @@
|
|||
package repofiles
|
||||
|
||||
import (
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"path"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
|
@ -38,6 +40,12 @@ func (ct *ContentType) String() string {
|
|||
// GetContentsOrList gets the meta data of a file's contents (*ContentsResponse) if treePath not a tree
|
||||
// directory, otherwise a listing of file contents ([]*ContentsResponse). Ref can be a branch, commit or tag
|
||||
func GetContentsOrList(repo *models.Repository, treePath, ref string) (interface{}, error) {
|
||||
startTotal:=time.Now()
|
||||
log.Info("Enter time:%v",startTotal.Format("2006-01-02 15:04:05.000"))
|
||||
defer func() {
|
||||
log.Info("***GetContentsOrList耗时:%v",time.Now().Sub(startTotal))
|
||||
}()
|
||||
start:=time.Now()
|
||||
if repo.IsEmpty {
|
||||
return make([]interface{}, 0), nil
|
||||
}
|
||||
|
@ -46,6 +54,7 @@ func GetContentsOrList(repo *models.Repository, treePath, ref string) (interface
|
|||
}
|
||||
origRef := ref
|
||||
|
||||
start=time.Now()
|
||||
// Check that the path given in opts.treePath is valid (not a git path)
|
||||
cleanTreePath := CleanUploadFileName(treePath)
|
||||
if cleanTreePath == "" && treePath != "" {
|
||||
|
@ -53,52 +62,61 @@ func GetContentsOrList(repo *models.Repository, treePath, ref string) (interface
|
|||
Path: treePath,
|
||||
}
|
||||
}
|
||||
log.Info("*****************GetContentsOrList.CleanUploadFileName:%v",time.Now().Sub(start))
|
||||
start=time.Now()
|
||||
treePath = cleanTreePath
|
||||
|
||||
gitRepo, err := git.OpenRepository(repo.RepoPath())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer gitRepo.Close()
|
||||
|
||||
log.Info("*****************GetContentsOrList.OpenRepository:%v",time.Now().Sub(start))
|
||||
start=time.Now()
|
||||
// Get the commit object for the ref
|
||||
commit, err := gitRepo.GetCommit(ref)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
log.Info("*****************GetContentsOrList.GetCommit:ret:%s treepath:%s", ref, treePath)
|
||||
log.Info("*****************GetContentsOrList.GetCommit:%v",time.Now().Sub(start)," ref:",ref," treePath:",treePath)
|
||||
start=time.Now()
|
||||
entry, err := commit.GetTreeEntryByPath(treePath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
log.Info("*****************GetContentsOrList.GetTreeEntryByPath:%v",time.Now().Sub(start))
|
||||
if entry.Type() != "tree" {
|
||||
return GetContents(repo, treePath, origRef, false)
|
||||
a,b:= GetContents(repo, treePath, origRef, false)
|
||||
log.Info("*****************GetContentsOrList.GetContents***:%v",time.Now().Sub(start))
|
||||
return a,b
|
||||
}
|
||||
|
||||
// We are in a directory, so we return a list of FileContentResponse objects
|
||||
var fileList []*api.ContentsResponse
|
||||
|
||||
start=time.Now()
|
||||
gitTree, err := commit.SubTree(treePath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
log.Info("*****************GetContentsOrList.SubTree:%v",time.Now().Sub(start))
|
||||
entries, err := gitTree.ListEntries()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
start=time.Now()
|
||||
//add by qiubing
|
||||
commitsInfo, _, err := entries.GetCommitsInfo(commit, treePath, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
//end by qiubing
|
||||
|
||||
start1:=time.Now()
|
||||
log.Info("****GetContentsOrList.GetCommitsInfo:%v",time.Now().Sub(start))
|
||||
for _, e := range entries {
|
||||
subTreePath := path.Join(treePath, e.Name())
|
||||
fileContentResponse, err := GetContents(repo, subTreePath, origRef, true)
|
||||
|
||||
start2:=time.Now()
|
||||
fileContentResponse, err := GetContentsExt(gitRepo,commit,repo, subTreePath, origRef, true)
|
||||
log.Info("*****GetContentsOrList.GetContents:%s %v",e.Name(),time.Now().Sub(start2))
|
||||
// add by qiubing
|
||||
for _, commitInfo := range commitsInfo {
|
||||
if treeEntry, ok := commitInfo[0].(*git.TreeEntry); ok {
|
||||
|
@ -125,9 +143,117 @@ func GetContentsOrList(repo *models.Repository, treePath, ref string) (interface
|
|||
}
|
||||
fileList = append(fileList, fileContentResponse)
|
||||
}
|
||||
log.Info("*****************GetContentsOrList.for-entries:%v",time.Now().Sub(start1))
|
||||
return fileList, nil
|
||||
}
|
||||
|
||||
|
||||
|
||||
// GetContents gets the meta data on a file's contents. Ref can be a branch, commit or tag
|
||||
func GetContentsExt(gitRepo *git.Repository, commit *git.Commit,repo *models.Repository, treePath, ref string, forList bool) (*api.ContentsResponse, error) {
|
||||
if ref == "" {
|
||||
ref = repo.DefaultBranch
|
||||
}
|
||||
origRef := ref
|
||||
|
||||
// Check that the path given in opts.treePath is valid (not a git path)
|
||||
cleanTreePath := CleanUploadFileName(treePath)
|
||||
if cleanTreePath == "" && treePath != "" {
|
||||
return nil, models.ErrFilenameInvalid{
|
||||
Path: treePath,
|
||||
}
|
||||
}
|
||||
treePath = cleanTreePath
|
||||
commitID := commit.ID.String()
|
||||
if len(ref) >= 4 && strings.HasPrefix(commitID, ref) {
|
||||
ref = commit.ID.String()
|
||||
}
|
||||
//start1:=time.Now()
|
||||
entry, err := commit.GetTreeEntryByPath(treePath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
//fmt.Println("****GetContents.commit.GetTreeEntryByPath:",treePath," ",time.Now().Sub(start1))
|
||||
refType := gitRepo.GetRefType(ref)
|
||||
if refType == "invalid" {
|
||||
return nil, fmt.Errorf("no commit found for the ref [ref: %s]", ref)
|
||||
}
|
||||
|
||||
selfURL, err := url.Parse(fmt.Sprintf("%s/contents/%s?ref=%s", repo.APIURL(), treePath, origRef))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selfURLString := selfURL.String()
|
||||
|
||||
// All content types have these fields in populated
|
||||
contentsResponse := &api.ContentsResponse{
|
||||
Name: entry.Name(),
|
||||
Path: treePath,
|
||||
SHA: entry.ID.String(),
|
||||
Size: entry.Size(),
|
||||
URL: &selfURLString,
|
||||
Links: &api.FileLinksResponse{
|
||||
Self: &selfURLString,
|
||||
},
|
||||
}
|
||||
|
||||
// Now populate the rest of the ContentsResponse based on entry type
|
||||
if entry.IsRegular() || entry.IsExecutable() {
|
||||
contentsResponse.Type = string(ContentTypeRegular)
|
||||
if blobResponse, err := GetBlobBySHA(repo, entry.ID.String()); err != nil {
|
||||
return nil, err
|
||||
} else if !forList {
|
||||
// We don't show the content if we are getting a list of FileContentResponses
|
||||
contentsResponse.Encoding = &blobResponse.Encoding
|
||||
contentsResponse.Content = &blobResponse.Content
|
||||
}
|
||||
} else if entry.IsDir() {
|
||||
contentsResponse.Type = string(ContentTypeDir)
|
||||
} else if entry.IsLink() {
|
||||
contentsResponse.Type = string(ContentTypeLink)
|
||||
// The target of a symlink file is the content of the file
|
||||
targetFromContent, err := entry.Blob().GetBlobContent()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
contentsResponse.Target = &targetFromContent
|
||||
} else if entry.IsSubModule() {
|
||||
contentsResponse.Type = string(ContentTypeSubmodule)
|
||||
submodule, err := commit.GetSubModule(treePath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
contentsResponse.SubmoduleGitURL = &submodule.URL
|
||||
}
|
||||
// Handle links
|
||||
if entry.IsRegular() || entry.IsLink() {
|
||||
downloadURL, err := url.Parse(fmt.Sprintf("%s/raw/%s/%s/%s", repo.HTMLURL(), refType, ref, treePath))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
downloadURLString := downloadURL.String()
|
||||
contentsResponse.DownloadURL = &downloadURLString
|
||||
}
|
||||
if !entry.IsSubModule() {
|
||||
htmlURL, err := url.Parse(fmt.Sprintf("%s/src/%s/%s/%s", repo.HTMLURL(), refType, ref, treePath))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
htmlURLString := htmlURL.String()
|
||||
contentsResponse.HTMLURL = &htmlURLString
|
||||
contentsResponse.Links.HTMLURL = &htmlURLString
|
||||
|
||||
gitURL, err := url.Parse(fmt.Sprintf("%s/git/blobs/%s", repo.APIURL(), entry.ID.String()))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
gitURLString := gitURL.String()
|
||||
contentsResponse.GitURL = &gitURLString
|
||||
contentsResponse.Links.GitURL = &gitURLString
|
||||
}
|
||||
|
||||
return contentsResponse, nil
|
||||
}
|
||||
// GetContents gets the meta data on a file's contents. Ref can be a branch, commit or tag
|
||||
func GetContents(repo *models.Repository, treePath, ref string, forList bool) (*api.ContentsResponse, error) {
|
||||
if ref == "" {
|
||||
|
|
|
@ -91,6 +91,7 @@ func InitDBConfig() {
|
|||
|
||||
Database.IterateBufferSize = sec.Key("ITERATE_BUFFER_SIZE").MustInt(50)
|
||||
Database.LogSQL = sec.Key("LOG_SQL").MustBool(true)
|
||||
//fmt.Println("*********Database.LogSQL ",Database.LogSQL )
|
||||
Database.DBConnectRetries = sec.Key("DB_RETRIES").MustInt(10)
|
||||
Database.DBConnectBackoff = sec.Key("DB_RETRY_BACKOFF").MustDuration(3 * time.Second)
|
||||
}
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
// Copyright 2015 The Gogs 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 structs
|
||||
|
||||
|
||||
// Organization represents an organization
|
||||
|
||||
type OrganizationExt struct {
|
||||
ID int64 `json:"id"`
|
||||
UserName string `json:"username"`
|
||||
FullName string `json:"full_name"`
|
||||
AvatarURL string `json:"avatar_url"`
|
||||
Description string `json:"description"`
|
||||
Website string `json:"website"`
|
||||
Location string `json:"location"`
|
||||
Visibility string `json:"visibility"`
|
||||
RepoAdminChangeTeamAccess bool `json:"repo_admin_change_team_access"`
|
||||
OwnerTeam interface{} `json:"owner_team"` //团队关系;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// EditOrgOption options for editing an organization
|
||||
type EditOrgOptionExt struct {
|
||||
Name string `json:"name"` // 添加对name的修改,lower_name 其值跟随name变化;
|
||||
FullName string `json:"full_name"`
|
||||
Description string `json:"description"`
|
||||
Website string `json:"website"`
|
||||
Location string `json:"location"`
|
||||
// possible values are `public`, `limited` or `private`
|
||||
// enum: public,limited,private
|
||||
Visibility string `json:"visibility" binding:"In(,public,limited,private)"`
|
||||
RepoAdminChangeTeamAccess bool `json:"repo_admin_change_team_access"`
|
||||
}
|
||||
|
|
@ -65,9 +65,6 @@
|
|||
package v1
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/auth"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
|
@ -79,9 +76,13 @@ import (
|
|||
"code.gitea.io/gitea/routers/api/v1/notify"
|
||||
"code.gitea.io/gitea/routers/api/v1/org"
|
||||
"code.gitea.io/gitea/routers/api/v1/repo"
|
||||
report "code.gitea.io/gitea/routers/api/v1/reporter"
|
||||
"code.gitea.io/gitea/routers/api/v1/settings"
|
||||
_ "code.gitea.io/gitea/routers/api/v1/swagger" // for swagger generation
|
||||
"code.gitea.io/gitea/routers/api/v1/user"
|
||||
"code.gitea.io/gitea/routers/api/v1/viewfile"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"gitea.com/macaron/binding"
|
||||
"gitea.com/macaron/macaron"
|
||||
|
@ -90,6 +91,7 @@ import (
|
|||
func sudo() macaron.Handler {
|
||||
return func(ctx *context.APIContext) {
|
||||
sudo := ctx.Query("sudo")
|
||||
//fmt.Println("*****************sudo:",sudo)
|
||||
if len(sudo) == 0 {
|
||||
sudo = ctx.Req.Header.Get("Sudo")
|
||||
}
|
||||
|
@ -97,6 +99,7 @@ func sudo() macaron.Handler {
|
|||
if len(sudo) > 0 {
|
||||
if ctx.IsSigned && ctx.User.IsAdmin {
|
||||
user, err := models.GetUserByName(sudo)
|
||||
//fmt.Println("*******user:",user)
|
||||
if err != nil {
|
||||
if models.IsErrUserNotExist(err) {
|
||||
ctx.NotFound()
|
||||
|
@ -180,24 +183,30 @@ func repoAssignment() macaron.Handler {
|
|||
// Contexter middleware already checks token for user sign in process.
|
||||
func reqToken() macaron.Handler {
|
||||
return func(ctx *context.APIContext) {
|
||||
|
||||
if true == ctx.Data["IsApiToken"] {
|
||||
return
|
||||
}
|
||||
|
||||
if ctx.Context.IsBasicAuth {
|
||||
ctx.CheckForOTP()
|
||||
return
|
||||
}
|
||||
|
||||
if ctx.IsSigned {
|
||||
ctx.RequireCSRF()
|
||||
return
|
||||
}
|
||||
|
||||
ctx.Context.Error(http.StatusUnauthorized)
|
||||
}
|
||||
}
|
||||
|
||||
func reqBasicAuth() macaron.Handler {
|
||||
return func(ctx *context.APIContext) {
|
||||
|
||||
if !ctx.Context.IsBasicAuth {
|
||||
// fmt.Println("***********:",http.StatusUnauthorized)
|
||||
ctx.Context.Error(http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
|
@ -271,7 +280,6 @@ func reqOrgOwnership() macaron.Handler {
|
|||
if ctx.Context.IsUserSiteAdmin() {
|
||||
return
|
||||
}
|
||||
|
||||
var orgID int64
|
||||
if ctx.Org.Organization != nil {
|
||||
orgID = ctx.Org.Organization.ID
|
||||
|
@ -281,7 +289,6 @@ func reqOrgOwnership() macaron.Handler {
|
|||
ctx.Error(http.StatusInternalServerError, "", "reqOrgOwnership: unprepared context")
|
||||
return
|
||||
}
|
||||
|
||||
isOwner, err := models.IsOrganizationOwner(orgID, ctx.User.ID)
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "IsOrganizationOwner", err)
|
||||
|
@ -402,16 +409,21 @@ func orgAssignment(args ...bool) macaron.Handler {
|
|||
}
|
||||
|
||||
if assignTeam {
|
||||
|
||||
ctx.Org.Team, err = models.GetTeamByID(ctx.ParamsInt64(":teamid"))
|
||||
if err != nil {
|
||||
|
||||
if models.IsErrUserNotExist(err) {
|
||||
|
||||
ctx.NotFound()
|
||||
} else {
|
||||
|
||||
ctx.Error(http.StatusInternalServerError, "GetTeamById", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -539,7 +551,7 @@ func RegisterRoutes(m *macaron.Macaron) {
|
|||
Patch(notify.ReadThread)
|
||||
}, reqToken())
|
||||
|
||||
// Users
|
||||
|
||||
m.Group("/users", func() {
|
||||
m.Get("/search", user.Search)
|
||||
|
||||
|
@ -573,6 +585,14 @@ func RegisterRoutes(m *macaron.Macaron) {
|
|||
})
|
||||
}, reqToken())
|
||||
|
||||
|
||||
//数据统计
|
||||
m.Group("/activity", func() {
|
||||
m.Get("", report.GetActivity)
|
||||
m.Get("/project", report.GetActivityProject)
|
||||
m.Get("/develop", report.GetActivityDevelop)
|
||||
})
|
||||
|
||||
m.Group("/user", func() {
|
||||
m.Get("", user.GetAuthenticatedUser)
|
||||
m.Combo("/emails").Get(user.ListEmails).
|
||||
|
@ -633,6 +653,8 @@ func RegisterRoutes(m *macaron.Macaron) {
|
|||
|
||||
m.Combo("/repositories/:id", reqToken()).Get(repo.GetByID)
|
||||
|
||||
|
||||
//
|
||||
m.Group("/repos", func() {
|
||||
m.Get("/search", repo.Search)
|
||||
|
||||
|
@ -641,6 +663,39 @@ func RegisterRoutes(m *macaron.Macaron) {
|
|||
m.Post("/migrate", reqToken(), bind(auth.MigrateRepoForm{}), repo.Migrate)
|
||||
|
||||
m.Group("/:username/:reponame", func() {
|
||||
m.Group("/readme", func() {
|
||||
//update by 2021-01-12 begin
|
||||
//m.Get("", context.RepoRefByType(context.RepoRefBranch), viewfile.ViewFile)
|
||||
//m.Get("/branch/*", context.RepoRefByType(context.RepoRefBranch), viewfile.ViewFile)
|
||||
//m.Get("/tag/*",context.RepoRefByType(context.RepoRefTag), viewfile.ViewFile)
|
||||
//m.Get("/commit/*", context.RepoRefByType(context.RepoRefCommit), viewfile.ViewFile)
|
||||
|
||||
m.Get("/ext", viewfile.RepoRefByType(context.RepoRefBranch), viewfile.ViewFile)
|
||||
m.Get("/branch/*", viewfile.RepoRefByType(context.RepoRefBranch), viewfile.ViewFile)
|
||||
m.Get("/tag/*",viewfile.RepoRefByType(context.RepoRefTag), viewfile.ViewFile)
|
||||
m.Get("/commit/*", viewfile.RepoRefByType(context.RepoRefCommit), viewfile.ViewFile)
|
||||
|
||||
//update by 2021-01-12 end 引用自定义包;
|
||||
|
||||
// alter on 2021/01/15
|
||||
m.Get("", viewfile.Readme) // reqRepoReader(models.UnitTypeCode),
|
||||
},reqToken())
|
||||
|
||||
m.Group("/count", func() {
|
||||
m.Get("", viewfile.CommitCount) //****
|
||||
})
|
||||
m.Group("/releases", func() {
|
||||
m.Get("/latest", viewfile.LatestRelease) //响应数据待确认 to do;
|
||||
})
|
||||
//
|
||||
m.Group("/find", func() {
|
||||
m.Get("", viewfile.FindFiles) //文件搜索 ****
|
||||
})
|
||||
|
||||
m.Group("/contributors", func() {
|
||||
m.Get("", report.GetContributors) //获取仓库的所有构建者信息 ****
|
||||
})
|
||||
|
||||
m.Combo("").Get(reqAnyRepoReader(), repo.Get).
|
||||
Delete(reqToken(), reqOwner(), repo.Delete).
|
||||
Patch(reqToken(), reqAdmin(), bind(api.EditRepoOption{}), context.RepoRef(), repo.Edit)
|
||||
|
@ -873,7 +928,8 @@ func RegisterRoutes(m *macaron.Macaron) {
|
|||
m.Get("/blobs/:sha", context.RepoRef(), repo.GetBlob)
|
||||
m.Get("/tags/:sha", context.RepoRef(), repo.GetTag)
|
||||
}, reqRepoReader(models.UnitTypeCode))
|
||||
m.Group("/contents", func() {
|
||||
|
||||
m.Group("/contents", func() { //***********
|
||||
m.Get("", repo.GetContentsList)
|
||||
m.Get("/*", repo.GetContents)
|
||||
m.Group("/*", func() {
|
||||
|
@ -898,11 +954,18 @@ func RegisterRoutes(m *macaron.Macaron) {
|
|||
// Organizations
|
||||
m.Get("/user/orgs", reqToken(), org.ListMyOrgs)
|
||||
m.Get("/users/:username/orgs", org.ListUserOrgs)
|
||||
m.Post("/orgs", reqToken(), bind(api.CreateOrgOption{}), org.Create)
|
||||
// modified on 2021-01-14 begin 创建组织时返回默认的团队 begin
|
||||
//m.Post("/orgs", reqToken(), bind(api.CreateOrgOption{}), org.Create)
|
||||
m.Post("/orgs", reqToken(), bind(api.CreateOrgOption{}), org.CreateExt)
|
||||
// modified on 2021-01-14 begin 创建组织时返回默认的团队 end
|
||||
|
||||
m.Get("/orgs", org.GetAll)
|
||||
m.Group("/orgs/:org", func() {
|
||||
m.Combo("").Get(org.Get).
|
||||
Patch(reqToken(), reqOrgOwnership(), bind(api.EditOrgOption{}), org.Edit).
|
||||
//modified on 2021/01/14 end
|
||||
Patch(reqToken(), reqOrgOwnership(), bind(api.EditOrgOptionExt{}), org.Edit_Ext).
|
||||
//Patch(reqToken(), reqOrgOwnership(), bind(api.EditOrgOption{}), org.Edit).
|
||||
//modified on 2021/01/14 end
|
||||
Delete(reqToken(), reqOrgOwnership(), org.Delete)
|
||||
m.Combo("/repos").Get(user.ListOrgRepos).
|
||||
Post(reqToken(), bind(api.CreateRepoOption{}), repo.CreateOrgRepo)
|
||||
|
|
|
@ -0,0 +1,160 @@
|
|||
// Copyright 2015 The Gogs Authors. All rights reserved.
|
||||
// Copyright 2018 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 org
|
||||
|
||||
import (
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
"code.gitea.io/gitea/modules/convert"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Edit change an organization's information modified on 2021/01/14
|
||||
func Edit_Ext(ctx *context.APIContext, form api.EditOrgOptionExt) {
|
||||
// swagger:operation PATCH /orgs/{org} organization orgEdit
|
||||
// ---
|
||||
// summary: Edit an organization
|
||||
// consumes:
|
||||
// - application/json
|
||||
// produces:
|
||||
// - application/json
|
||||
// parameters:
|
||||
// - name: org
|
||||
// in: path
|
||||
// description: name of the organization to edit
|
||||
// type: string
|
||||
// required: true
|
||||
// - name: body
|
||||
// in: body
|
||||
// required: true
|
||||
// schema:
|
||||
// "$ref": "#/definitions/EditOrgOption"
|
||||
// responses:
|
||||
// "200":
|
||||
// "$ref": "#/responses/Organization"
|
||||
|
||||
org := ctx.Org.Organization
|
||||
if org.LowerName!=strings.ToLower(form.Name) && form.Name!="" {
|
||||
if len(form.Name)>40 {
|
||||
ctx.Error(http.StatusBadRequest, "EditOrganization", "name长度不能超过40个字符")
|
||||
return
|
||||
}
|
||||
org.Name=form.Name //add by hcxm 2021/01/14
|
||||
org.LowerName=strings.ToLower(org.Name) //add by hcxm 2021/01/14
|
||||
}
|
||||
org.RepoAdminChangeTeamAccess=form.RepoAdminChangeTeamAccess //add by hcxm 2021/01/14
|
||||
org.FullName = form.FullName
|
||||
org.Description = form.Description
|
||||
org.Website = form.Website
|
||||
org.Location = form.Location
|
||||
|
||||
var visibilityChanged bool=false
|
||||
if form.Visibility != "" {
|
||||
visibilityChanged = form.Visibility != org.Visibility.String()
|
||||
fmt.Println("***打印参数: visibilityChanged:",visibilityChanged," form.Visibility:",form.Visibility," org.Visibility:",org.Visibility.String())
|
||||
org.Visibility = api.VisibilityModes[form.Visibility]
|
||||
}
|
||||
if err := models.UpdateUserCols(org, "full_name", "description", "website", "location", "visibility","name","lower_name","repo_admin_change_team_access"); err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "EditOrganization", err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
// update forks visibility 更新库的访问权限;
|
||||
if visibilityChanged {
|
||||
if err := org.GetRepositories(models.ListOptions{Page: 1, PageSize: org.NumRepos}); err != nil {
|
||||
ctx.ServerError("GetRepositories", err)
|
||||
return
|
||||
}
|
||||
for _, repo := range org.Repos {
|
||||
if err := models.UpdateRepository(repo, true); err != nil {
|
||||
ctx.ServerError("UpdateRepository", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
ctx.JSON(http.StatusOK, convert.ToOrganization(org))
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Create api for create organization ext inferface
|
||||
func CreateExt(ctx *context.APIContext, form api.CreateOrgOption) {
|
||||
// swagger:operation POST /orgs organization orgCreate
|
||||
// ---
|
||||
// summary: Create an organization
|
||||
// consumes:
|
||||
// - application/json
|
||||
// produces:
|
||||
// - application/json
|
||||
// parameters:
|
||||
// - name: organization
|
||||
// in: body
|
||||
// required: true
|
||||
// schema: { "$ref": "#/definitions/CreateOrgOption" }
|
||||
// responses:
|
||||
// "201":
|
||||
// "$ref": "#/responses/Organization"
|
||||
// "403":
|
||||
// "$ref": "#/responses/forbidden"
|
||||
// "422":
|
||||
// "$ref": "#/responses/validationError"
|
||||
|
||||
if !ctx.User.CanCreateOrganization() {
|
||||
ctx.Error(http.StatusForbidden, "Create organization not allowed", nil)
|
||||
return
|
||||
}
|
||||
|
||||
visibility := api.VisibleTypePublic
|
||||
if form.Visibility != "" {
|
||||
visibility = api.VisibilityModes[form.Visibility]
|
||||
}
|
||||
|
||||
org := &models.User{
|
||||
Name: form.UserName,
|
||||
FullName: form.FullName,
|
||||
Description: form.Description,
|
||||
Website: form.Website,
|
||||
Location: form.Location,
|
||||
IsActive: true,
|
||||
Type: models.UserTypeOrganization,
|
||||
Visibility: visibility,
|
||||
RepoAdminChangeTeamAccess: form.RepoAdminChangeTeamAccess,
|
||||
}
|
||||
if err := models.CreateOrganization(org, ctx.User); err != nil {
|
||||
if models.IsErrUserAlreadyExist(err) ||
|
||||
models.IsErrNameReserved(err) ||
|
||||
models.IsErrNameCharsNotAllowed(err) ||
|
||||
models.IsErrNamePatternNotAllowed(err) {
|
||||
ctx.Error(http.StatusUnprocessableEntity, "", err)
|
||||
} else {
|
||||
ctx.Error(http.StatusInternalServerError, "CreateOrganization", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 根据业务需要 自定义创建组织时将默认团队同时返回.
|
||||
Team, err := models.GetTeam(org.ID,"")
|
||||
if err != nil {
|
||||
if models.IsErrUserNotExist(err) {
|
||||
ctx.NotFound()
|
||||
} else {
|
||||
ctx.Error(http.StatusInternalServerError, "GetTeam", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
apiOrg:=convert.ToOrganizationExt(org)
|
||||
apiOrg.OwnerTeam=convert.ToTeam(Team)
|
||||
ctx.JSON(http.StatusCreated, apiOrg)
|
||||
|
||||
}
|
|
@ -6,9 +6,6 @@
|
|||
package repo
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
"code.gitea.io/gitea/modules/convert"
|
||||
|
@ -17,6 +14,8 @@ import (
|
|||
"code.gitea.io/gitea/modules/repofiles"
|
||||
repo_module "code.gitea.io/gitea/modules/repository"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// GetBranch get a branch of a repository
|
||||
|
@ -46,6 +45,8 @@ func GetBranch(ctx *context.APIContext) {
|
|||
// "200":
|
||||
// "$ref": "#/responses/Branch"
|
||||
|
||||
|
||||
|
||||
if ctx.Repo.TreePath != "" {
|
||||
// if TreePath != "", then URL contained extra slashes
|
||||
// (i.e. "master/subbranch" instead of "master"), so branch does
|
||||
|
@ -294,11 +295,13 @@ func ListBranches(ctx *context.APIContext) {
|
|||
// "200":
|
||||
// "$ref": "#/responses/BranchList"
|
||||
|
||||
//start:=time.Now()
|
||||
branches, err := repo_module.GetBranches(ctx.Repo.Repository)
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "GetBranches", err)
|
||||
return
|
||||
}
|
||||
//fmt.Println("***************** *GetBranches:",time.Now().Sub(start)," ",branches,len(branches))
|
||||
|
||||
apiBranches := make([]*api.Branch, len(branches))
|
||||
for i := range branches {
|
||||
|
@ -307,16 +310,19 @@ func ListBranches(ctx *context.APIContext) {
|
|||
ctx.Error(http.StatusInternalServerError, "GetCommit", err)
|
||||
return
|
||||
}
|
||||
//fmt.Println("****branches[i]:",branches[i])
|
||||
branchProtection, err := ctx.Repo.Repository.GetBranchProtection(branches[i].Name)
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "GetBranchProtection", err)
|
||||
return
|
||||
}
|
||||
//fmt.Println("****branchProtection:",branchProtection)
|
||||
apiBranches[i], err = convert.ToBranch(ctx.Repo.Repository, branches[i], c, branchProtection, ctx.User, ctx.Repo.IsAdmin())
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "convert.ToBranch", err)
|
||||
return
|
||||
}
|
||||
//fmt.Println("****apiBranches[i]:",apiBranches[i])
|
||||
}
|
||||
|
||||
ctx.JSON(http.StatusOK, &apiBranches)
|
||||
|
|
|
@ -528,6 +528,9 @@ func GetContents(ctx *context.APIContext) {
|
|||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
|
||||
|
||||
start:=time.Now()
|
||||
|
||||
if !canReadFiles(ctx.Repo) {
|
||||
ctx.Error(http.StatusInternalServerError, "GetContentsOrList", models.ErrUserDoesNotHaveAccessToRepo{
|
||||
UserID: ctx.User.ID,
|
||||
|
@ -535,10 +538,12 @@ func GetContents(ctx *context.APIContext) {
|
|||
})
|
||||
return
|
||||
}
|
||||
|
||||
//log.Info("*****************GetContents.1:%v",time.Now().Sub(start))
|
||||
treePath := ctx.Params("*")
|
||||
ref := ctx.QueryTrim("ref")
|
||||
|
||||
fmt.Println("***GetContents.treePath:",treePath)
|
||||
fmt.Println("***GetContents.ref:",ref)
|
||||
if fileList, err := repofiles.GetContentsOrList(ctx.Repo.Repository, treePath, ref); err != nil {
|
||||
if git.IsErrNotExist(err) {
|
||||
ctx.NotFound("GetContentsOrList", err)
|
||||
|
@ -548,6 +553,7 @@ func GetContents(ctx *context.APIContext) {
|
|||
} else {
|
||||
ctx.JSON(http.StatusOK, fileList)
|
||||
}
|
||||
log.Info("*****************GetContents:%v",time.Now().Sub(start))
|
||||
}
|
||||
|
||||
// add by qiubing
|
||||
|
|
|
@ -0,0 +1,236 @@
|
|||
package report
|
||||
|
||||
import (
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
func GetActivity(ctx *context.APIContext) {
|
||||
// swagger:operation GET /activity activity activity
|
||||
// ---
|
||||
// summary: Statistics of commit and pull request data,Platform required data **
|
||||
// produces:
|
||||
// - application/json
|
||||
// parameters:
|
||||
// - name: from
|
||||
// in: query
|
||||
// description: Query begin timestamp
|
||||
// type: string
|
||||
// required: false
|
||||
// - name: to
|
||||
// in: query
|
||||
// description: Query end timestamp
|
||||
// type: string
|
||||
// required: false
|
||||
// responses:
|
||||
// "200":
|
||||
// "$ref": "#/responses/"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
|
||||
opt:=GetParamOption(ctx)
|
||||
if opt==nil {
|
||||
return
|
||||
}
|
||||
list, err := models.GetActivity(opt)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetActivity", err)
|
||||
return
|
||||
}
|
||||
ctx.JSON(http.StatusOK,list)
|
||||
}
|
||||
|
||||
|
||||
type PrjectDTO struct {
|
||||
Project interface{} `json:"project"`
|
||||
//Param struct{
|
||||
// FromDate string `json:"from_date"`
|
||||
// ToDate string `json:"to_date"`
|
||||
//} `json:"param"`
|
||||
}
|
||||
|
||||
func GetActivityDevelop(ctx *context.APIContext) {
|
||||
// swagger:operation GET /activity/develop activity develop
|
||||
// ---
|
||||
// summary: Statistics of submitted data by developers **
|
||||
// produces:
|
||||
// - application/json
|
||||
// parameters:
|
||||
// - name: from
|
||||
// in: query
|
||||
// description: Query begin timestamp
|
||||
// type: string
|
||||
// required: false
|
||||
// - name: to
|
||||
// in: query
|
||||
// description: Query end timestamp
|
||||
// type: string
|
||||
// required: false
|
||||
// - name: top
|
||||
// in: query
|
||||
// description: Display the previous n records
|
||||
// type: integer
|
||||
// required: false
|
||||
// responses:
|
||||
// "200":
|
||||
// "$ref": "#/responses"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
|
||||
|
||||
opt:=GetParamOption(ctx)
|
||||
if opt==nil {
|
||||
return
|
||||
}
|
||||
list, err := models.GetActivityDevelop(opt)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetActivityDevelop", err)
|
||||
return
|
||||
}
|
||||
|
||||
data:=DevelopDTO{Develop:list}
|
||||
//data.Param.FromDate=opt.FromDate
|
||||
//data.Param.ToDate=opt.ToDate
|
||||
ctx.JSON(http.StatusOK,data)
|
||||
}
|
||||
type DevelopDTO struct {
|
||||
Develop interface{} `json:"develop"`
|
||||
//Param struct {
|
||||
// FromDate string `json:"from_date"`
|
||||
// ToDate string `json:"to_date"`
|
||||
//} `json:"param"`
|
||||
}
|
||||
|
||||
|
||||
func GetActivityProject(ctx *context.APIContext) {
|
||||
// swagger:operation GET /activity/project activity project
|
||||
// ---
|
||||
// summary: Statistics of submitted data by project **
|
||||
// produces:
|
||||
// - application/json
|
||||
// parameters:
|
||||
// - name: from
|
||||
// in: query
|
||||
// description: Query begin timestamp
|
||||
// type: string
|
||||
// required: false
|
||||
// - name: to
|
||||
// in: query
|
||||
// description: Query end timestamp
|
||||
// type: string
|
||||
// required: false
|
||||
// - name: top
|
||||
// in: query
|
||||
// description: Display the previous n records
|
||||
// type: integer
|
||||
// required: false
|
||||
// responses:
|
||||
// "200":
|
||||
// "$ref": "#/responses"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
|
||||
|
||||
opt:=GetParamOption(ctx)
|
||||
if opt==nil {
|
||||
return
|
||||
}
|
||||
list, err := models.GetActivityProject(opt)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetActivityProject", err)
|
||||
return
|
||||
}
|
||||
data:=PrjectDTO{Project:list}
|
||||
//data.Param.FromDate=opt.FromDate
|
||||
//data.Param.ToDate=opt.ToDate
|
||||
ctx.JSON(http.StatusOK,data)
|
||||
}
|
||||
|
||||
|
||||
func GetContributors(ctx *context.APIContext) {
|
||||
// swagger:operation GET /repos/{owner}/{repo}/contributors repository contributors
|
||||
// ---
|
||||
// summary: Get all builder information in the repository **
|
||||
// produces:
|
||||
// - application/json
|
||||
// parameters:
|
||||
// - name: owner
|
||||
// in: path
|
||||
// description: owner of the repo
|
||||
// type: string
|
||||
// required: true
|
||||
// - name: repo
|
||||
// in: path
|
||||
// description: name of the repo
|
||||
// type: string
|
||||
// required: true
|
||||
// responses:
|
||||
// "200":
|
||||
// "$ref": "#/responses/"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
|
||||
opt:= models.GetContributorsOptionsExt{
|
||||
UserId:ctx.Repo.Owner.ID,
|
||||
RepoId:ctx.Repo.Repository.ID,
|
||||
}
|
||||
list, err := models.GetContributors(opt)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetFeedsExt", err)
|
||||
return
|
||||
}
|
||||
ctx.JSON(http.StatusOK,list)
|
||||
}
|
||||
func GetParamOption(ctx *context.APIContext) (opt *models.GetGetActivityOptions) {
|
||||
Layout:="2006-01-02 15:04:05"
|
||||
//##top
|
||||
top:=ctx.QueryInt64("top")
|
||||
if top<=0 {
|
||||
top=5
|
||||
}else if top>=20 {
|
||||
top=20
|
||||
}
|
||||
|
||||
//##from
|
||||
FromDate, err := strconv.ParseInt(ctx.QueryTrim("from"), 10, 64)
|
||||
if err!=nil {
|
||||
ctx.Error(http.StatusBadRequest,"param.from", err)
|
||||
return
|
||||
}
|
||||
if FromDate <= 0 {
|
||||
ctx.Error(http.StatusBadRequest,"param.from", fmt.Errorf("请指定from参数"))
|
||||
return
|
||||
//from=time.Now().Format("2006-01-02")
|
||||
}
|
||||
|
||||
from := time.Unix(FromDate, 0).Format(Layout)
|
||||
//fmt.Println("********from:",from," ", FromDate," convert:",time.Unix( FromDate,0).Format("2006-01-02 15:04:05"))
|
||||
|
||||
|
||||
//##to
|
||||
ToDate, err := strconv.ParseInt(ctx.QueryTrim("to"), 10, 64)
|
||||
if err!=nil {
|
||||
ctx.Error(http.StatusBadRequest,"param.to ", err)
|
||||
return
|
||||
}
|
||||
if ToDate <= 0 {
|
||||
ctx.Error(http.StatusBadRequest,"param.to", fmt.Errorf("请指定to参数"))
|
||||
return
|
||||
}
|
||||
|
||||
to := time.Unix(ToDate, 0).Format(Layout)
|
||||
|
||||
//fmt.Println("********to:",to ," ", ToDate," convert:",time.Unix( ToDate,0).Format(Layout))
|
||||
opt= &models.GetGetActivityOptions{
|
||||
FromDateUnix:FromDate,
|
||||
ToDateUnix:ToDate,
|
||||
FromDate:from,
|
||||
ToDate:to,
|
||||
Top:top,
|
||||
}
|
||||
return opt
|
||||
}
|
|
@ -41,6 +41,7 @@ func ListAccessTokens(ctx *context.APIContext) {
|
|||
// "200":
|
||||
// "$ref": "#/responses/AccessTokenList"
|
||||
|
||||
|
||||
tokens, err := models.ListAccessTokens(ctx.User.ID, utils.GetListOptions(ctx))
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "ListAccessTokens", err)
|
||||
|
@ -52,6 +53,7 @@ func ListAccessTokens(ctx *context.APIContext) {
|
|||
apiTokens[i] = &api.AccessToken{
|
||||
ID: tokens[i].ID,
|
||||
Name: tokens[i].Name,
|
||||
Token: tokens[i].Token, // add by hcxm 2021/04/04 修复无Token值;
|
||||
TokenLastEight: tokens[i].TokenLastEight,
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -14,6 +14,7 @@ import (
|
|||
|
||||
// SetEditorconfigIfExists set editor config as render variable
|
||||
func SetEditorconfigIfExists(ctx *context.Context) {
|
||||
|
||||
if ctx.Repo.Repository.IsEmpty {
|
||||
ctx.Data["Editorconfig"] = nil
|
||||
return
|
||||
|
|
|
@ -113,6 +113,7 @@ func getReadmeFileFromPath(commit *git.Commit, treePath string) (*namedBlob, err
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
var readmeFile *namedBlob
|
||||
for _, f := range readmeFiles {
|
||||
if f != nil {
|
||||
|
|
|
@ -950,6 +950,7 @@ func RegisterRoutes(m *macaron.Macaron) {
|
|||
m.Get("/commit/:sha([a-f0-9]{7,40})$", repo.SetEditorconfigIfExists, repo.SetDiffViewStyle, repo.Diff)
|
||||
}, repo.MustBeNotEmpty, context.RepoRef(), reqRepoCodeReader)
|
||||
|
||||
//****** view source
|
||||
m.Group("/src", func() {
|
||||
m.Get("/branch/*", context.RepoRefByType(context.RepoRefBranch), repo.Home)
|
||||
m.Get("/tag/*", context.RepoRefByType(context.RepoRefTag), repo.Home)
|
||||
|
|
|
@ -50,6 +50,7 @@ const (
|
|||
|
||||
// AutoSignIn reads cookie and try to auto-login.
|
||||
func AutoSignIn(ctx *context.Context) (bool, error) {
|
||||
|
||||
if !models.HasEngine {
|
||||
return false, nil
|
||||
}
|
||||
|
@ -82,7 +83,6 @@ func AutoSignIn(ctx *context.Context) (bool, error) {
|
|||
}
|
||||
|
||||
isSucceed = true
|
||||
|
||||
// Set session IDs
|
||||
if err := ctx.Session.Set("uid", u.ID); err != nil {
|
||||
return false, err
|
||||
|
@ -101,6 +101,7 @@ func AutoSignIn(ctx *context.Context) (bool, error) {
|
|||
func checkAutoLogin(ctx *context.Context) bool {
|
||||
// Check auto-login.
|
||||
isSucceed, err := AutoSignIn(ctx)
|
||||
//fmt.Println("=============isSucceed, err:",isSucceed, err)
|
||||
if err != nil {
|
||||
ctx.ServerError("AutoSignIn", err)
|
||||
return true
|
||||
|
@ -126,7 +127,7 @@ func checkAutoLogin(ctx *context.Context) bool {
|
|||
func SignIn(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("sign_in")
|
||||
|
||||
// Check auto-login.
|
||||
// Check auto-login.
|
||||
if checkAutoLogin(ctx) {
|
||||
return
|
||||
}
|
||||
|
@ -170,6 +171,7 @@ func SignInPost(ctx *context.Context, form auth.SignInForm) {
|
|||
}
|
||||
|
||||
u, err := models.UserSignIn(form.UserName, form.Password)
|
||||
//fmt.Println("********err:",err)
|
||||
if err != nil {
|
||||
if models.IsErrUserNotExist(err) {
|
||||
ctx.RenderWithErr(ctx.Tr("form.username_password_incorrect"), tplSignIn, &form)
|
||||
|
@ -195,6 +197,14 @@ func SignInPost(ctx *context.Context, form auth.SignInForm) {
|
|||
}
|
||||
return
|
||||
}
|
||||
|
||||
//// 禁止非管理员身份登陆 by hcxm //2020.12.25
|
||||
//if !u.IsAdmin {
|
||||
// ctx.RenderWithErr(ctx.Tr("form.username_password_incorrect"), tplSignIn, &form)
|
||||
// //ctx.RenderWithErr(ctx.Tr("form.非管理员无权访问"), tplSignIn, &form)
|
||||
// return
|
||||
//}
|
||||
|
||||
// If this user is enrolled in 2FA, we can't sign the user in just yet.
|
||||
// Instead, redirect them to the 2FA authentication page.
|
||||
_, err = models.GetTwoFactorByUID(u.ID)
|
||||
|
@ -207,6 +217,7 @@ func SignInPost(ctx *context.Context, form auth.SignInForm) {
|
|||
return
|
||||
}
|
||||
|
||||
|
||||
// User needs to use 2FA, save data and redirect to 2FA page.
|
||||
if err := ctx.Session.Set("twofaUid", u.ID); err != nil {
|
||||
ctx.ServerError("UserSignIn: Unable to set twofaUid in session", err)
|
||||
|
|
|
@ -21,8 +21,122 @@
|
|||
},
|
||||
"version": "1.1.1"
|
||||
},
|
||||
"basePath": "{{AppSubUrl}}/api/v1",
|
||||
"basePath": "/api/v1",
|
||||
"paths": {
|
||||
"/activity": {
|
||||
"get": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"activity"
|
||||
],
|
||||
"summary": "Statistics of commit and pull request data,Platform required data **",
|
||||
"operationId": "activity",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Query begin timestamp",
|
||||
"name": "from",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Query end timestamp",
|
||||
"name": "to",
|
||||
"in": "query"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"$ref": "#/responses/"
|
||||
},
|
||||
"404": {
|
||||
"$ref": "#/responses/notFound"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/activity/develop": {
|
||||
"get": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"activity"
|
||||
],
|
||||
"summary": "Statistics of submitted data by developers **",
|
||||
"operationId": "develop",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Query begin timestamp",
|
||||
"name": "from",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Query end timestamp",
|
||||
"name": "to",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Display the previous n records",
|
||||
"name": "top",
|
||||
"in": "query"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"$ref": "#/responses"
|
||||
},
|
||||
"404": {
|
||||
"$ref": "#/responses/notFound"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/activity/project": {
|
||||
"get": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"activity"
|
||||
],
|
||||
"summary": "Statistics of submitted data by project **",
|
||||
"operationId": "project",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Query begin timestamp",
|
||||
"name": "from",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Query end timestamp",
|
||||
"name": "to",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Display the previous n records",
|
||||
"name": "top",
|
||||
"in": "query"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"$ref": "#/responses"
|
||||
},
|
||||
"404": {
|
||||
"$ref": "#/responses/notFound"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/admin/orgs": {
|
||||
"get": {
|
||||
"produces": [
|
||||
|
@ -2961,6 +3075,84 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"/repos/{owner}/{repo}/contributors": {
|
||||
"get": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"repository"
|
||||
],
|
||||
"summary": "Get all builder information in the repository **",
|
||||
"operationId": "contributors",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "owner of the repo",
|
||||
"name": "owner",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "name of the repo",
|
||||
"name": "repo",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"$ref": "#/responses/"
|
||||
},
|
||||
"404": {
|
||||
"$ref": "#/responses/notFound"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/repos/{owner}/{repo}/count": {
|
||||
"get": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"repository"
|
||||
],
|
||||
"summary": "Get commit quantity by branch which is a custom interface ****",
|
||||
"operationId": "Count",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "owner of the repo",
|
||||
"name": "owner",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "name of the repo",
|
||||
"name": "repo",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "The name of the commit/branch/tag. Default the repository’s default branch (usually master)",
|
||||
"name": "ref",
|
||||
"in": "query"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"$ref": "#/responses/CountDTO"
|
||||
},
|
||||
"404": {
|
||||
"$ref": "#/responses/notFound"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/repos/{owner}/{repo}/editorconfig/{filepath}": {
|
||||
"get": {
|
||||
"produces": [
|
||||
|
@ -3004,6 +3196,54 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"/repos/{owner}/{repo}/find": {
|
||||
"get": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"repository"
|
||||
],
|
||||
"summary": "The search file contains subdirectories, which is a custom interface *****",
|
||||
"operationId": "find",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "owner of the repo",
|
||||
"name": "owner",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "name of the repo",
|
||||
"name": "repo",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "The name of the commit/branch/tag. Default the repository’s default branch (usually master)",
|
||||
"name": "ref",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Search keywords",
|
||||
"name": "q",
|
||||
"in": "query"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"$ref": "#/responses/[]*SearchFileItem"
|
||||
},
|
||||
"404": {
|
||||
"$ref": "#/responses/notFound"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/repos/{owner}/{repo}/forks": {
|
||||
"get": {
|
||||
"produces": [
|
||||
|
@ -7328,6 +7568,48 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"/repos/{owner}/{repo}/readme": {
|
||||
"get": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"repository"
|
||||
],
|
||||
"summary": "Get the content of the readme.* file, which is a custom interface *****",
|
||||
"operationId": "readme",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "owner of the repo",
|
||||
"name": "owner",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "name of the repo",
|
||||
"name": "repo",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "The name of the commit/branch/tag. Default the repository’s default branch (usually master)",
|
||||
"name": "ref",
|
||||
"in": "query"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"$ref": "#/responses/ReadmeDTO"
|
||||
},
|
||||
"404": {
|
||||
"$ref": "#/responses/notFound"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/repos/{owner}/{repo}/releases": {
|
||||
"get": {
|
||||
"produces": [
|
||||
|
@ -7423,6 +7705,42 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"/repos/{owner}/{repo}/releases/latest": {
|
||||
"get": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"repository"
|
||||
],
|
||||
"summary": "Get the last updated Release version of the repository., which is a custom interface ****",
|
||||
"operationId": "latest",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "owner of the repo",
|
||||
"name": "owner",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "name of the repo",
|
||||
"name": "repo",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"$ref": "#/responses/release"
|
||||
},
|
||||
"404": {
|
||||
"$ref": "#/responses/notFound"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/repos/{owner}/{repo}/releases/{id}": {
|
||||
"get": {
|
||||
"produces": [
|
||||
|
@ -11028,6 +11346,11 @@
|
|||
"_links": {
|
||||
"$ref": "#/definitions/FileLinksResponse"
|
||||
},
|
||||
"commit_count": {
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"x-go-name": "CommitCount"
|
||||
},
|
||||
"content": {
|
||||
"description": "`content` is populated when `type` is `file`, otherwise null",
|
||||
"type": "string",
|
||||
|
@ -11050,6 +11373,9 @@
|
|||
"type": "string",
|
||||
"x-go-name": "HTMLURL"
|
||||
},
|
||||
"latest_commit": {
|
||||
"$ref": "#/definitions/ContentsResponseCommit"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"x-go-name": "Name"
|
||||
|
@ -11089,6 +11415,26 @@
|
|||
},
|
||||
"x-go-package": "code.gitea.io/gitea/modules/structs"
|
||||
},
|
||||
"ContentsResponseCommit": {
|
||||
"description": "add by qiubing",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"created_at": {
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"x-go-name": "Created"
|
||||
},
|
||||
"message": {
|
||||
"type": "string",
|
||||
"x-go-name": "Message"
|
||||
},
|
||||
"sha": {
|
||||
"type": "string",
|
||||
"x-go-name": "LatestCommitSha"
|
||||
}
|
||||
},
|
||||
"x-go-package": "code.gitea.io/gitea/modules/structs"
|
||||
},
|
||||
"CreateBranchProtectionOption": {
|
||||
"description": "CreateBranchProtectionOption options for creating a branch protection",
|
||||
"type": "object",
|
||||
|
|
Binary file not shown.
|
@ -66,7 +66,7 @@ var (
|
|||
// A Decoder can be used in two modes:
|
||||
//
|
||||
// 1) As a stream, or
|
||||
// 2) For stateless decoding using DecodeAll or DecodeBuffer.
|
||||
// 2) For stateless decoding using DecodeAll.
|
||||
//
|
||||
// Only a single stream can be decoded concurrently, but the same decoder
|
||||
// can run multiple concurrent stateless decodes. It is even possible to
|
||||
|
|
|
@ -172,55 +172,6 @@ encodeLoop:
|
|||
cv = load6432(src, s)
|
||||
continue
|
||||
}
|
||||
const repOff2 = 1
|
||||
// We deviate from the reference encoder and also check offset 2.
|
||||
// Slower and not consistently better, so disabled.
|
||||
// repIndex = s - offset2 + repOff2
|
||||
if false && repIndex >= 0 && load3232(src, repIndex) == uint32(cv>>(repOff2*8)) {
|
||||
// Consider history as well.
|
||||
var seq seq
|
||||
lenght := 4 + e.matchlen(s+4+repOff2, repIndex+4, src)
|
||||
|
||||
seq.matchLen = uint32(lenght - zstdMinMatch)
|
||||
|
||||
// We might be able to match backwards.
|
||||
// Extend as long as we can.
|
||||
start := s + repOff2
|
||||
// We end the search early, so we don't risk 0 literals
|
||||
// and have to do special offset treatment.
|
||||
startLimit := nextEmit + 1
|
||||
|
||||
tMin := s - e.maxMatchOff
|
||||
if tMin < 0 {
|
||||
tMin = 0
|
||||
}
|
||||
for repIndex > tMin && start > startLimit && src[repIndex-1] == src[start-1] && seq.matchLen < maxMatchLength-zstdMinMatch-1 {
|
||||
repIndex--
|
||||
start--
|
||||
seq.matchLen++
|
||||
}
|
||||
addLiterals(&seq, start)
|
||||
|
||||
// rep 2
|
||||
seq.offset = 2
|
||||
if debugSequences {
|
||||
println("repeat sequence 2", seq, "next s:", s)
|
||||
}
|
||||
blk.sequences = append(blk.sequences, seq)
|
||||
s += lenght + repOff2
|
||||
nextEmit = s
|
||||
if s >= sLimit {
|
||||
if debug {
|
||||
println("repeat ended", s, lenght)
|
||||
|
||||
}
|
||||
break encodeLoop
|
||||
}
|
||||
cv = load6432(src, s)
|
||||
// Swap offsets
|
||||
offset1, offset2 = offset2, offset1
|
||||
continue
|
||||
}
|
||||
}
|
||||
// Find the offsets of our two matches.
|
||||
coffsetL := s - (candidateL.offset - e.cur)
|
||||
|
@ -372,7 +323,7 @@ encodeLoop:
|
|||
}
|
||||
|
||||
// Store this, since we have it.
|
||||
nextHashS := hash5(cv1>>8, dFastShortTableBits)
|
||||
nextHashS := hash5(cv, dFastShortTableBits)
|
||||
nextHashL := hash8(cv, dFastLongTableBits)
|
||||
|
||||
// We have at least 4 byte match.
|
||||
|
|
|
@ -6,6 +6,7 @@ package zstd
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
"math/bits"
|
||||
|
||||
"github.com/klauspost/compress/zstd/internal/xxhash"
|
||||
|
@ -23,7 +24,7 @@ type tableEntry struct {
|
|||
offset int32
|
||||
}
|
||||
|
||||
type fastEncoder struct {
|
||||
type fastBase struct {
|
||||
o encParams
|
||||
// cur is the offset at the start of hist
|
||||
cur int32
|
||||
|
@ -31,18 +32,22 @@ type fastEncoder struct {
|
|||
maxMatchOff int32
|
||||
hist []byte
|
||||
crc *xxhash.Digest
|
||||
table [tableSize]tableEntry
|
||||
tmp [8]byte
|
||||
blk *blockEnc
|
||||
}
|
||||
|
||||
type fastEncoder struct {
|
||||
fastBase
|
||||
table [tableSize]tableEntry
|
||||
}
|
||||
|
||||
// CRC returns the underlying CRC writer.
|
||||
func (e *fastEncoder) CRC() *xxhash.Digest {
|
||||
func (e *fastBase) CRC() *xxhash.Digest {
|
||||
return e.crc
|
||||
}
|
||||
|
||||
// AppendCRC will append the CRC to the destination slice and return it.
|
||||
func (e *fastEncoder) AppendCRC(dst []byte) []byte {
|
||||
func (e *fastBase) AppendCRC(dst []byte) []byte {
|
||||
crc := e.crc.Sum(e.tmp[:0])
|
||||
dst = append(dst, crc[7], crc[6], crc[5], crc[4])
|
||||
return dst
|
||||
|
@ -50,7 +55,7 @@ func (e *fastEncoder) AppendCRC(dst []byte) []byte {
|
|||
|
||||
// WindowSize returns the window size of the encoder,
|
||||
// or a window size small enough to contain the input size, if > 0.
|
||||
func (e *fastEncoder) WindowSize(size int) int32 {
|
||||
func (e *fastBase) WindowSize(size int) int32 {
|
||||
if size > 0 && size < int(e.maxMatchOff) {
|
||||
b := int32(1) << uint(bits.Len(uint(size)))
|
||||
// Keep minimum window.
|
||||
|
@ -63,7 +68,7 @@ func (e *fastEncoder) WindowSize(size int) int32 {
|
|||
}
|
||||
|
||||
// Block returns the current block.
|
||||
func (e *fastEncoder) Block() *blockEnc {
|
||||
func (e *fastBase) Block() *blockEnc {
|
||||
return e.blk
|
||||
}
|
||||
|
||||
|
@ -169,9 +174,22 @@ encodeLoop:
|
|||
if canRepeat && repIndex >= 0 && load3232(src, repIndex) == uint32(cv>>16) {
|
||||
// Consider history as well.
|
||||
var seq seq
|
||||
lenght := 4 + e.matchlen(s+6, repIndex+4, src)
|
||||
var length int32
|
||||
// length = 4 + e.matchlen(s+6, repIndex+4, src)
|
||||
{
|
||||
a := src[s+6:]
|
||||
b := src[repIndex+4:]
|
||||
endI := len(a) & (math.MaxInt32 - 7)
|
||||
length = int32(endI) + 4
|
||||
for i := 0; i < endI; i += 8 {
|
||||
if diff := load64(a, i) ^ load64(b, i); diff != 0 {
|
||||
length = int32(i+bits.TrailingZeros64(diff)>>3) + 4
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
seq.matchLen = uint32(lenght - zstdMinMatch)
|
||||
seq.matchLen = uint32(length - zstdMinMatch)
|
||||
|
||||
// We might be able to match backwards.
|
||||
// Extend as long as we can.
|
||||
|
@ -197,11 +215,11 @@ encodeLoop:
|
|||
println("repeat sequence", seq, "next s:", s)
|
||||
}
|
||||
blk.sequences = append(blk.sequences, seq)
|
||||
s += lenght + 2
|
||||
s += length + 2
|
||||
nextEmit = s
|
||||
if s >= sLimit {
|
||||
if debug {
|
||||
println("repeat ended", s, lenght)
|
||||
println("repeat ended", s, length)
|
||||
|
||||
}
|
||||
break encodeLoop
|
||||
|
@ -257,7 +275,20 @@ encodeLoop:
|
|||
}
|
||||
|
||||
// Extend the 4-byte match as long as possible.
|
||||
l := e.matchlen(s+4, t+4, src) + 4
|
||||
//l := e.matchlen(s+4, t+4, src) + 4
|
||||
var l int32
|
||||
{
|
||||
a := src[s+4:]
|
||||
b := src[t+4:]
|
||||
endI := len(a) & (math.MaxInt32 - 7)
|
||||
l = int32(endI) + 4
|
||||
for i := 0; i < endI; i += 8 {
|
||||
if diff := load64(a, i) ^ load64(b, i); diff != 0 {
|
||||
l = int32(i+bits.TrailingZeros64(diff)>>3) + 4
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Extend backwards
|
||||
tMin := s - e.maxMatchOff
|
||||
|
@ -294,7 +325,20 @@ encodeLoop:
|
|||
if o2 := s - offset2; canRepeat && load3232(src, o2) == uint32(cv) {
|
||||
// We have at least 4 byte match.
|
||||
// No need to check backwards. We come straight from a match
|
||||
l := 4 + e.matchlen(s+4, o2+4, src)
|
||||
//l := 4 + e.matchlen(s+4, o2+4, src)
|
||||
var l int32
|
||||
{
|
||||
a := src[s+4:]
|
||||
b := src[o2+4:]
|
||||
endI := len(a) & (math.MaxInt32 - 7)
|
||||
l = int32(endI) + 4
|
||||
for i := 0; i < endI; i += 8 {
|
||||
if diff := load64(a, i) ^ load64(b, i); diff != 0 {
|
||||
l = int32(i+bits.TrailingZeros64(diff)>>3) + 4
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Store this, since we have it.
|
||||
nextHash := hash6(cv, hashLog)
|
||||
|
@ -412,10 +456,23 @@ encodeLoop:
|
|||
if len(blk.sequences) > 2 && load3232(src, repIndex) == uint32(cv>>16) {
|
||||
// Consider history as well.
|
||||
var seq seq
|
||||
// lenght := 4 + e.matchlen(s+6, repIndex+4, src)
|
||||
lenght := 4 + int32(matchLen(src[s+6:], src[repIndex+4:]))
|
||||
// length := 4 + e.matchlen(s+6, repIndex+4, src)
|
||||
// length := 4 + int32(matchLen(src[s+6:], src[repIndex+4:]))
|
||||
var length int32
|
||||
{
|
||||
a := src[s+6:]
|
||||
b := src[repIndex+4:]
|
||||
endI := len(a) & (math.MaxInt32 - 7)
|
||||
length = int32(endI) + 4
|
||||
for i := 0; i < endI; i += 8 {
|
||||
if diff := load64(a, i) ^ load64(b, i); diff != 0 {
|
||||
length = int32(i+bits.TrailingZeros64(diff)>>3) + 4
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
seq.matchLen = uint32(lenght - zstdMinMatch)
|
||||
seq.matchLen = uint32(length - zstdMinMatch)
|
||||
|
||||
// We might be able to match backwards.
|
||||
// Extend as long as we can.
|
||||
|
@ -441,11 +498,11 @@ encodeLoop:
|
|||
println("repeat sequence", seq, "next s:", s)
|
||||
}
|
||||
blk.sequences = append(blk.sequences, seq)
|
||||
s += lenght + 2
|
||||
s += length + 2
|
||||
nextEmit = s
|
||||
if s >= sLimit {
|
||||
if debug {
|
||||
println("repeat ended", s, lenght)
|
||||
println("repeat ended", s, length)
|
||||
|
||||
}
|
||||
break encodeLoop
|
||||
|
@ -498,7 +555,20 @@ encodeLoop:
|
|||
|
||||
// Extend the 4-byte match as long as possible.
|
||||
//l := e.matchlenNoHist(s+4, t+4, src) + 4
|
||||
l := int32(matchLen(src[s+4:], src[t+4:])) + 4
|
||||
// l := int32(matchLen(src[s+4:], src[t+4:])) + 4
|
||||
var l int32
|
||||
{
|
||||
a := src[s+4:]
|
||||
b := src[t+4:]
|
||||
endI := len(a) & (math.MaxInt32 - 7)
|
||||
l = int32(endI) + 4
|
||||
for i := 0; i < endI; i += 8 {
|
||||
if diff := load64(a, i) ^ load64(b, i); diff != 0 {
|
||||
l = int32(i+bits.TrailingZeros64(diff)>>3) + 4
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Extend backwards
|
||||
tMin := s - e.maxMatchOff
|
||||
|
@ -536,7 +606,20 @@ encodeLoop:
|
|||
// We have at least 4 byte match.
|
||||
// No need to check backwards. We come straight from a match
|
||||
//l := 4 + e.matchlenNoHist(s+4, o2+4, src)
|
||||
l := 4 + int32(matchLen(src[s+4:], src[o2+4:]))
|
||||
// l := 4 + int32(matchLen(src[s+4:], src[o2+4:]))
|
||||
var l int32
|
||||
{
|
||||
a := src[s+4:]
|
||||
b := src[o2+4:]
|
||||
endI := len(a) & (math.MaxInt32 - 7)
|
||||
l = int32(endI) + 4
|
||||
for i := 0; i < endI; i += 8 {
|
||||
if diff := load64(a, i) ^ load64(b, i); diff != 0 {
|
||||
l = int32(i+bits.TrailingZeros64(diff)>>3) + 4
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Store this, since we have it.
|
||||
nextHash := hash6(cv, hashLog)
|
||||
|
@ -571,7 +654,7 @@ encodeLoop:
|
|||
}
|
||||
}
|
||||
|
||||
func (e *fastEncoder) addBlock(src []byte) int32 {
|
||||
func (e *fastBase) addBlock(src []byte) int32 {
|
||||
if debugAsserts && e.cur > bufferReset {
|
||||
panic(fmt.Sprintf("ecur (%d) > buffer reset (%d)", e.cur, bufferReset))
|
||||
}
|
||||
|
@ -602,17 +685,17 @@ func (e *fastEncoder) addBlock(src []byte) int32 {
|
|||
|
||||
// useBlock will replace the block with the provided one,
|
||||
// but transfer recent offsets from the previous.
|
||||
func (e *fastEncoder) UseBlock(enc *blockEnc) {
|
||||
func (e *fastBase) UseBlock(enc *blockEnc) {
|
||||
enc.reset(e.blk)
|
||||
e.blk = enc
|
||||
}
|
||||
|
||||
func (e *fastEncoder) matchlenNoHist(s, t int32, src []byte) int32 {
|
||||
func (e *fastBase) matchlenNoHist(s, t int32, src []byte) int32 {
|
||||
// Extend the match to be as long as possible.
|
||||
return int32(matchLen(src[s:], src[t:]))
|
||||
}
|
||||
|
||||
func (e *fastEncoder) matchlen(s, t int32, src []byte) int32 {
|
||||
func (e *fastBase) matchlen(s, t int32, src []byte) int32 {
|
||||
if debugAsserts {
|
||||
if s < 0 {
|
||||
err := fmt.Sprintf("s (%d) < 0", s)
|
||||
|
@ -626,18 +709,17 @@ func (e *fastEncoder) matchlen(s, t int32, src []byte) int32 {
|
|||
err := fmt.Sprintf("s (%d) - t (%d) > maxMatchOff (%d)", s, t, e.maxMatchOff)
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
s1 := int(s) + maxMatchLength - 4
|
||||
if s1 > len(src) {
|
||||
s1 = len(src)
|
||||
if len(src)-int(s) > maxCompressedBlockSize {
|
||||
panic(fmt.Sprintf("len(src)-s (%d) > maxCompressedBlockSize (%d)", len(src)-int(s), maxCompressedBlockSize))
|
||||
}
|
||||
}
|
||||
|
||||
// Extend the match to be as long as possible.
|
||||
return int32(matchLen(src[s:s1], src[t:]))
|
||||
return int32(matchLen(src[s:], src[t:]))
|
||||
}
|
||||
|
||||
// Reset the encoding table.
|
||||
func (e *fastEncoder) Reset() {
|
||||
func (e *fastBase) Reset() {
|
||||
if e.blk == nil {
|
||||
e.blk = &blockEnc{}
|
||||
e.blk.init()
|
||||
|
|
|
@ -71,15 +71,14 @@ func NewWriter(w io.Writer, opts ...EOption) (*Encoder, error) {
|
|||
}
|
||||
if w != nil {
|
||||
e.Reset(w)
|
||||
} else {
|
||||
e.init.Do(func() {
|
||||
e.initialize()
|
||||
})
|
||||
}
|
||||
return &e, nil
|
||||
}
|
||||
|
||||
func (e *Encoder) initialize() {
|
||||
if e.o.concurrent == 0 {
|
||||
e.o.setDefault()
|
||||
}
|
||||
e.encoders = make(chan encoder, e.o.concurrent)
|
||||
for i := 0; i < e.o.concurrent; i++ {
|
||||
e.encoders <- e.o.encoder()
|
||||
|
@ -89,9 +88,6 @@ func (e *Encoder) initialize() {
|
|||
// Reset will re-initialize the writer and new writes will encode to the supplied writer
|
||||
// as a new, independent stream.
|
||||
func (e *Encoder) Reset(w io.Writer) {
|
||||
e.init.Do(func() {
|
||||
e.initialize()
|
||||
})
|
||||
s := &e.state
|
||||
s.wg.Wait()
|
||||
s.wWg.Wait()
|
||||
|
@ -422,10 +418,7 @@ func (e *Encoder) EncodeAll(src, dst []byte) []byte {
|
|||
}
|
||||
return dst
|
||||
}
|
||||
e.init.Do(func() {
|
||||
e.o.setDefault()
|
||||
e.initialize()
|
||||
})
|
||||
e.init.Do(e.initialize)
|
||||
enc := <-e.encoders
|
||||
defer func() {
|
||||
// Release encoder reference to last block.
|
||||
|
|
|
@ -39,9 +39,11 @@ func (o *encoderOptions) setDefault() {
|
|||
func (o encoderOptions) encoder() encoder {
|
||||
switch o.level {
|
||||
case SpeedDefault:
|
||||
return &doubleFastEncoder{fastEncoder: fastEncoder{maxMatchOff: int32(o.windowSize)}}
|
||||
return &doubleFastEncoder{fastEncoder: fastEncoder{fastBase: fastBase{maxMatchOff: int32(o.windowSize)}}}
|
||||
case SpeedBetterCompression:
|
||||
return &betterFastEncoder{fastBase: fastBase{maxMatchOff: int32(o.windowSize)}}
|
||||
case SpeedFastest:
|
||||
return &fastEncoder{maxMatchOff: int32(o.windowSize)}
|
||||
return &fastEncoder{fastBase: fastBase{maxMatchOff: int32(o.windowSize)}}
|
||||
}
|
||||
panic("unknown compression level")
|
||||
}
|
||||
|
@ -67,7 +69,7 @@ func WithEncoderConcurrency(n int) EOption {
|
|||
}
|
||||
|
||||
// WithWindowSize will set the maximum allowed back-reference distance.
|
||||
// The value must be a power of two between WindowSizeMin and WindowSizeMax.
|
||||
// The value must be a power of two between MinWindowSize and MaxWindowSize.
|
||||
// A larger value will enable better compression but allocate more memory and,
|
||||
// for above-default values, take considerably longer.
|
||||
// The default value is determined by the compression level.
|
||||
|
@ -130,18 +132,18 @@ const (
|
|||
// This is roughly equivalent to the default Zstandard mode (level 3).
|
||||
SpeedDefault
|
||||
|
||||
// SpeedBetterCompression will yield better compression than the default.
|
||||
// Currently it is about zstd level 7-8 with ~ 2x-3x the default CPU usage.
|
||||
// By using this, notice that CPU usage may go up in the future.
|
||||
SpeedBetterCompression
|
||||
|
||||
// speedLast should be kept as the last actual compression option.
|
||||
// The is not for external usage, but is used to keep track of the valid options.
|
||||
speedLast
|
||||
|
||||
// SpeedBetterCompression will (in the future) yield better compression than the default,
|
||||
// but at approximately 4x the CPU usage of the default.
|
||||
// For now this is not implemented.
|
||||
SpeedBetterCompression = SpeedDefault
|
||||
|
||||
// SpeedBestCompression will choose the best available compression option.
|
||||
// For now this is not implemented.
|
||||
SpeedBestCompression = SpeedDefault
|
||||
SpeedBestCompression = SpeedBetterCompression
|
||||
)
|
||||
|
||||
// EncoderLevelFromString will convert a string representation of an encoding level back
|
||||
|
@ -163,8 +165,10 @@ func EncoderLevelFromZstd(level int) EncoderLevel {
|
|||
switch {
|
||||
case level < 3:
|
||||
return SpeedFastest
|
||||
case level >= 3:
|
||||
case level >= 3 && level < 6:
|
||||
return SpeedDefault
|
||||
case level > 5:
|
||||
return SpeedBetterCompression
|
||||
}
|
||||
return SpeedDefault
|
||||
}
|
||||
|
@ -176,6 +180,8 @@ func (e EncoderLevel) String() string {
|
|||
return "fastest"
|
||||
case SpeedDefault:
|
||||
return "default"
|
||||
case SpeedBetterCompression:
|
||||
return "better"
|
||||
default:
|
||||
return "invalid"
|
||||
}
|
||||
|
|
|
@ -87,6 +87,17 @@ func printf(format string, a ...interface{}) {
|
|||
}
|
||||
}
|
||||
|
||||
// matchLenFast does matching, but will not match the last up to 7 bytes.
|
||||
func matchLenFast(a, b []byte) int {
|
||||
endI := len(a) & (math.MaxInt32 - 7)
|
||||
for i := 0; i < endI; i += 8 {
|
||||
if diff := load64(a, i) ^ load64(b, i); diff != 0 {
|
||||
return i + bits.TrailingZeros64(diff)>>3
|
||||
}
|
||||
}
|
||||
return endI
|
||||
}
|
||||
|
||||
// matchLen returns the maximum length.
|
||||
// a must be the shortest of the two.
|
||||
// The function also returns whether all bytes matched.
|
||||
|
@ -97,33 +108,18 @@ func matchLen(a, b []byte) int {
|
|||
return i + (bits.TrailingZeros64(diff) >> 3)
|
||||
}
|
||||
}
|
||||
|
||||
checked := (len(a) >> 3) << 3
|
||||
a = a[checked:]
|
||||
b = b[checked:]
|
||||
// TODO: We could do a 4 check.
|
||||
for i := range a {
|
||||
if a[i] != b[i] {
|
||||
return int(i) + checked
|
||||
return i + checked
|
||||
}
|
||||
}
|
||||
return len(a) + checked
|
||||
}
|
||||
|
||||
// matchLen returns a match length in src between index s and t
|
||||
func matchLenIn(src []byte, s, t int32) int32 {
|
||||
s1 := len(src)
|
||||
b := src[t:]
|
||||
a := src[s:s1]
|
||||
b = b[:len(a)]
|
||||
// Extend the match to be as long as possible.
|
||||
for i := range a {
|
||||
if a[i] != b[i] {
|
||||
return int32(i)
|
||||
}
|
||||
}
|
||||
return int32(len(a))
|
||||
}
|
||||
|
||||
func load3232(b []byte, i int32) uint32 {
|
||||
// Help the compiler eliminate bounds checks on the read so it can be done in a single read.
|
||||
b = b[i:]
|
||||
|
|
|
@ -58,6 +58,7 @@ github.com/PuerkitoBio/goquery
|
|||
# github.com/PuerkitoBio/purell v1.1.1
|
||||
github.com/PuerkitoBio/purell
|
||||
# github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578
|
||||
## explicit
|
||||
github.com/PuerkitoBio/urlesc
|
||||
# github.com/RoaringBitmap/roaring v0.4.23
|
||||
## explicit
|
||||
|
@ -100,12 +101,15 @@ github.com/andybalholm/brotli
|
|||
# github.com/andybalholm/cascadia v1.1.0
|
||||
github.com/andybalholm/cascadia
|
||||
# github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239
|
||||
## explicit
|
||||
github.com/anmitsu/go-shlex
|
||||
# github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a
|
||||
github.com/asaskevich/govalidator
|
||||
# github.com/aymerick/douceur v0.2.0
|
||||
## explicit
|
||||
github.com/aymerick/douceur/css
|
||||
# github.com/beorn7/perks v1.0.1
|
||||
## explicit
|
||||
github.com/beorn7/perks/quantile
|
||||
# github.com/bgentry/speakeasy v0.1.0
|
||||
## explicit
|
||||
|
@ -176,6 +180,7 @@ github.com/chris-ramon/douceur/parser
|
|||
github.com/couchbase/gomemcached
|
||||
github.com/couchbase/gomemcached/client
|
||||
# github.com/couchbase/goutils v0.0.0-20191018232750-b49639060d85
|
||||
## explicit
|
||||
github.com/couchbase/goutils/logging
|
||||
github.com/couchbase/goutils/scramsha
|
||||
# github.com/couchbase/vellum v1.0.1
|
||||
|
@ -194,6 +199,7 @@ github.com/couchbaselabs/go-couchbase
|
|||
# github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964
|
||||
github.com/danwakefield/fnmatch
|
||||
# github.com/davecgh/go-spew v1.1.1
|
||||
## explicit
|
||||
github.com/davecgh/go-spew/spew
|
||||
# github.com/denisenkom/go-mssqldb v0.0.0-20200428022330-06a60b6afbbc
|
||||
## explicit
|
||||
|
@ -205,6 +211,7 @@ github.com/denisenkom/go-mssqldb/internal/querytext
|
|||
## explicit
|
||||
github.com/dgrijalva/jwt-go
|
||||
# github.com/dlclark/regexp2 v1.2.0
|
||||
## explicit
|
||||
github.com/dlclark/regexp2
|
||||
github.com/dlclark/regexp2/syntax
|
||||
# github.com/dsnet/compress v0.0.1
|
||||
|
@ -238,8 +245,10 @@ github.com/ethantkoenig/rupture
|
|||
# github.com/facebookgo/subset v0.0.0-20150612182917-8dac2c3c4870
|
||||
## explicit
|
||||
# github.com/fatih/color v1.9.0
|
||||
## explicit
|
||||
github.com/fatih/color
|
||||
# github.com/fatih/structtag v1.2.0
|
||||
## explicit
|
||||
github.com/fatih/structtag
|
||||
# github.com/fsnotify/fsnotify v1.4.7
|
||||
github.com/fsnotify/fsnotify
|
||||
|
@ -260,6 +269,7 @@ github.com/go-enry/go-enry/v2/regex
|
|||
# github.com/go-enry/go-oniguruma v1.2.1
|
||||
github.com/go-enry/go-oniguruma
|
||||
# github.com/go-git/gcfg v1.5.0
|
||||
## explicit
|
||||
github.com/go-git/gcfg
|
||||
github.com/go-git/gcfg/scanner
|
||||
github.com/go-git/gcfg/token
|
||||
|
@ -317,12 +327,19 @@ github.com/go-git/go-git/v5/utils/merkletrie/filesystem
|
|||
github.com/go-git/go-git/v5/utils/merkletrie/index
|
||||
github.com/go-git/go-git/v5/utils/merkletrie/internal/frame
|
||||
github.com/go-git/go-git/v5/utils/merkletrie/noder
|
||||
# github.com/go-macaron/gzip v0.0.0-20200329073552-98214d7a897e
|
||||
## explicit
|
||||
# github.com/go-macaron/toolbox v0.0.0-20200329073429-4401f4ce0f55
|
||||
## explicit
|
||||
# github.com/go-openapi/analysis v0.19.5
|
||||
## explicit
|
||||
github.com/go-openapi/analysis
|
||||
github.com/go-openapi/analysis/internal
|
||||
# github.com/go-openapi/errors v0.19.2
|
||||
## explicit
|
||||
github.com/go-openapi/errors
|
||||
# github.com/go-openapi/inflect v0.19.0
|
||||
## explicit
|
||||
github.com/go-openapi/inflect
|
||||
# github.com/go-openapi/jsonpointer v0.19.3
|
||||
github.com/go-openapi/jsonpointer
|
||||
|
@ -330,9 +347,11 @@ github.com/go-openapi/jsonpointer
|
|||
## explicit
|
||||
github.com/go-openapi/jsonreference
|
||||
# github.com/go-openapi/loads v0.19.3
|
||||
## explicit
|
||||
github.com/go-openapi/loads
|
||||
github.com/go-openapi/loads/fmts
|
||||
# github.com/go-openapi/runtime v0.19.5
|
||||
## explicit
|
||||
github.com/go-openapi/runtime
|
||||
github.com/go-openapi/runtime/logger
|
||||
github.com/go-openapi/runtime/middleware
|
||||
|
@ -341,12 +360,16 @@ github.com/go-openapi/runtime/middleware/header
|
|||
github.com/go-openapi/runtime/middleware/untyped
|
||||
github.com/go-openapi/runtime/security
|
||||
# github.com/go-openapi/spec v0.19.3
|
||||
## explicit
|
||||
github.com/go-openapi/spec
|
||||
# github.com/go-openapi/strfmt v0.19.3
|
||||
## explicit
|
||||
github.com/go-openapi/strfmt
|
||||
# github.com/go-openapi/swag v0.19.5
|
||||
## explicit
|
||||
github.com/go-openapi/swag
|
||||
# github.com/go-openapi/validate v0.19.3
|
||||
## explicit
|
||||
github.com/go-openapi/validate
|
||||
# github.com/go-redis/redis v6.15.2+incompatible
|
||||
## explicit
|
||||
|
@ -361,6 +384,7 @@ github.com/go-redis/redis/internal/util
|
|||
## explicit
|
||||
github.com/go-sql-driver/mysql
|
||||
# github.com/go-stack/stack v1.8.0
|
||||
## explicit
|
||||
github.com/go-stack/stack
|
||||
# github.com/go-swagger/go-swagger v0.21.0
|
||||
## explicit
|
||||
|
@ -394,17 +418,20 @@ github.com/gogs/cron
|
|||
# github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe
|
||||
github.com/golang-sql/civil
|
||||
# github.com/golang/gddo v0.0.0-20190419222130-af0f2af80721
|
||||
## explicit
|
||||
github.com/golang/gddo/httputil
|
||||
github.com/golang/gddo/httputil/header
|
||||
# github.com/golang/protobuf v1.4.1
|
||||
## explicit
|
||||
github.com/golang/protobuf/proto
|
||||
# github.com/golang/snappy v0.0.1
|
||||
## explicit
|
||||
github.com/golang/snappy
|
||||
# github.com/google/go-github/v32 v32.1.0
|
||||
## explicit
|
||||
github.com/google/go-github/v32/github
|
||||
# github.com/google/go-querystring v1.0.0
|
||||
## explicit
|
||||
github.com/google/go-querystring/query
|
||||
# github.com/google/uuid v1.1.1
|
||||
## explicit
|
||||
|
@ -413,8 +440,10 @@ github.com/google/uuid
|
|||
## explicit
|
||||
github.com/gorilla/context
|
||||
# github.com/gorilla/css v1.0.0
|
||||
## explicit
|
||||
github.com/gorilla/css/scanner
|
||||
# github.com/gorilla/handlers v1.4.2
|
||||
## explicit
|
||||
github.com/gorilla/handlers
|
||||
# github.com/gorilla/mux v1.7.3
|
||||
github.com/gorilla/mux
|
||||
|
@ -454,6 +483,7 @@ github.com/jaytaylor/html2text
|
|||
# github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99
|
||||
github.com/jbenet/go-context/io
|
||||
# github.com/jessevdk/go-flags v1.4.0
|
||||
## explicit
|
||||
github.com/jessevdk/go-flags
|
||||
# github.com/jmhodges/levigo v1.0.0
|
||||
## explicit
|
||||
|
@ -477,7 +507,7 @@ github.com/keybase/go-crypto/openpgp/errors
|
|||
github.com/keybase/go-crypto/openpgp/packet
|
||||
github.com/keybase/go-crypto/openpgp/s2k
|
||||
github.com/keybase/go-crypto/rsa
|
||||
# github.com/klauspost/compress v1.10.2
|
||||
# github.com/klauspost/compress v1.10.3
|
||||
## explicit
|
||||
github.com/klauspost/compress/flate
|
||||
github.com/klauspost/compress/fse
|
||||
|
@ -489,6 +519,7 @@ github.com/klauspost/compress/zstd/internal/xxhash
|
|||
# github.com/klauspost/pgzip v1.2.1
|
||||
github.com/klauspost/pgzip
|
||||
# github.com/kr/pretty v0.1.0
|
||||
## explicit
|
||||
github.com/kr/pretty
|
||||
# github.com/kr/text v0.2.0
|
||||
github.com/kr/text
|
||||
|
@ -505,8 +536,10 @@ github.com/lib/pq/scram
|
|||
## explicit
|
||||
github.com/lunny/dingtalk_webhook
|
||||
# github.com/lunny/log v0.0.0-20160921050905-7887c61bf0de
|
||||
## explicit
|
||||
github.com/lunny/log
|
||||
# github.com/lunny/nodb v0.0.0-20160621015157-fc1ef06ad4af
|
||||
## explicit
|
||||
github.com/lunny/nodb
|
||||
github.com/lunny/nodb/config
|
||||
github.com/lunny/nodb/store
|
||||
|
@ -547,6 +580,7 @@ github.com/mattn/go-runewidth
|
|||
## explicit
|
||||
github.com/mattn/go-sqlite3
|
||||
# github.com/matttproud/golang_protobuf_extensions v1.0.1
|
||||
## explicit
|
||||
github.com/matttproud/golang_protobuf_extensions/pbutil
|
||||
# github.com/mcuadros/go-version v0.0.0-20190308113854-92cdf37c5b75
|
||||
## explicit
|
||||
|
@ -586,6 +620,7 @@ github.com/niklasfasching/go-org/org
|
|||
# github.com/nwaples/rardecode v1.0.0
|
||||
github.com/nwaples/rardecode
|
||||
# github.com/olekukonko/tablewriter v0.0.4
|
||||
## explicit
|
||||
github.com/olekukonko/tablewriter
|
||||
# github.com/oliamb/cutter v0.2.2
|
||||
## explicit
|
||||
|
@ -598,14 +633,17 @@ github.com/olivere/elastic/v7/uritemplates
|
|||
# github.com/pelletier/go-toml v1.4.0
|
||||
github.com/pelletier/go-toml
|
||||
# github.com/philhofer/fwd v1.0.0
|
||||
## explicit
|
||||
github.com/philhofer/fwd
|
||||
# github.com/pierrec/lz4 v2.0.5+incompatible
|
||||
## explicit
|
||||
github.com/pierrec/lz4
|
||||
github.com/pierrec/lz4/internal/xxh32
|
||||
# github.com/pkg/errors v0.9.1
|
||||
## explicit
|
||||
github.com/pkg/errors
|
||||
# github.com/pmezard/go-difflib v1.0.0
|
||||
## explicit
|
||||
github.com/pmezard/go-difflib/difflib
|
||||
# github.com/pquerna/otp v1.2.0
|
||||
## explicit
|
||||
|
@ -621,6 +659,7 @@ github.com/prometheus/client_golang/prometheus/promhttp
|
|||
## explicit
|
||||
github.com/prometheus/client_model/go
|
||||
# github.com/prometheus/common v0.6.0
|
||||
## explicit
|
||||
github.com/prometheus/common/expfmt
|
||||
github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg
|
||||
github.com/prometheus/common/model
|
||||
|
@ -645,6 +684,7 @@ github.com/shurcooL/httpfs/vfsutil
|
|||
## explicit
|
||||
github.com/shurcooL/vfsgen
|
||||
# github.com/siddontang/go-snappy v0.0.0-20140704025258-d8f7bb82a96d
|
||||
## explicit
|
||||
github.com/siddontang/go-snappy/snappy
|
||||
# github.com/spf13/afero v1.2.2
|
||||
github.com/spf13/afero
|
||||
|
@ -656,6 +696,7 @@ github.com/spf13/jwalterweatherman
|
|||
# github.com/spf13/pflag v1.0.5
|
||||
github.com/spf13/pflag
|
||||
# github.com/spf13/viper v1.4.0
|
||||
## explicit
|
||||
github.com/spf13/viper
|
||||
# github.com/steveyen/gtreap v0.1.0
|
||||
github.com/steveyen/gtreap
|
||||
|
@ -664,6 +705,7 @@ github.com/steveyen/gtreap
|
|||
github.com/stretchr/testify/assert
|
||||
github.com/stretchr/testify/require
|
||||
# github.com/syndtr/goleveldb v1.0.0
|
||||
## explicit
|
||||
github.com/syndtr/goleveldb/leveldb
|
||||
github.com/syndtr/goleveldb/leveldb/cache
|
||||
github.com/syndtr/goleveldb/leveldb/comparer
|
||||
|
@ -682,6 +724,7 @@ github.com/syndtr/goleveldb/leveldb/util
|
|||
## explicit
|
||||
github.com/tinylib/msgp/msgp
|
||||
# github.com/toqueteos/webbrowser v1.2.0
|
||||
## explicit
|
||||
github.com/toqueteos/webbrowser
|
||||
# github.com/tstranex/u2f v1.0.0
|
||||
## explicit
|
||||
|
@ -735,6 +778,7 @@ github.com/yuin/goldmark-meta
|
|||
# go.etcd.io/bbolt v1.3.4
|
||||
go.etcd.io/bbolt
|
||||
# go.mongodb.org/mongo-driver v1.1.1
|
||||
## explicit
|
||||
go.mongodb.org/mongo-driver/bson
|
||||
go.mongodb.org/mongo-driver/bson/bsoncodec
|
||||
go.mongodb.org/mongo-driver/bson/bsonrw
|
||||
|
@ -770,6 +814,7 @@ golang.org/x/crypto/ssh/agent
|
|||
golang.org/x/crypto/ssh/internal/bcrypt_pbkdf
|
||||
golang.org/x/crypto/ssh/knownhosts
|
||||
# golang.org/x/mod v0.2.0
|
||||
## explicit
|
||||
golang.org/x/mod/module
|
||||
golang.org/x/mod/semver
|
||||
# golang.org/x/net v0.0.0-20200602114024-627f9648deb9
|
||||
|
@ -846,6 +891,7 @@ golang.org/x/tools/internal/gopathwalk
|
|||
golang.org/x/tools/internal/imports
|
||||
golang.org/x/tools/internal/packagesinternal
|
||||
# golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543
|
||||
## explicit
|
||||
golang.org/x/xerrors
|
||||
golang.org/x/xerrors/internal
|
||||
# google.golang.org/appengine v1.6.5
|
||||
|
@ -861,6 +907,7 @@ google.golang.org/appengine/internal/remote_api
|
|||
google.golang.org/appengine/internal/urlfetch
|
||||
google.golang.org/appengine/urlfetch
|
||||
# google.golang.org/protobuf v1.22.0
|
||||
## explicit
|
||||
google.golang.org/protobuf/encoding/prototext
|
||||
google.golang.org/protobuf/encoding/protowire
|
||||
google.golang.org/protobuf/internal/descfmt
|
||||
|
@ -903,7 +950,10 @@ gopkg.in/ini.v1
|
|||
# gopkg.in/ldap.v3 v3.0.2
|
||||
## explicit
|
||||
gopkg.in/ldap.v3
|
||||
# gopkg.in/macaron.v1 v1.4.0
|
||||
## explicit
|
||||
# gopkg.in/warnings.v0 v0.1.2
|
||||
## explicit
|
||||
gopkg.in/warnings.v0
|
||||
# gopkg.in/yaml.v2 v2.3.0
|
||||
## explicit
|
||||
|
|
Loading…
Reference in New Issue