Lines of code counter for Gitea
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
|
||
---|---|---|
models | ||
modules | ||
routes | ||
.gitignore | ||
.woodpecker.yml | ||
go.mod | ||
go.sum | ||
LICENSE | ||
main.go | ||
README.md |
tea-cloc
Lines of code counter for Gitea
Usage
- Clone the repository
git clone https://codeberg.org/qwerty287/tea-cloc.git
or download a binary - Create a file called
config.ini
that holds your configuration - Start the server
- if you downloaded the binary, just run
./tea-cloc
- if you cloned the source code: just run
go run main.go
- if you cloned the source code: or compile a binary with
go build
and run with./tea-cloc
- if you downloaded the binary, just run
- for every repository you want to use tea-cloc, open the webhook settings of the repository and create a new
Gitea
webhook (Trigger On and Branch filter depend on what you would like to use, of course)- Target URL: the URL used for your tea-cloc server, with
/hook
path (e.g.http://localhost:8080/hook
) - HTTP Method:
POST
- POST Content Type:
application/json
- Secret: the secret your config contains
- Trigger On: Custom Events...
- Repository Events
- Push
- Pull Request Events
- Pull Request
- Pull Request Synchronized
- Repository Events
- Branch filter:
*
- Active: ✅
- Target URL: the URL used for your tea-cloc server, with
Config
Configuration is stored as INI file in config.ini
. If you need a "global" file location, the secondary one is /etc/tea-cloc.ini
.
Sections:
tokens
- contains instance's tokens (and usernames) in the format
"<instance>"=<username>:<token>
- must use full instance name how it is returned in webhooks. For example,
http://localhost:3000
and notlocalhost:3000
(without a trailing slash) - if you would like to work with private repositories, the
username
must be set. It will allow Git to clone them. The corresponding user must have read permissions to repository and must match with the user owning the token.
- must use full instance name how it is returned in webhooks. For example,
database
TYPE
:mysql
,postgresql
,mssql
orsqlite3
(defaultsqlite3
)PATH
: path to SQLite database (defaultdb.sqlite
)TIMEOUT
: timeout for SQLite database (default 500)HOST
: database host for MySQL, MSSQL or PostgreSQL databaseNAME
: database name for MySQL, MSSQL or PostgreSQL databaseUSER
: database user for MySQL, MSSQL or PostgreSQL databasePASSWORD
: database password for MySQL, MSSQL or PostgreSQL databaseSSL
: whether to use SSL/TLS for MySQL, MSSQL or PostgreSQL databaseCHARSET
: database charset for MySQL database
server
DEBUG_MODE
: run Gin in debug mode (default false)PORT
: port to listen to (default 8080, can be overridden using the-port
flag)DOMAIN
: domain of the serverSECRET
: secret to protect webhooksALLOW_PUSH
: allow push events (default true)ALLOW_PR
: allow pull request events (default true)TLS_MODE
:none
,customcert
orletsencrypt
(defaultnone
). If you useletsencrypt
, you accept the terms and conditions of Let's Encrypt.TLS_CERT
: path to TLS certificate. Only used ifserver.TLS_MODE
iscustomcert
.TLS_PRIV
: path to TLS private key. Only used ifserver.TLS_MODE
iscustomcert
.COMMENT_TYPE
: type of Gitea comments,table
,json
,yaml
orxml
(defaulttable
)STATUS_CONTEXT
: context of the commit status sent to Gitea (defaulttea-cloc
)STATUS_CONTEXT_PR
: context of the commit status sent to Gitea for PR checks (defaulttea-cloc (PR)
)SKIP
: commits containing this will be skipped (default[skip cloc]
)OWNER
: owner of repos where counting is allowedREPO
: name of repos where counting is allowed (this only affects the repo name and not the owner)
data
TMP
: use a temporary directory (e.g. usually under Unix as a subdirectory of/tmp
). DO NOT DISABLE THIS IN A PRODUCTIVE ENVIRONMENT. This is necessary to run multiple checks at one time in one repository (default true)LOCATION
: where to save temporary data to count LOC, ignored ifdata.TMP
istrue
(defaultdata/
)KEEP
: keep data directories after counting (default false). Not recommended.
Simple example configuration suitable for debugging:
[tokens]
"http://localhost:3000"=username:33ab5639bfd8e7b95eb1d8d0b87781d4ffea4d5d
[server]
DEBUG_MODE=true
[database]
TYPE=sqlite3
PATH=db.sqlite