Compare commits
3 Commits
main
...
release/v0
Author | SHA1 | Date |
---|---|---|
techknowlogick | fff1af1029 | |
6543 | f28f199e85 | |
6543 | c00418e74c |
|
@ -1,20 +0,0 @@
|
|||
{
|
||||
"name": "Tea DevContainer",
|
||||
"image": "mcr.microsoft.com/devcontainers/go:1.22-bullseye",
|
||||
"features": {
|
||||
"ghcr.io/devcontainers/features/git-lfs:1.2.2": {}
|
||||
},
|
||||
"customizations": {
|
||||
"vscode": {
|
||||
"settings": {},
|
||||
"extensions": [
|
||||
"editorconfig.editorconfig",
|
||||
"golang.go",
|
||||
"stylelint.vscode-stylelint",
|
||||
"DavidAnson.vscode-markdownlint",
|
||||
"ms-azuretools.vscode-docker",
|
||||
"GitHub.vscode-pull-request-github"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,219 @@
|
|||
---
|
||||
kind: pipeline
|
||||
name: default
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: amd64
|
||||
|
||||
steps:
|
||||
- name: vendor
|
||||
pull: always
|
||||
image: golang:1.18
|
||||
environment:
|
||||
GOPROXY: https://goproxy.io # proxy.golang.org is blocked in China, this proxy is not
|
||||
commands:
|
||||
- make vendor # use vendor folder as cache
|
||||
|
||||
- name: build
|
||||
pull: always
|
||||
image: golang:1.18
|
||||
environment:
|
||||
GOPROXY: https://goproxy.io # proxy.golang.org is blocked in China, this proxy is not
|
||||
commands:
|
||||
- make clean
|
||||
- make vet
|
||||
- make lint
|
||||
- make fmt-check
|
||||
- make misspell-check
|
||||
- make build
|
||||
when:
|
||||
event:
|
||||
- push
|
||||
- tag
|
||||
- pull_request
|
||||
|
||||
- name: unit-test
|
||||
image: golang:1.18
|
||||
commands:
|
||||
- make unit-test-coverage
|
||||
settings:
|
||||
group: test
|
||||
environment:
|
||||
GOPROXY: https://goproxy.io # proxy.golang.org is blocked in China, this proxy is not
|
||||
when:
|
||||
branch:
|
||||
- main
|
||||
event:
|
||||
- push
|
||||
- pull_request
|
||||
|
||||
- name: release-test
|
||||
image: golang:1.18
|
||||
commands:
|
||||
- make test
|
||||
settings:
|
||||
group: test
|
||||
environment:
|
||||
GOPROXY: https://goproxy.io # proxy.golang.org is blocked in China, this proxy is not
|
||||
when:
|
||||
branch:
|
||||
- "release/*"
|
||||
event:
|
||||
- push
|
||||
- pull_request
|
||||
|
||||
- name: tag-test
|
||||
pull: always
|
||||
image: golang:1.18
|
||||
commands:
|
||||
- make test
|
||||
settings:
|
||||
group: test
|
||||
environment:
|
||||
GOPROXY: https://goproxy.io # proxy.golang.org is blocked in China, this proxy is not
|
||||
when:
|
||||
event:
|
||||
- tag
|
||||
|
||||
- name: static
|
||||
image: golang:1.18
|
||||
environment:
|
||||
GOPROXY: https://goproxy.io # proxy.golang.org is blocked in China, this proxy is not
|
||||
commands:
|
||||
- make release
|
||||
when:
|
||||
event:
|
||||
- push
|
||||
- tag
|
||||
|
||||
- name: gpg-sign
|
||||
pull: always
|
||||
image: plugins/gpgsign:1
|
||||
settings:
|
||||
detach_sign: true
|
||||
excludes:
|
||||
- "dist/release/*.sha256"
|
||||
files:
|
||||
- "dist/release/*"
|
||||
environment:
|
||||
GPGSIGN_KEY:
|
||||
from_secret: gpgsign_key
|
||||
GPGSIGN_PASSPHRASE:
|
||||
from_secret: gpgsign_passphrase
|
||||
when:
|
||||
event:
|
||||
- push
|
||||
- tag
|
||||
|
||||
- name: tag-release
|
||||
pull: always
|
||||
image: woodpeckerci/plugin-s3:latest
|
||||
settings:
|
||||
acl:
|
||||
from_secret: aws_s3_acl
|
||||
region:
|
||||
from_secret: aws_s3_region
|
||||
bucket:
|
||||
from_secret: aws_s3_bucket
|
||||
endpoint:
|
||||
from_secret: aws_s3_endpoint
|
||||
path_style:
|
||||
from_secret: aws_s3_path_style
|
||||
source: "dist/release/*"
|
||||
strip_prefix: dist/release/
|
||||
target: "/tea/${DRONE_TAG##v}"
|
||||
environment:
|
||||
AWS_ACCESS_KEY_ID:
|
||||
from_secret: aws_access_key_id
|
||||
AWS_SECRET_ACCESS_KEY:
|
||||
from_secret: aws_secret_access_key
|
||||
when:
|
||||
event:
|
||||
- tag
|
||||
|
||||
- name: release-branch-release
|
||||
pull: always
|
||||
image: woodpeckerci/plugin-s3:latest
|
||||
settings:
|
||||
acl:
|
||||
from_secret: aws_s3_acl
|
||||
region:
|
||||
from_secret: aws_s3_region
|
||||
bucket:
|
||||
from_secret: aws_s3_bucket
|
||||
endpoint:
|
||||
from_secret: aws_s3_endpoint
|
||||
path_style:
|
||||
from_secret: aws_s3_path_style
|
||||
source: "dist/release/*"
|
||||
strip_prefix: dist/release/
|
||||
target: "/tea/${DRONE_BRANCH##release/v}"
|
||||
environment:
|
||||
AWS_ACCESS_KEY_ID:
|
||||
from_secret: aws_access_key_id
|
||||
AWS_SECRET_ACCESS_KEY:
|
||||
from_secret: aws_secret_access_key
|
||||
when:
|
||||
branch:
|
||||
- "release/*"
|
||||
event:
|
||||
- push
|
||||
|
||||
- name: release
|
||||
pull: always
|
||||
image: woodpeckerci/plugin-s3:latest
|
||||
settings:
|
||||
acl:
|
||||
from_secret: aws_s3_acl
|
||||
region:
|
||||
from_secret: aws_s3_region
|
||||
bucket:
|
||||
from_secret: aws_s3_bucket
|
||||
endpoint:
|
||||
from_secret: aws_s3_endpoint
|
||||
path_style:
|
||||
from_secret: aws_s3_path_style
|
||||
source: "dist/release/*"
|
||||
strip_prefix: dist/release/
|
||||
target: /tea/main
|
||||
environment:
|
||||
AWS_ACCESS_KEY_ID:
|
||||
from_secret: aws_access_key_id
|
||||
AWS_SECRET_ACCESS_KEY:
|
||||
from_secret: aws_secret_access_key
|
||||
when:
|
||||
branch:
|
||||
- main
|
||||
event:
|
||||
- push
|
||||
|
||||
- name: gitea
|
||||
pull: always
|
||||
image: plugins/gitea-release:1
|
||||
settings:
|
||||
files:
|
||||
- "dist/release/*"
|
||||
base_url: https://gitea.com
|
||||
api_key:
|
||||
from_secret: gitea_token
|
||||
when:
|
||||
event:
|
||||
- tag
|
||||
|
||||
- name: discord
|
||||
pull: always
|
||||
image: appleboy/drone-discord:1.0.0
|
||||
environment:
|
||||
DISCORD_WEBHOOK_ID:
|
||||
from_secret: discord_webhook_id
|
||||
DISCORD_WEBHOOK_TOKEN:
|
||||
from_secret: discord_webhook_token
|
||||
when:
|
||||
event:
|
||||
- push
|
||||
- tag
|
||||
- pull_request
|
||||
status:
|
||||
- changed
|
||||
- failure
|
|
@ -8,7 +8,7 @@ labels:
|
|||
|
||||
### describe your environment
|
||||
- tea version used (`tea -v`):
|
||||
- [ ] I also reproduced the issue [with the latest main build](https://dl.gitea.com/tea/main/)
|
||||
- [ ] I also reproduced the issue [with the latest master build](https://dl.gitea.io/tea/master)
|
||||
- Gitea version used:
|
||||
- [ ] the issue only occurred after updating gitea recently
|
||||
- operating system:
|
||||
|
|
|
@ -1,75 +0,0 @@
|
|||
name: goreleaser
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
|
||||
jobs:
|
||||
goreleaser:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- run: git fetch --force --tags
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: "go.mod"
|
||||
- name: import gpg
|
||||
id: import_gpg
|
||||
uses: crazy-max/ghaction-import-gpg@v6
|
||||
with:
|
||||
gpg_private_key: ${{ secrets.GPGSIGN_KEY }}
|
||||
passphrase: ${{ secrets.GPGSIGN_PASSPHRASE }}
|
||||
- name: goreleaser
|
||||
uses: goreleaser/goreleaser-action@v6
|
||||
with:
|
||||
distribution: goreleaser-pro
|
||||
version: "~> v1"
|
||||
args: release --nightly
|
||||
env:
|
||||
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
|
||||
AWS_REGION: ${{ secrets.AWS_REGION }}
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
S3_REGION: ${{ secrets.AWS_REGION }}
|
||||
S3_BUCKET: ${{ secrets.AWS_BUCKET }}
|
||||
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
|
||||
GPGSIGN_PASSPHRASE: ${{ secrets.GPGSIGN_PASSPHRASE }}
|
||||
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
release-image:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
DOCKER_ORG: gitea
|
||||
DOCKER_LATEST: nightly
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0 # all history for all branches and tags
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker BuildX
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v6
|
||||
env:
|
||||
ACTIONS_RUNTIME_TOKEN: '' # See https://gitea.com/gitea/act_runner/issues/119
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
platforms: |
|
||||
linux/amd64
|
||||
linux/arm64
|
||||
push: true
|
||||
tags: |
|
||||
gitea/tea:latest
|
|
@ -1,42 +0,0 @@
|
|||
name: goreleaser
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
jobs:
|
||||
goreleaser:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- run: git fetch --force --tags
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: 'go.mod'
|
||||
- name: import gpg
|
||||
id: import_gpg
|
||||
uses: crazy-max/ghaction-import-gpg@v6
|
||||
with:
|
||||
gpg_private_key: ${{ secrets.GPGSIGN_KEY }}
|
||||
passphrase: ${{ secrets.GPGSIGN_PASSPHRASE }}
|
||||
fingerprint: CC64B1DB67ABBEECAB24B6455FC346329753F4B0
|
||||
- name: goreleaser
|
||||
uses: goreleaser/goreleaser-action@v6
|
||||
with:
|
||||
distribution: goreleaser-pro
|
||||
version: "~> v1"
|
||||
args: release
|
||||
env:
|
||||
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
|
||||
AWS_REGION: ${{ secrets.AWS_REGION }}
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
S3_REGION: ${{ secrets.AWS_REGION }}
|
||||
S3_BUCKET: ${{ secrets.AWS_BUCKET }}
|
||||
GORELEASER_FORCE_TOKEN: 'gitea'
|
||||
GPGSIGN_PASSPHRASE: ${{ secrets.GPGSIGN_PASSPHRASE }}
|
||||
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
|
||||
GITEA_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
|
@ -1,30 +0,0 @@
|
|||
name: check-and-test
|
||||
|
||||
on:
|
||||
- pull_request
|
||||
|
||||
jobs:
|
||||
check-and-test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: 'go.mod'
|
||||
- name: lint and build
|
||||
run: |
|
||||
make clean
|
||||
make vet
|
||||
make lint
|
||||
make fmt-check
|
||||
make misspell-check
|
||||
make docs-check
|
||||
make build
|
||||
env:
|
||||
GOPROXY: https://goproxy.io,direct
|
||||
- name: test and coverage
|
||||
run: |
|
||||
make test
|
||||
make unit-test-coverage
|
||||
env:
|
||||
GOPROXY: https://goproxy.io,direct
|
|
@ -1,6 +1,5 @@
|
|||
tea
|
||||
/gitea-vet
|
||||
/gitea-vet.exe
|
||||
|
||||
.idea/
|
||||
.history/
|
||||
|
@ -8,7 +7,3 @@ dist/
|
|||
|
||||
.vscode/
|
||||
vendor/
|
||||
|
||||
coverage.out
|
||||
|
||||
dist/
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "usage: $0 <path>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
SUM=$(shasum -a 256 "$1" | cut -d' ' -f1)
|
||||
BASENAME=$(basename "$1")
|
||||
echo -n "${SUM} ${BASENAME}" > "$1".sha256
|
124
.goreleaser.yaml
124
.goreleaser.yaml
|
@ -1,124 +0,0 @@
|
|||
before:
|
||||
hooks:
|
||||
- go mod tidy
|
||||
|
||||
builds:
|
||||
- env:
|
||||
- CGO_ENABLED=0
|
||||
goos:
|
||||
- darwin
|
||||
- linux
|
||||
- windows
|
||||
- freebsd
|
||||
goarch:
|
||||
- amd64
|
||||
- arm
|
||||
- arm64
|
||||
goarm:
|
||||
- "5"
|
||||
- "6"
|
||||
- "7"
|
||||
ignore:
|
||||
- goos: darwin
|
||||
goarch: arm
|
||||
- goos: darwin
|
||||
goarch: ppc64le
|
||||
- goos: darwin
|
||||
goarch: s390x
|
||||
- goos: windows
|
||||
goarch: ppc64le
|
||||
- goos: windows
|
||||
goarch: s390x
|
||||
- goos: windows
|
||||
goarch: arm
|
||||
goarm: "5"
|
||||
- goos: windows
|
||||
goarch: arm
|
||||
goarm: "6"
|
||||
- goos: windows
|
||||
goarch: arm
|
||||
goarm: "7"
|
||||
- goos: windows
|
||||
goarch: arm64
|
||||
- goos: freebsd
|
||||
goarch: ppc64le
|
||||
- goos: freebsd
|
||||
goarch: s390x
|
||||
- goos: freebsd
|
||||
goarch: arm
|
||||
goarm: "5"
|
||||
- goos: freebsd
|
||||
goarch: arm
|
||||
goarm: "6"
|
||||
- goos: freebsd
|
||||
goarch: arm
|
||||
goarm: "7"
|
||||
- goos: freebsd
|
||||
goarch: arm64
|
||||
flags:
|
||||
- -trimpath
|
||||
ldflags:
|
||||
- -s -w -X main.Version={{ .Version }}
|
||||
binary: >-
|
||||
{{ .ProjectName }}-
|
||||
{{- .Version }}-
|
||||
{{- .Os }}-
|
||||
{{- if eq .Arch "amd64" }}amd64
|
||||
{{- else if eq .Arch "amd64_v1" }}amd64
|
||||
{{- else if eq .Arch "386" }}386
|
||||
{{- else }}{{ .Arch }}{{ end }}
|
||||
{{- if .Arm }}-{{ .Arm }}{{ end }}
|
||||
no_unique_dist_dir: true
|
||||
hooks:
|
||||
post:
|
||||
- cmd: xz -k -9 {{ .Path }}
|
||||
dir: ./dist/
|
||||
- cmd: sh .goreleaser.checksum.sh {{ .Path }}
|
||||
- cmd: sh .goreleaser.checksum.sh {{ .Path }}.xz
|
||||
|
||||
blobs:
|
||||
-
|
||||
provider: s3
|
||||
bucket: "{{ .Env.S3_BUCKET }}"
|
||||
region: "{{ .Env.S3_REGION }}"
|
||||
folder: "tea/{{.Version}}"
|
||||
extra_files:
|
||||
- glob: ./**.xz
|
||||
- glob: ./**.sha256
|
||||
|
||||
archives:
|
||||
- format: binary
|
||||
name_template: "{{ .Binary }}"
|
||||
allow_different_binary_count: true
|
||||
|
||||
checksum:
|
||||
name_template: 'checksums.txt'
|
||||
extra_files:
|
||||
- glob: ./**.xz
|
||||
|
||||
force_token: gitea
|
||||
|
||||
signs:
|
||||
-
|
||||
signature: "${artifact}.sig"
|
||||
artifacts: checksum
|
||||
stdin: '{{ .Env.GPGSIGN_PASSPHRASE }}'
|
||||
args: ["--batch", "-u", "{{ .Env.GPG_FINGERPRINT }}", "--output", "${signature}", "--detach-sign", "${artifact}"]
|
||||
|
||||
snapshot:
|
||||
name_template: "{{ .Branch }}-devel"
|
||||
|
||||
nightly:
|
||||
name_template: "{{ .Branch }}"
|
||||
|
||||
gitea_urls:
|
||||
api: https://gitea.com/api/v1
|
||||
download: https://gitea.com
|
||||
|
||||
release:
|
||||
extra_files:
|
||||
- glob: ./**.xz
|
||||
- glob: ./**.xz.sha256
|
||||
|
||||
# yaml-language-server: $schema=https://goreleaser.com/static/schema-pro.json
|
||||
# vim: set ts=2 sw=2 tw=0 fo=cnqoj
|
|
@ -7,6 +7,7 @@
|
|||
- [Bug reports](#bug-reports)
|
||||
- [Discuss your design](#discuss-your-design)
|
||||
- [Testing redux](#testing-redux)
|
||||
- [Vendoring](#vendoring)
|
||||
- [Code review](#code-review)
|
||||
- [Styleguide](#styleguide)
|
||||
- [Sign-off your work](#sign-off-your-work)
|
||||
|
@ -59,6 +60,20 @@ high-level discussions.
|
|||
Before sending code out for review, run all the test by executing: `make test`
|
||||
Since TEA is an cli tool it should be obvious to test your feature locally first.
|
||||
|
||||
## Vendoring
|
||||
|
||||
We keep a cached copy of dependencies within the `vendor/` directory,
|
||||
managing updates via [dep](https://github.com/golang/dep).
|
||||
|
||||
Pull requests should only include `vendor/` updates if they are part of
|
||||
the same change, be it a bugfix or a feature addition.
|
||||
|
||||
The `vendor/` update needs to be justified as part of the PR description,
|
||||
and must be verified by the reviewers and/or merger to always reference
|
||||
an existing upstream commit.
|
||||
|
||||
You can find more information on how to get started with it on the [dep project website](https://golang.github.io/dep/docs/introduction.html).
|
||||
|
||||
## Code review
|
||||
|
||||
Changes to TEA must be reviewed before they are accepted—no matter who
|
||||
|
@ -160,7 +175,7 @@ maintainers](MAINTAINERS). Every PR **MUST** be reviewed by at least
|
|||
two maintainers (or owners) before it can get merged. A maintainer
|
||||
should be a contributor of Gitea (or Gogs) and contributed at least
|
||||
4 accepted PRs. A contributor should apply as a maintainer in the
|
||||
[Discord](https://discord.gg/Gitea) #develop channel. The owners
|
||||
[Discord](https://discord.gg/NsatcWJ) #develop channel. The owners
|
||||
or the team maintainers may invite the contributor. A maintainer
|
||||
should spend some time on code reviews. If a maintainer has no
|
||||
time to do that, they should apply to leave the maintainers team
|
||||
|
@ -193,7 +208,7 @@ https://help.github.com/articles/securing-your-account-with-two-factor-authentic
|
|||
|
||||
After the election, the new owners should proactively agree
|
||||
with our [CONTRIBUTING](CONTRIBUTING.md) requirements in the
|
||||
[Discord](https://discord.gg/Gitea) #general channel. Below are the
|
||||
[Discord](https://discord.gg/NsatcWJ) #general channel. Below are the
|
||||
words to speak:
|
||||
|
||||
```
|
||||
|
@ -221,8 +236,8 @@ Code that you contribute should use the standard copyright header:
|
|||
|
||||
```
|
||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
```
|
||||
|
||||
Files in the repository contain copyright from the year they are added
|
||||
|
|
29
Dockerfile
29
Dockerfile
|
@ -1,10 +1,25 @@
|
|||
FROM cgr.dev/chainguard/go:latest AS build
|
||||
COPY . /build/
|
||||
WORKDIR /build
|
||||
RUN make build
|
||||
ARG GOVERSION="1.16.2"
|
||||
|
||||
FROM cgr.dev/chainguard/static:latest
|
||||
COPY --from=build /build/tea /tea
|
||||
VOLUME [ "/app" ]
|
||||
FROM golang:${GOVERSION}-alpine AS buildenv
|
||||
|
||||
ARG GOOS="linux"
|
||||
|
||||
COPY . $GOPATH/src/
|
||||
WORKDIR $GOPATH/src
|
||||
|
||||
RUN apk add --quiet --no-cache \
|
||||
build-base \
|
||||
make \
|
||||
git && \
|
||||
make clean build STATIC=true
|
||||
|
||||
FROM scratch
|
||||
ARG VERSION="0.7.0"
|
||||
LABEL org.opencontainers.image.title="tea - CLI for Gitea - git with a cup of tea"
|
||||
LABEL org.opencontainers.image.description="A command line tool to interact with Gitea servers"
|
||||
LABEL org.opencontainers.image.version="${VERSION}"
|
||||
LABEL org.opencontainers.image.authors="Tamás Gérczei <tamas@gerczei.eu>"
|
||||
LABEL org.opencontainers.image.vendor="The Gitea Authors"
|
||||
COPY --from=buildenv /go/src/tea /
|
||||
ENV HOME="/app"
|
||||
ENTRYPOINT ["/tea"]
|
||||
|
|
1
LICENSE
1
LICENSE
|
@ -1,4 +1,5 @@
|
|||
Copyright (c) 2016 The Gitea Authors
|
||||
Copyright (c) 2015 The Gogs Authors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
87
Makefile
87
Makefile
|
@ -1,10 +1,13 @@
|
|||
DIST := dist
|
||||
export GO111MODULE=on
|
||||
export CGO_ENABLED=0
|
||||
|
||||
GO ?= go
|
||||
SHASUM ?= shasum -a 256
|
||||
|
||||
export PATH := $($(GO) env GOPATH)/bin:$(PATH)
|
||||
|
||||
GOFILES := $(shell find . -name "*.go" -type f ! -path "*/bindata.go")
|
||||
GOFILES := $(shell find . -name "*.go" -type f ! -path "./vendor/*" ! -path "*/bindata.go")
|
||||
GOFMT ?= gofmt -s
|
||||
|
||||
ifneq ($(DRONE_TAG),)
|
||||
|
@ -14,7 +17,7 @@ else
|
|||
ifneq ($(DRONE_BRANCH),)
|
||||
VERSION ?= $(subst release/v,,$(DRONE_BRANCH))
|
||||
else
|
||||
VERSION ?= main
|
||||
VERSION ?= master
|
||||
endif
|
||||
TEA_VERSION ?= $(shell git describe --tags --always | sed 's/-/+/' | sed 's/^v//')
|
||||
endif
|
||||
|
@ -25,18 +28,19 @@ SDK ?= $(shell $(GO) list -f '{{.Version}}' -m code.gitea.io/sdk/gitea)
|
|||
LDFLAGS := -X "main.Version=$(TEA_VERSION)" -X "main.Tags=$(TAGS)" -X "main.SDK=$(SDK)" -s -w
|
||||
|
||||
# override to allow passing additional goflags via make CLI
|
||||
override GOFLAGS := $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)'
|
||||
override GOFLAGS := $(GOFLAGS) -mod=vendor -tags '$(TAGS)' -ldflags '$(LDFLAGS)'
|
||||
|
||||
PACKAGES ?= $(shell $(GO) list ./...)
|
||||
PACKAGES ?= $(shell $(GO) list ./... | grep -v /vendor/)
|
||||
SOURCES ?= $(shell find . -name "*.go" -type f)
|
||||
|
||||
# OS specific vars.
|
||||
ifeq ($(OS), Windows_NT)
|
||||
EXECUTABLE := tea.exe
|
||||
VET_TOOL := gitea-vet.exe
|
||||
else
|
||||
EXECUTABLE := tea
|
||||
VET_TOOL := gitea-vet
|
||||
ifneq ($(shell uname -s), OpenBSD)
|
||||
override BUILDMODE := -buildmode=pie
|
||||
endif
|
||||
endif
|
||||
|
||||
.PHONY: all
|
||||
|
@ -44,7 +48,7 @@ all: build
|
|||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
$(GO) clean -i ./...
|
||||
$(GO) clean -mod=vendor -i ./...
|
||||
rm -rf $(EXECUTABLE) $(DIST)
|
||||
|
||||
.PHONY: fmt
|
||||
|
@ -54,22 +58,22 @@ fmt:
|
|||
.PHONY: vet
|
||||
vet:
|
||||
# Default vet
|
||||
$(GO) vet $(PACKAGES)
|
||||
$(GO) vet -mod=vendor $(PACKAGES)
|
||||
# Custom vet
|
||||
$(GO) build code.gitea.io/gitea-vet
|
||||
$(GO) vet -vettool=$(VET_TOOL) $(PACKAGES)
|
||||
$(GO) build -mod=vendor code.gitea.io/gitea-vet
|
||||
$(GO) vet -vettool=gitea-vet $(PACKAGES)
|
||||
|
||||
.PHONY: lint
|
||||
lint: install-lint-tools
|
||||
$(GO) run github.com/mgechev/revive@v1.3.2 -config .revive.toml ./... || exit 1
|
||||
revive -config .revive.toml -exclude=./vendor/... ./... || exit 1
|
||||
|
||||
.PHONY: misspell-check
|
||||
misspell-check: install-lint-tools
|
||||
$(GO) run github.com/client9/misspell/cmd/misspell@latest -error -i unknwon,destory $(GOFILES)
|
||||
misspell -error -i unknwon,destory $(GOFILES)
|
||||
|
||||
.PHONY: misspell
|
||||
misspell: install-lint-tools
|
||||
$(GO) run github.com/client9/misspell/cmd/misspell@latest -w -i unknwon $(GOFILES)
|
||||
misspell -w -i unknwon $(GOFILES)
|
||||
|
||||
.PHONY: fmt-check
|
||||
fmt-check:
|
||||
|
@ -81,38 +85,25 @@ fmt-check:
|
|||
exit 1; \
|
||||
fi;
|
||||
|
||||
.PHONY: docs
|
||||
docs:
|
||||
$(GO) run . docs --out docs/CLI.md
|
||||
|
||||
.PHONY: docs-check
|
||||
docs-check:
|
||||
@DIFF=$$($(GO) run . docs | diff docs/CLI.md -); \
|
||||
if [ -n "$$DIFF" ]; then \
|
||||
echo "Please run 'make docs' and commit the result:"; \
|
||||
echo "$$DIFF"; \
|
||||
exit 1; \
|
||||
fi;
|
||||
|
||||
.PHONY: test
|
||||
test:
|
||||
$(GO) test -tags='sqlite sqlite_unlock_notify' $(PACKAGES)
|
||||
$(GO) test -mod=vendor -tags='sqlite sqlite_unlock_notify' $(PACKAGES)
|
||||
|
||||
.PHONY: unit-test-coverage
|
||||
unit-test-coverage:
|
||||
$(GO) test -tags='sqlite sqlite_unlock_notify' -cover -coverprofile coverage.out $(PACKAGES) && echo "\n==>\033[32m Ok\033[m\n" || exit 1
|
||||
$(GO) test -mod=vendor -tags='sqlite sqlite_unlock_notify' -cover -coverprofile coverage.out $(PACKAGES) && echo "\n==>\033[32m Ok\033[m\n" || exit 1
|
||||
|
||||
.PHONY: tidy
|
||||
tidy:
|
||||
$(GO) mod tidy
|
||||
.PHONY: vendor
|
||||
vendor:
|
||||
$(GO) mod tidy && $(GO) mod vendor
|
||||
|
||||
.PHONY: check
|
||||
check: test
|
||||
|
||||
.PHONY: install
|
||||
install: $(SOURCES)
|
||||
@echo "installing to $(shell $(GO) env GOPATH)/bin/$(EXECUTABLE)"
|
||||
$(GO) install -v $(BUILDMODE) $(GOFLAGS)
|
||||
@echo "installing to $(GOPATH)/bin/$(EXECUTABLE)"
|
||||
$(GO) install -v $(BUILDMODE) $(GOFLAGS)
|
||||
|
||||
.PHONY: build
|
||||
build: $(EXECUTABLE)
|
||||
|
@ -124,9 +115,37 @@ $(EXECUTABLE): $(SOURCES)
|
|||
build-image:
|
||||
docker build --build-arg VERSION=$(TEA_VERSION) -t gitea/tea:$(TEA_VERSION_TAG) .
|
||||
|
||||
.PHONY: release
|
||||
release: release-dirs install-release-tools release-os release-compress release-check
|
||||
|
||||
.PHONY: release-dirs
|
||||
release-dirs:
|
||||
mkdir -p $(DIST)/binaries $(DIST)/release
|
||||
|
||||
.PHONY: release-os
|
||||
release-os:
|
||||
CGO_ENABLED=0 gox -verbose -cgo=false $(GOFLAGS) -osarch='!darwin/386 !darwin/arm' -os="windows linux darwin" -arch="386 amd64 arm arm64" -output="$(DIST)/release/tea-$(VERSION)-{{.OS}}-{{.Arch}}"
|
||||
|
||||
.PHONY: release-compress
|
||||
release-compress: install-release-tools
|
||||
cd $(DIST)/release/; for file in `find . -type f -name "*"`; do echo "compressing $${file}" && gxz -k -9 $${file}; done;
|
||||
|
||||
.PHONY: release-check
|
||||
release-check: install-release-tools
|
||||
cd $(DIST)/release/; for file in `find . -type f -name "*"`; do echo "checksumming $${file}" && $(SHASUM) `echo $${file} | sed 's/^..//'` > $${file}.sha256; done;
|
||||
|
||||
### tools
|
||||
install-release-tools:
|
||||
@hash gox > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
||||
$(GO) install github.com/mitchellh/gox@latest; \
|
||||
fi
|
||||
@hash gxz > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
||||
$(GO) install github.com/ulikunitz/xz/cmd/gxz@latest; \
|
||||
fi
|
||||
|
||||
install-lint-tools:
|
||||
@hash revive > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
||||
$(GO) install github.com/mgechev/revive@v1.3.2; \
|
||||
$(GO) install github.com/mgechev/revive@latest; \
|
||||
fi
|
||||
@hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
||||
$(GO) install github.com/client9/misspell/cmd/misspell@latest; \
|
||||
|
|
49
README.md
49
README.md
|
@ -1,12 +1,8 @@
|
|||
# <img alt='tea logo' src='https://gitea.com/repo-avatars/550-80a3a8c2ab0e2c2d69f296b7f8582485' height="40"/> *T E A*
|
||||
# <img alt='' src='https://gitea.com/repo-avatars/550-80a3a8c2ab0e2c2d69f296b7f8582485' height="40"/> *T E A*
|
||||
|
||||
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
|
||||
[![Release](https://raster.shields.io/badge/dynamic/json.svg?label=release&url=https://gitea.com/api/v1/repos/gitea/tea/releases&query=$[0].tag_name)](https://gitea.com/gitea/tea/releases)
|
||||
[![Join the chat at https://img.shields.io/discord/322538954119184384.svg](https://img.shields.io/discord/322538954119184384.svg)](https://discord.gg/Gitea)
|
||||
[![Go Report Card](https://goreportcard.com/badge/code.gitea.io/tea)](https://goreportcard.com/report/code.gitea.io/tea) [![GoDoc](https://pkg.go.dev/badge/code.gitea.io/tea?status.svg)](https://godoc.org/code.gitea.io/tea)
|
||||
![Tea Release Status](https://gitea.com/gitea/tea/actions/workflows/release-nightly.yml/badge.svg)
|
||||
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) [![Release](https://raster.shields.io/badge/dynamic/json.svg?label=release&url=https://gitea.com/api/v1/repos/gitea/tea/releases&query=$[0].tag_name)](https://gitea.com/gitea/tea/releases) [![Build Status](https://drone.gitea.com/api/badges/gitea/tea/status.svg)](https://drone.gitea.com/gitea/tea) [![Join the chat at https://img.shields.io/discord/322538954119184384.svg](https://img.shields.io/discord/322538954119184384.svg)](https://discord.gg/Gitea) [![Go Report Card](https://goreportcard.com/badge/code.gitea.io/tea)](https://goreportcard.com/report/code.gitea.io/tea) [![GoDoc](https://godoc.org/code.gitea.io/tea?status.svg)](https://godoc.org/code.gitea.io/tea)
|
||||
|
||||
## The official CLI for Gitea
|
||||
### The official CLI for Gitea
|
||||
|
||||
![demo gif](./demo.gif)
|
||||
|
||||
|
@ -29,16 +25,15 @@
|
|||
COMMANDS
|
||||
help, h Shows a list of commands or help for one command
|
||||
ENTITIES:
|
||||
issues, issue, i List, create and update issues
|
||||
pulls, pull, pr Manage and checkout pull requests
|
||||
labels, label Manage issue labels
|
||||
milestones, milestone, ms List and create milestones
|
||||
releases, release, r Manage releases
|
||||
release assets, release asset, r a Manage release attachments
|
||||
times, time, t Operate on tracked times of a repository's issues & pulls
|
||||
organizations, organization, org List, create, delete organizations
|
||||
repos, repo Show repository details
|
||||
comment, c Add a comment to an issue / pr
|
||||
issues, issue, i List, create and update issues
|
||||
pulls, pull, pr Manage and checkout pull requests
|
||||
labels, label Manage issue labels
|
||||
milestones, milestone, ms List and create milestones
|
||||
releases, release, r Manage releases
|
||||
times, time, t Operate on tracked times of a repository's issues & pulls
|
||||
organizations, organization, org List, create, delete organizations
|
||||
repos, repo Show repository details
|
||||
comment, c Add a comment to an issue / pr
|
||||
HELPERS:
|
||||
open, o Open something of the repository in web browser
|
||||
notifications, notification, n Show notifications
|
||||
|
@ -74,7 +69,7 @@
|
|||
ABOUT
|
||||
Written & maintained by The Gitea Authors.
|
||||
If you find a bug or want to contribute, we'll welcome you at https://gitea.com/gitea/tea.
|
||||
More info about Gitea itself on https://about.gitea.com.
|
||||
More info about Gitea itself on https://gitea.io.
|
||||
```
|
||||
|
||||
- [Compare features with other git forge CLIs](./FEATURE-COMPARISON.md)
|
||||
|
@ -85,22 +80,20 @@
|
|||
There are different ways to get `tea`:
|
||||
|
||||
1. Install via your system package manager:
|
||||
- macOS via `brew` (official):
|
||||
- macOS via `brew` (gitea-maintained):
|
||||
```sh
|
||||
brew tap gitea/tap https://gitea.com/gitea/homebrew-gitea
|
||||
brew install tea
|
||||
```
|
||||
- arch linux ([gitea-tea-git](https://aur.archlinux.org/packages/gitea-tea-git), thirdparty)
|
||||
- alpine linux ([tea](https://pkgs.alpinelinux.org/packages?name=tea&branch=edge), thirdparty)
|
||||
- Windows via `MSYS2` ([tea](https://packages.msys2.org/base/mingw-w64-tea), thirdparty)
|
||||
|
||||
2. Use the prebuilt binaries from [dl.gitea.com](https://dl.gitea.com/tea/)
|
||||
2. Use the prebuilt binaries from [dl.gitea.io](https://dl.gitea.io/tea/)
|
||||
|
||||
3. Install from source: [see *Compilation*](#compilation)
|
||||
|
||||
4. Docker (thirdparty): [tgerczei/tea](https://hub.docker.com/r/tgerczei/tea)
|
||||
|
||||
5. asdf (thirdparty): [mvaldes14/asdf-tea](https://github.com/mvaldes14/asdf-tea)
|
||||
|
||||
## Compilation
|
||||
|
||||
Make sure you have a current go version installed (1.13 or newer).
|
||||
|
@ -112,15 +105,10 @@ Make sure you have a current go version installed (1.13 or newer).
|
|||
make
|
||||
```
|
||||
Note that GNU Make (gmake on OpenBSD) is required.
|
||||
If you want to install the compiled program you have to execute the following command:
|
||||
```sh
|
||||
make install
|
||||
```
|
||||
This installs the binary into the "bin" folder inside of your GOPATH folder (`go env GOPATH`). It is possible that this folder isn't in your PATH Environment Variable.
|
||||
|
||||
- For a quick installation without `git` & `make`, set $version and exec:
|
||||
- For a quick installation without `git` & `make`:
|
||||
```sh
|
||||
go install code.gitea.io/tea@${version}
|
||||
go install code.gitea.io/tea@latest
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
@ -129,6 +117,7 @@ Fork -> Patch -> Push -> Pull Request
|
|||
|
||||
- `make test` run testsuite
|
||||
- `make vet` run checks (check the order of imports; preventing failure on CI pipeline beforehand)
|
||||
- `make vendor` when adding new dependencies
|
||||
- ... (for other development tasks, check the `Makefile`)
|
||||
|
||||
**Please** read the [CONTRIBUTING](CONTRIBUTING.md) documentation, it will tell you about internal structures and concepts.
|
||||
|
|
4
build.go
4
build.go
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
//go:build vendor
|
||||
// +build vendor
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2021 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package cmd
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2021 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package users
|
||||
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
// Copyright 2024 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"code.gitea.io/tea/cmd/attachments"
|
||||
"code.gitea.io/tea/cmd/flags"
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// CmdReleaseAttachments represents a release attachment (file attachment)
|
||||
var CmdReleaseAttachments = cli.Command{
|
||||
Name: "assets",
|
||||
Aliases: []string{"asset", "a"},
|
||||
Category: catEntities,
|
||||
Usage: "Manage release assets",
|
||||
Description: "Manage release assets",
|
||||
ArgsUsage: " ", // command does not accept arguments
|
||||
Action: attachments.RunReleaseAttachmentList,
|
||||
Subcommands: []*cli.Command{
|
||||
&attachments.CmdReleaseAttachmentList,
|
||||
&attachments.CmdReleaseAttachmentCreate,
|
||||
&attachments.CmdReleaseAttachmentDelete,
|
||||
},
|
||||
Flags: flags.AllDefaultFlags,
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
// Copyright 2024 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package attachments
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"code.gitea.io/tea/cmd/flags"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// CmdReleaseAttachmentCreate represents a sub command of Release Attachments to create a release attachment
|
||||
var CmdReleaseAttachmentCreate = cli.Command{
|
||||
Name: "create",
|
||||
Aliases: []string{"c"},
|
||||
Usage: "Create one or more release attachments",
|
||||
Description: `Create one or more release attachments`,
|
||||
ArgsUsage: "<release-tag> <asset> [<asset>...]",
|
||||
Action: runReleaseAttachmentCreate,
|
||||
Flags: flags.AllDefaultFlags,
|
||||
}
|
||||
|
||||
func runReleaseAttachmentCreate(cmd *cli.Context) error {
|
||||
ctx := context.InitCommand(cmd)
|
||||
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
|
||||
client := ctx.Login.Client()
|
||||
|
||||
if ctx.Args().Len() < 2 {
|
||||
return fmt.Errorf("No release tag or assets specified.\nUsage:\t%s", ctx.Command.UsageText)
|
||||
}
|
||||
|
||||
tag := ctx.Args().First()
|
||||
if len(tag) == 0 {
|
||||
return fmt.Errorf("Release tag needed to create attachment")
|
||||
}
|
||||
|
||||
release, err := getReleaseByTag(ctx.Owner, ctx.Repo, tag, client)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, asset := range ctx.Args().Slice()[1:] {
|
||||
var file *os.File
|
||||
if file, err = os.Open(asset); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
filePath := filepath.Base(asset)
|
||||
|
||||
if _, _, err = ctx.Login.Client().CreateReleaseAttachment(ctx.Owner, ctx.Repo, release.ID, file, filePath); err != nil {
|
||||
file.Close()
|
||||
return err
|
||||
}
|
||||
|
||||
file.Close()
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
|
@ -1,100 +0,0 @@
|
|||
// Copyright 2024 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package attachments
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"code.gitea.io/tea/cmd/flags"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// CmdReleaseAttachmentDelete represents a sub command of Release Attachments to delete a release attachment
|
||||
var CmdReleaseAttachmentDelete = cli.Command{
|
||||
Name: "delete",
|
||||
Aliases: []string{"rm"},
|
||||
Usage: "Delete one or more release attachments",
|
||||
Description: `Delete one or more release attachments`,
|
||||
ArgsUsage: "<release tag> <attachment name> [<attachment name>...]",
|
||||
Action: runReleaseAttachmentDelete,
|
||||
Flags: append([]cli.Flag{
|
||||
&cli.BoolFlag{
|
||||
Name: "confirm",
|
||||
Aliases: []string{"y"},
|
||||
Usage: "Confirm deletion (required)",
|
||||
},
|
||||
}, flags.AllDefaultFlags...),
|
||||
}
|
||||
|
||||
func runReleaseAttachmentDelete(cmd *cli.Context) error {
|
||||
ctx := context.InitCommand(cmd)
|
||||
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
|
||||
client := ctx.Login.Client()
|
||||
|
||||
if ctx.Args().Len() < 2 {
|
||||
return fmt.Errorf("No release tag or attachment names specified.\nUsage:\t%s", ctx.Command.UsageText)
|
||||
}
|
||||
|
||||
tag := ctx.Args().First()
|
||||
if len(tag) == 0 {
|
||||
return fmt.Errorf("Release tag needed to delete attachment")
|
||||
}
|
||||
|
||||
if !ctx.Bool("confirm") {
|
||||
fmt.Println("Are you sure? Please confirm with -y or --confirm.")
|
||||
return nil
|
||||
}
|
||||
|
||||
release, err := getReleaseByTag(ctx.Owner, ctx.Repo, tag, client)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
existing, _, err := client.ListReleaseAttachments(ctx.Owner, ctx.Repo, release.ID, gitea.ListReleaseAttachmentsOptions{
|
||||
ListOptions: gitea.ListOptions{Page: -1},
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, name := range ctx.Args().Slice()[1:] {
|
||||
var attachment *gitea.Attachment
|
||||
for _, a := range existing {
|
||||
if a.Name == name {
|
||||
attachment = a
|
||||
}
|
||||
}
|
||||
if attachment == nil {
|
||||
return fmt.Errorf("Release does not have attachment named '%s'", name)
|
||||
}
|
||||
|
||||
_, err = client.DeleteReleaseAttachment(ctx.Owner, ctx.Repo, release.ID, attachment.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func getReleaseAttachmentByName(owner, repo string, release int64, name string, client *gitea.Client) (*gitea.Attachment, error) {
|
||||
al, _, err := client.ListReleaseAttachments(owner, repo, release, gitea.ListReleaseAttachmentsOptions{
|
||||
ListOptions: gitea.ListOptions{Page: -1},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(al) == 0 {
|
||||
return nil, fmt.Errorf("Release does not have any attachments")
|
||||
}
|
||||
for _, a := range al {
|
||||
if a.Name == name {
|
||||
return a, nil
|
||||
}
|
||||
}
|
||||
return nil, fmt.Errorf("Attachment does not exist")
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
// Copyright 2024 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package attachments
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"code.gitea.io/tea/cmd/flags"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
"code.gitea.io/tea/modules/print"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// CmdReleaseAttachmentList represents a sub command of release attachment to list release attachments
|
||||
var CmdReleaseAttachmentList = cli.Command{
|
||||
Name: "list",
|
||||
Aliases: []string{"ls"},
|
||||
Usage: "List Release Attachments",
|
||||
Description: "List Release Attachments",
|
||||
ArgsUsage: "<release-tag>", // command does not accept arguments
|
||||
Action: RunReleaseAttachmentList,
|
||||
Flags: append([]cli.Flag{
|
||||
&flags.PaginationPageFlag,
|
||||
&flags.PaginationLimitFlag,
|
||||
}, flags.AllDefaultFlags...),
|
||||
}
|
||||
|
||||
// RunReleaseAttachmentList list release attachments
|
||||
func RunReleaseAttachmentList(cmd *cli.Context) error {
|
||||
ctx := context.InitCommand(cmd)
|
||||
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
|
||||
client := ctx.Login.Client()
|
||||
|
||||
tag := ctx.Args().First()
|
||||
if len(tag) == 0 {
|
||||
return fmt.Errorf("Release tag needed to list attachments")
|
||||
}
|
||||
|
||||
release, err := getReleaseByTag(ctx.Owner, ctx.Repo, tag, client)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
attachments, _, err := ctx.Login.Client().ListReleaseAttachments(ctx.Owner, ctx.Repo, release.ID, gitea.ListReleaseAttachmentsOptions{
|
||||
ListOptions: ctx.GetListOptions(),
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
print.ReleaseAttachmentsList(attachments, ctx.Output)
|
||||
return nil
|
||||
}
|
||||
|
||||
func getReleaseByTag(owner, repo, tag string, client *gitea.Client) (*gitea.Release, error) {
|
||||
rl, _, err := client.ListReleases(owner, repo, gitea.ListReleasesOptions{
|
||||
ListOptions: gitea.ListOptions{Page: -1},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(rl) == 0 {
|
||||
return nil, fmt.Errorf("Repo does not have any release")
|
||||
}
|
||||
for _, r := range rl {
|
||||
if r.TagName == tag {
|
||||
return r, nil
|
||||
}
|
||||
}
|
||||
return nil, fmt.Errorf("Release tag does not exist")
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package cmd
|
||||
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
// Copyright 2024 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"code.gitea.io/tea/cmd/branches"
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// CmdBranches represents to login a gitea server.
|
||||
var CmdBranches = cli.Command{
|
||||
Name: "branches",
|
||||
Aliases: []string{"branch", "b"},
|
||||
Category: catEntities,
|
||||
Usage: "Consult branches",
|
||||
Description: `Lists branches when called without argument. If a branch is provided, will show it in detail.`,
|
||||
ArgsUsage: "[<branch name>]",
|
||||
Action: runBranches,
|
||||
Subcommands: []*cli.Command{
|
||||
&branches.CmdBranchesList,
|
||||
&branches.CmdBranchesProtect,
|
||||
&branches.CmdBranchesUnprotect,
|
||||
},
|
||||
Flags: append([]cli.Flag{
|
||||
&cli.BoolFlag{
|
||||
Name: "comments",
|
||||
Usage: "Whether to display comments (will prompt if not provided & run interactively)",
|
||||
},
|
||||
}, branches.CmdBranchesList.Flags...),
|
||||
}
|
||||
|
||||
func runBranches(ctx *cli.Context) error {
|
||||
return branches.RunBranchesList(ctx)
|
||||
}
|
|
@ -1,73 +0,0 @@
|
|||
// Copyright 2024 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package branches
|
||||
|
||||
import (
|
||||
"code.gitea.io/tea/cmd/flags"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
"code.gitea.io/tea/modules/print"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
var branchFieldsFlag = flags.FieldsFlag(print.BranchFields, []string{
|
||||
"name", "protected", "user-can-merge", "user-can-push",
|
||||
})
|
||||
|
||||
// CmdBranchesListFlags Flags for command list
|
||||
var CmdBranchesListFlags = append([]cli.Flag{
|
||||
branchFieldsFlag,
|
||||
&flags.PaginationPageFlag,
|
||||
&flags.PaginationLimitFlag,
|
||||
}, flags.AllDefaultFlags...)
|
||||
|
||||
// CmdBranchesList represents a sub command of branches to list branches
|
||||
var CmdBranchesList = cli.Command{
|
||||
Name: "list",
|
||||
Aliases: []string{"ls"},
|
||||
Usage: "List branches of the repository",
|
||||
Description: `List branches of the repository`,
|
||||
ArgsUsage: " ", // command does not accept arguments
|
||||
Action: RunBranchesList,
|
||||
Flags: CmdBranchesListFlags,
|
||||
}
|
||||
|
||||
// RunBranchesList list branches
|
||||
func RunBranchesList(cmd *cli.Context) error {
|
||||
ctx := context.InitCommand(cmd)
|
||||
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
|
||||
|
||||
owner := ctx.Owner
|
||||
if ctx.IsSet("owner") {
|
||||
owner = ctx.String("owner")
|
||||
}
|
||||
|
||||
var branches []*gitea.Branch
|
||||
var protections []*gitea.BranchProtection
|
||||
var err error
|
||||
branches, _, err = ctx.Login.Client().ListRepoBranches(owner, ctx.Repo, gitea.ListRepoBranchesOptions{
|
||||
ListOptions: ctx.GetListOptions(),
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
protections, _, err = ctx.Login.Client().ListBranchProtections(owner, ctx.Repo, gitea.ListBranchProtectionsOptions{
|
||||
ListOptions: ctx.GetListOptions(),
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fields, err := branchFieldsFlag.GetValues(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
print.BranchesList(branches, protections, ctx.Output, fields)
|
||||
return nil
|
||||
}
|
|
@ -1,101 +0,0 @@
|
|||
// Copyright 2024 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package branches
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"code.gitea.io/tea/cmd/flags"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// CmdBranchesProtectFlags Flags for command protect/unprotect
|
||||
var CmdBranchesProtectFlags = append([]cli.Flag{
|
||||
branchFieldsFlag,
|
||||
&flags.PaginationPageFlag,
|
||||
&flags.PaginationLimitFlag,
|
||||
}, flags.AllDefaultFlags...)
|
||||
|
||||
// CmdBranchesProtect represents a sub command of branches to protect a branch
|
||||
var CmdBranchesProtect = cli.Command{
|
||||
Name: "protect",
|
||||
Aliases: []string{"P"},
|
||||
Usage: "Protect branches",
|
||||
Description: `Block actions push/merge on specified branches`,
|
||||
ArgsUsage: "<branch>",
|
||||
Action: RunBranchesProtect,
|
||||
Flags: CmdBranchesProtectFlags,
|
||||
}
|
||||
|
||||
// CmdBranchesUnprotect represents a sub command of branches to protect a branch
|
||||
var CmdBranchesUnprotect = cli.Command{
|
||||
Name: "unprotect",
|
||||
Aliases: []string{"U"},
|
||||
Usage: "Unprotect branches",
|
||||
Description: `Suppress existing protections on specified branches`,
|
||||
ArgsUsage: "<branch>",
|
||||
Action: RunBranchesProtect,
|
||||
Flags: CmdBranchesProtectFlags,
|
||||
}
|
||||
|
||||
// RunBranchesProtect function to protect/unprotect a list of branches
|
||||
func RunBranchesProtect(cmd *cli.Context) error {
|
||||
ctx := context.InitCommand(cmd)
|
||||
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
|
||||
|
||||
if !cmd.Args().Present() {
|
||||
return fmt.Errorf("must specify at least one branch")
|
||||
}
|
||||
|
||||
owner := ctx.Owner
|
||||
if ctx.IsSet("owner") {
|
||||
owner = ctx.String("owner")
|
||||
}
|
||||
|
||||
for _, branch := range ctx.Args().Slice() {
|
||||
|
||||
var err error
|
||||
command := ctx.Command.Name
|
||||
if command == "protect" {
|
||||
_, _, err = ctx.Login.Client().CreateBranchProtection(owner, ctx.Repo, gitea.CreateBranchProtectionOption{
|
||||
BranchName: branch,
|
||||
RuleName: "",
|
||||
EnablePush: false,
|
||||
EnablePushWhitelist: false,
|
||||
PushWhitelistUsernames: []string{},
|
||||
PushWhitelistTeams: []string{},
|
||||
PushWhitelistDeployKeys: false,
|
||||
EnableMergeWhitelist: false,
|
||||
MergeWhitelistUsernames: []string{},
|
||||
MergeWhitelistTeams: []string{},
|
||||
EnableStatusCheck: false,
|
||||
StatusCheckContexts: []string{},
|
||||
RequiredApprovals: 1,
|
||||
EnableApprovalsWhitelist: false,
|
||||
ApprovalsWhitelistUsernames: []string{},
|
||||
ApprovalsWhitelistTeams: []string{},
|
||||
BlockOnRejectedReviews: false,
|
||||
BlockOnOfficialReviewRequests: false,
|
||||
BlockOnOutdatedBranch: false,
|
||||
DismissStaleApprovals: false,
|
||||
RequireSignedCommits: false,
|
||||
ProtectedFilePatterns: "",
|
||||
UnprotectedFilePatterns: "",
|
||||
})
|
||||
} else if command == "unprotect" {
|
||||
_, err = ctx.Login.Client().DeleteBranchProtection(owner, ctx.Repo, branch)
|
||||
} else {
|
||||
return fmt.Errorf("command %s is not supported", command)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package cmd
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2021 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package cmd
|
||||
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/tea/cmd/flags"
|
||||
|
@ -49,7 +50,7 @@ func runAddComment(cmd *cli.Context) error {
|
|||
body := strings.Join(ctx.Args().Tail(), " ")
|
||||
if interact.IsStdinPiped() {
|
||||
// custom solution until https://github.com/AlecAivazis/survey/issues/328 is fixed
|
||||
if bodyStdin, err := io.ReadAll(ctx.App.Reader); err != nil {
|
||||
if bodyStdin, err := ioutil.ReadAll(ctx.App.Reader); err != nil {
|
||||
return err
|
||||
} else if len(bodyStdin) != 0 {
|
||||
body = strings.Join([]string{body, string(bodyStdin)}, "\n\n")
|
||||
|
|
55
cmd/docs.go
55
cmd/docs.go
|
@ -1,55 +0,0 @@
|
|||
// Copyright 2023 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// CmdDocs generates markdown for tea
|
||||
var CmdDocs = cli.Command{
|
||||
Name: "docs",
|
||||
Hidden: true,
|
||||
Description: "Generate CLI docs",
|
||||
Action: runDocs,
|
||||
Flags: []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "out",
|
||||
Usage: "Path to output docs to, otherwise prints to stdout",
|
||||
Aliases: []string{"o"},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
func runDocs(ctx *cli.Context) error {
|
||||
md, err := ctx.App.ToMarkdown()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
outPath := ctx.String("out")
|
||||
if outPath == "" {
|
||||
fmt.Print(md)
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := os.MkdirAll(filepath.Dir(outPath), os.ModePerm); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fi, err := os.Create(outPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer fi.Close()
|
||||
if _, err := fi.WriteString(md); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2021 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package flags
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package flags
|
||||
|
||||
|
@ -32,7 +33,7 @@ var RemoteFlag = cli.StringFlag{
|
|||
var OutputFlag = cli.StringFlag{
|
||||
Name: "output",
|
||||
Aliases: []string{"o"},
|
||||
Usage: "Output format. (simple, table, csv, tsv, yaml, json)",
|
||||
Usage: "Output format. (csv, simple, table, tsv, yaml)",
|
||||
}
|
||||
|
||||
// PaginationPageFlag provides flag for pagination options
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package flags
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
|
@ -70,10 +70,6 @@ var IssueListingFlags = append([]cli.Flag{
|
|||
Name: "mentions",
|
||||
Aliases: []string{"M"},
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "owner",
|
||||
Aliases: []string{"org"},
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "from",
|
||||
Aliases: []string{"F"},
|
||||
|
@ -88,8 +84,8 @@ var IssueListingFlags = append([]cli.Flag{
|
|||
&PaginationLimitFlag,
|
||||
}, AllDefaultFlags...)
|
||||
|
||||
// issuePRFlags defines shared flags between flags IssuePRCreateFlags and IssuePREditFlags
|
||||
var issuePRFlags = append([]cli.Flag{
|
||||
// IssuePREditFlags defines flags for properties of issues and PRs
|
||||
var IssuePREditFlags = append([]cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "title",
|
||||
Aliases: []string{"t"},
|
||||
|
@ -98,25 +94,6 @@ var issuePRFlags = append([]cli.Flag{
|
|||
Name: "description",
|
||||
Aliases: []string{"d"},
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "referenced-version",
|
||||
Aliases: []string{"v"},
|
||||
Usage: "commit-hash or tag name to assign",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "milestone",
|
||||
Aliases: []string{"m"},
|
||||
Usage: "Milestone to assign",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "deadline",
|
||||
Aliases: []string{"D"},
|
||||
Usage: "Deadline timestamp to assign",
|
||||
},
|
||||
}, LoginRepoFlags...)
|
||||
|
||||
// IssuePRCreateFlags defines flags for creation of issues and PRs
|
||||
var IssuePRCreateFlags = append([]cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "assignees",
|
||||
Aliases: []string{"a"},
|
||||
|
@ -127,10 +104,20 @@ var IssuePRCreateFlags = append([]cli.Flag{
|
|||
Aliases: []string{"L"},
|
||||
Usage: "Comma-separated list of labels to assign",
|
||||
},
|
||||
}, issuePRFlags...)
|
||||
&cli.StringFlag{
|
||||
Name: "deadline",
|
||||
Aliases: []string{"D"},
|
||||
Usage: "Deadline timestamp to assign",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "milestone",
|
||||
Aliases: []string{"m"},
|
||||
Usage: "Milestone to assign",
|
||||
},
|
||||
}, LoginRepoFlags...)
|
||||
|
||||
// GetIssuePRCreateFlags parses all IssuePREditFlags
|
||||
func GetIssuePRCreateFlags(ctx *context.TeaContext) (*gitea.CreateIssueOption, error) {
|
||||
// GetIssuePREditFlags parses all IssuePREditFlags
|
||||
func GetIssuePREditFlags(ctx *context.TeaContext) (*gitea.CreateIssueOption, error) {
|
||||
opts := gitea.CreateIssueOption{
|
||||
Title: ctx.String("title"),
|
||||
Body: ctx.String("description"),
|
||||
|
@ -172,67 +159,3 @@ func GetIssuePRCreateFlags(ctx *context.TeaContext) (*gitea.CreateIssueOption, e
|
|||
|
||||
return &opts, nil
|
||||
}
|
||||
|
||||
// IssuePREditFlags defines flags for editing properties of issues and PRs
|
||||
var IssuePREditFlags = append([]cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "add-assignees",
|
||||
Aliases: []string{"a"},
|
||||
Usage: "Comma-separated list of usernames to assign",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "add-labels",
|
||||
Aliases: []string{"L"},
|
||||
Usage: "Comma-separated list of labels to assign. Takes precedence over --remove-labels",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "remove-labels",
|
||||
Usage: "Comma-separated list of labels to remove",
|
||||
},
|
||||
}, issuePRFlags...)
|
||||
|
||||
// GetIssuePREditFlags parses all IssuePREditFlags
|
||||
func GetIssuePREditFlags(ctx *context.TeaContext) (*task.EditIssueOption, error) {
|
||||
opts := task.EditIssueOption{}
|
||||
if ctx.IsSet("title") {
|
||||
val := ctx.String("title")
|
||||
opts.Title = &val
|
||||
}
|
||||
if ctx.IsSet("description") {
|
||||
val := ctx.String("description")
|
||||
opts.Body = &val
|
||||
}
|
||||
if ctx.IsSet("referenced-version") {
|
||||
val := ctx.String("referenced-version")
|
||||
opts.Ref = &val
|
||||
}
|
||||
if ctx.IsSet("milestone") {
|
||||
val := ctx.String("milestone")
|
||||
opts.Milestone = &val
|
||||
}
|
||||
if ctx.IsSet("deadline") {
|
||||
date := ctx.String("deadline")
|
||||
if date == "" {
|
||||
opts.Deadline = &time.Time{}
|
||||
} else {
|
||||
t, err := dateparse.ParseAny(date)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
opts.Deadline = &t
|
||||
}
|
||||
}
|
||||
if ctx.IsSet("add-assignees") {
|
||||
val := ctx.String("add-assignees")
|
||||
opts.AddAssignees = strings.Split(val, ",")
|
||||
}
|
||||
if ctx.IsSet("add-labels") {
|
||||
val := ctx.String("add-labels")
|
||||
opts.AddLabels = strings.Split(val, ",")
|
||||
}
|
||||
if ctx.IsSet("remove-labels") {
|
||||
val := ctx.String("remove-labels")
|
||||
opts.RemoveLabels = strings.Split(val, ",")
|
||||
}
|
||||
return &opts, nil
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2018 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package cmd
|
||||
|
||||
|
@ -27,7 +28,6 @@ var CmdIssues = cli.Command{
|
|||
Subcommands: []*cli.Command{
|
||||
&issues.CmdIssuesList,
|
||||
&issues.CmdIssuesCreate,
|
||||
&issues.CmdIssuesEdit,
|
||||
&issues.CmdIssuesReopen,
|
||||
&issues.CmdIssuesClose,
|
||||
},
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2018 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package issues
|
||||
|
||||
|
@ -18,9 +19,9 @@ import (
|
|||
// CmdIssuesClose represents a sub command of issues to close an issue
|
||||
var CmdIssuesClose = cli.Command{
|
||||
Name: "close",
|
||||
Usage: "Change state of one ore more issues to 'closed'",
|
||||
Description: `Change state of one ore more issues to 'closed'`,
|
||||
ArgsUsage: "<issue index> [<issue index>...]",
|
||||
Usage: "Change state of an issue to 'closed'",
|
||||
Description: `Change state of an issue to 'closed'`,
|
||||
ArgsUsage: "<issue index>",
|
||||
Action: func(ctx *cli.Context) error {
|
||||
var s = gitea.StateClosed
|
||||
return editIssueState(ctx, gitea.EditIssueOption{State: &s})
|
||||
|
@ -36,23 +37,16 @@ func editIssueState(cmd *cli.Context, opts gitea.EditIssueOption) error {
|
|||
return fmt.Errorf(ctx.Command.ArgsUsage)
|
||||
}
|
||||
|
||||
indices, err := utils.ArgsToIndices(ctx.Args().Slice())
|
||||
index, err := utils.ArgToIndex(ctx.Args().First())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
client := ctx.Login.Client()
|
||||
for _, index := range indices {
|
||||
issue, _, err := client.EditIssue(ctx.Owner, ctx.Repo, index, opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(indices) > 1 {
|
||||
fmt.Println(issue.HTMLURL)
|
||||
} else {
|
||||
print.IssueDetails(issue, nil)
|
||||
}
|
||||
issue, _, err := ctx.Login.Client().EditIssue(ctx.Owner, ctx.Repo, index, opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
print.IssueDetails(issue, nil)
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package issues
|
||||
|
||||
|
@ -20,7 +21,7 @@ var CmdIssuesCreate = cli.Command{
|
|||
Description: `Create an issue on repository`,
|
||||
ArgsUsage: " ", // command does not accept arguments
|
||||
Action: runIssuesCreate,
|
||||
Flags: flags.IssuePRCreateFlags,
|
||||
Flags: flags.IssuePREditFlags,
|
||||
}
|
||||
|
||||
func runIssuesCreate(cmd *cli.Context) error {
|
||||
|
@ -31,7 +32,7 @@ func runIssuesCreate(cmd *cli.Context) error {
|
|||
return interact.CreateIssue(ctx.Login, ctx.Owner, ctx.Repo)
|
||||
}
|
||||
|
||||
opts, err := flags.GetIssuePRCreateFlags(ctx)
|
||||
opts, err := flags.GetIssuePREditFlags(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -1,62 +0,0 @@
|
|||
// Copyright 2022 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package issues
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"code.gitea.io/tea/cmd/flags"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
"code.gitea.io/tea/modules/print"
|
||||
"code.gitea.io/tea/modules/task"
|
||||
"code.gitea.io/tea/modules/utils"
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// CmdIssuesEdit is the subcommand of issues to edit issues
|
||||
var CmdIssuesEdit = cli.Command{
|
||||
Name: "edit",
|
||||
Aliases: []string{"e"},
|
||||
Usage: "Edit one or more issues",
|
||||
Description: `Edit one or more issues. To unset a property again,
|
||||
use an empty string (eg. --milestone "").`,
|
||||
ArgsUsage: "<idx> [<idx>...]",
|
||||
Action: runIssuesEdit,
|
||||
Flags: flags.IssuePREditFlags,
|
||||
}
|
||||
|
||||
func runIssuesEdit(cmd *cli.Context) error {
|
||||
ctx := context.InitCommand(cmd)
|
||||
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
|
||||
|
||||
if !cmd.Args().Present() {
|
||||
return fmt.Errorf("must specify at least one issue index")
|
||||
}
|
||||
|
||||
opts, err := flags.GetIssuePREditFlags(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
indices, err := utils.ArgsToIndices(ctx.Args().Slice())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
client := ctx.Login.Client()
|
||||
for _, opts.Index = range indices {
|
||||
issue, err := task.EditIssue(ctx, client, *opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if ctx.Args().Len() > 1 {
|
||||
fmt.Println(issue.HTMLURL)
|
||||
} else {
|
||||
print.IssueDetails(issue, nil)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package issues
|
||||
|
||||
|
@ -17,7 +18,7 @@ import (
|
|||
)
|
||||
|
||||
var issueFieldsFlag = flags.FieldsFlag(print.IssueFields, []string{
|
||||
"index", "title", "state", "author", "milestone", "labels", "owner", "repo",
|
||||
"index", "title", "state", "author", "milestone", "labels",
|
||||
})
|
||||
|
||||
// CmdIssuesList represents a sub command of issues to list issues
|
||||
|
@ -34,6 +35,7 @@ var CmdIssuesList = cli.Command{
|
|||
// RunIssuesList list issues
|
||||
func RunIssuesList(cmd *cli.Context) error {
|
||||
ctx := context.InitCommand(cmd)
|
||||
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
|
||||
|
||||
state := gitea.StateOpen
|
||||
switch ctx.String("state") {
|
||||
|
@ -73,52 +75,27 @@ func RunIssuesList(cmd *cli.Context) error {
|
|||
return err
|
||||
}
|
||||
}
|
||||
owner := ctx.Owner
|
||||
if ctx.IsSet("owner") {
|
||||
owner = ctx.String("owner")
|
||||
}
|
||||
|
||||
// ignore error, as we don't do any input validation on these flags
|
||||
labels, _ := flags.LabelFilterFlag.GetValues(cmd)
|
||||
milestones, _ := flags.MilestoneFilterFlag.GetValues(cmd)
|
||||
var issues []*gitea.Issue
|
||||
if ctx.Repo != "" {
|
||||
issues, _, err = ctx.Login.Client().ListRepoIssues(owner, ctx.Repo, gitea.ListIssueOption{
|
||||
ListOptions: ctx.GetListOptions(),
|
||||
State: state,
|
||||
Type: kind,
|
||||
KeyWord: ctx.String("keyword"),
|
||||
CreatedBy: ctx.String("author"),
|
||||
AssignedBy: ctx.String("assigned-to"),
|
||||
MentionedBy: ctx.String("mentions"),
|
||||
Labels: labels,
|
||||
Milestones: milestones,
|
||||
Since: from,
|
||||
Before: until,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
issues, _, err = ctx.Login.Client().ListIssues(gitea.ListIssueOption{
|
||||
ListOptions: ctx.GetListOptions(),
|
||||
State: state,
|
||||
Type: kind,
|
||||
KeyWord: ctx.String("keyword"),
|
||||
CreatedBy: ctx.String("author"),
|
||||
AssignedBy: ctx.String("assigned-to"),
|
||||
MentionedBy: ctx.String("mentions"),
|
||||
Labels: labels,
|
||||
Milestones: milestones,
|
||||
Since: from,
|
||||
Before: until,
|
||||
Owner: owner,
|
||||
})
|
||||
issues, _, err := ctx.Login.Client().ListRepoIssues(ctx.Owner, ctx.Repo, gitea.ListIssueOption{
|
||||
ListOptions: ctx.GetListOptions(),
|
||||
State: state,
|
||||
Type: kind,
|
||||
KeyWord: ctx.String("keyword"),
|
||||
CreatedBy: ctx.String("author"),
|
||||
AssignedBy: ctx.String("assigned-to"),
|
||||
MentionedBy: ctx.String("mentions"),
|
||||
Labels: labels,
|
||||
Milestones: milestones,
|
||||
Since: from,
|
||||
Before: until,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fields, err := issueFieldsFlag.GetValues(cmd)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package issues
|
||||
|
||||
|
@ -14,9 +15,9 @@ import (
|
|||
var CmdIssuesReopen = cli.Command{
|
||||
Name: "reopen",
|
||||
Aliases: []string{"open"},
|
||||
Usage: "Change state of one or more issues to 'open'",
|
||||
Description: `Change state of one or more issues to 'open'`,
|
||||
ArgsUsage: "<issue index> [<issue index>...]",
|
||||
Usage: "Change state of an issue to 'open'",
|
||||
Description: `Change state of an issue to 'open'`,
|
||||
ArgsUsage: "<issue index>",
|
||||
Action: func(ctx *cli.Context) error {
|
||||
var s = gitea.StateOpen
|
||||
return editIssueState(ctx, gitea.EditIssueOption{State: &s})
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package cmd
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package labels
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package labels
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package labels
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package labels
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package labels
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package cmd
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package login
|
||||
|
||||
|
@ -29,11 +30,6 @@ var CmdLoginAdd = cli.Command{
|
|||
EnvVars: []string{"GITEA_SERVER_URL"},
|
||||
Usage: "Server URL",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "no-version-check",
|
||||
Aliases: []string{"nv"},
|
||||
Usage: "Do not check version of Gitea instance",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "token",
|
||||
Aliases: []string{"t"},
|
||||
|
@ -54,36 +50,16 @@ var CmdLoginAdd = cli.Command{
|
|||
EnvVars: []string{"GITEA_SERVER_PASSWORD"},
|
||||
Usage: "Password for basic auth (will create token)",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "otp",
|
||||
EnvVars: []string{"GITEA_SERVER_OTP"},
|
||||
Usage: "OTP token for auth, if necessary",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "scopes",
|
||||
EnvVars: []string{"GITEA_SCOPES"},
|
||||
Usage: "Token scopes to add when creating a new token, separated by a comma",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "ssh-key",
|
||||
Aliases: []string{"s"},
|
||||
Usage: "Path to a SSH key/certificate to use, overrides auto-discovery",
|
||||
Usage: "Path to a SSH key to use, overrides auto-discovery",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "insecure",
|
||||
Aliases: []string{"i"},
|
||||
Usage: "Disable TLS verification",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "ssh-agent-principal",
|
||||
Aliases: []string{"c"},
|
||||
Usage: "Use SSH certificate with specified principal to login (needs a running ssh-agent with certificate loaded)",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "ssh-agent-key",
|
||||
Aliases: []string{"a"},
|
||||
Usage: "Use SSH public key or SSH fingerprint to login (needs a running ssh-agent with ssh key loaded)",
|
||||
},
|
||||
},
|
||||
Action: runLoginAdd,
|
||||
}
|
||||
|
@ -94,24 +70,13 @@ func runLoginAdd(ctx *cli.Context) error {
|
|||
return interact.CreateLogin()
|
||||
}
|
||||
|
||||
sshAgent := false
|
||||
if ctx.String("ssh-agent-key") != "" || ctx.String("ssh-agent-principal") != "" {
|
||||
sshAgent = true
|
||||
}
|
||||
|
||||
// else use args to add login
|
||||
return task.CreateLogin(
|
||||
ctx.String("name"),
|
||||
ctx.String("token"),
|
||||
ctx.String("user"),
|
||||
ctx.String("password"),
|
||||
ctx.String("otp"),
|
||||
ctx.String("scopes"),
|
||||
ctx.String("ssh-key"),
|
||||
ctx.String("url"),
|
||||
ctx.String("ssh-agent-principal"),
|
||||
ctx.String("ssh-agent-key"),
|
||||
ctx.Bool("insecure"),
|
||||
sshAgent,
|
||||
!ctx.Bool("no-version-check"))
|
||||
ctx.Bool("insecure"))
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package login
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package login
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package login
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package login
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package cmd
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package cmd
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package milestones
|
||||
|
||||
|
@ -12,9 +13,9 @@ import (
|
|||
// CmdMilestonesClose represents a sub command of milestones to close an milestone
|
||||
var CmdMilestonesClose = cli.Command{
|
||||
Name: "close",
|
||||
Usage: "Change state of one or more milestones to 'closed'",
|
||||
Description: `Change state of one or more milestones to 'closed'`,
|
||||
ArgsUsage: "<milestone name> [<milestone name>...]",
|
||||
Usage: "Change state of an milestone to 'closed'",
|
||||
Description: `Change state of an milestone to 'closed'`,
|
||||
ArgsUsage: "<milestone name>",
|
||||
Action: func(ctx *cli.Context) error {
|
||||
if ctx.Bool("force") {
|
||||
return deleteMilestone(ctx)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package milestones
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package milestones
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package milestones
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package milestones
|
||||
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package milestones
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"code.gitea.io/tea/cmd/flags"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
"code.gitea.io/tea/modules/print"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
"github.com/urfave/cli/v2"
|
||||
|
@ -18,9 +16,9 @@ import (
|
|||
var CmdMilestonesReopen = cli.Command{
|
||||
Name: "reopen",
|
||||
Aliases: []string{"open"},
|
||||
Usage: "Change state of one or more milestones to 'open'",
|
||||
Description: `Change state of one or more milestones to 'open'`,
|
||||
ArgsUsage: "<milestone name> [<milestone name> ...]",
|
||||
Usage: "Change state of an milestone to 'open'",
|
||||
Description: `Change state of an milestone to 'open'`,
|
||||
ArgsUsage: "<milestone name>",
|
||||
Action: func(ctx *cli.Context) error {
|
||||
return editMilestoneStatus(ctx, false)
|
||||
},
|
||||
|
@ -30,31 +28,16 @@ var CmdMilestonesReopen = cli.Command{
|
|||
func editMilestoneStatus(cmd *cli.Context, close bool) error {
|
||||
ctx := context.InitCommand(cmd)
|
||||
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
|
||||
if ctx.Args().Len() == 0 {
|
||||
return fmt.Errorf(ctx.Command.ArgsUsage)
|
||||
}
|
||||
client := ctx.Login.Client()
|
||||
|
||||
state := gitea.StateOpen
|
||||
if close {
|
||||
state = gitea.StateClosed
|
||||
}
|
||||
_, _, err := client.EditMilestoneByName(ctx.Owner, ctx.Repo, ctx.Args().First(), gitea.EditMilestoneOption{
|
||||
State: &state,
|
||||
Title: ctx.Args().First(),
|
||||
})
|
||||
|
||||
client := ctx.Login.Client()
|
||||
for _, ms := range ctx.Args().Slice() {
|
||||
opts := gitea.EditMilestoneOption{
|
||||
State: &state,
|
||||
Title: ms,
|
||||
}
|
||||
milestone, _, err := client.EditMilestoneByName(ctx.Owner, ctx.Repo, ms, opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if ctx.Args().Len() > 1 {
|
||||
fmt.Printf("%s/milestone/%d\n", ctx.GetRemoteRepoHTMLURL(), milestone.ID)
|
||||
} else {
|
||||
print.MilestoneDetails(milestone)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package cmd
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2021 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package notifications
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2021 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package notifications
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package cmd
|
||||
|
||||
|
@ -73,5 +74,6 @@ func runOpen(cmd *cli.Context) error {
|
|||
suffix = number
|
||||
}
|
||||
|
||||
return open.Run(path.Join(ctx.GetRemoteRepoHTMLURL(), suffix))
|
||||
u := path.Join(ctx.Login.URL, ctx.Owner, ctx.Repo, suffix)
|
||||
return open.Run(u)
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package cmd
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2021 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package organizations
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package organizations
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package organizations
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2018 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package cmd
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package pulls
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package pulls
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package pulls
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package pulls
|
||||
|
||||
|
@ -13,9 +14,9 @@ import (
|
|||
// CmdPullsClose closes a given open pull request
|
||||
var CmdPullsClose = cli.Command{
|
||||
Name: "close",
|
||||
Usage: "Change state of one or more pull requests to 'closed'",
|
||||
Description: `Change state of one or more pull requests to 'closed'`,
|
||||
ArgsUsage: "<pull index> [<pull index>...]",
|
||||
Usage: "Change state of a pull request to 'closed'",
|
||||
Description: `Change state of a pull request to 'closed'`,
|
||||
ArgsUsage: "<pull index>",
|
||||
Action: func(ctx *cli.Context) error {
|
||||
var s = gitea.StateClosed
|
||||
return editPullState(ctx, gitea.EditPullRequestOption{State: &s})
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package pulls
|
||||
|
||||
|
@ -29,13 +30,7 @@ var CmdPullsCreate = cli.Command{
|
|||
Aliases: []string{"b"},
|
||||
Usage: "Branch name of the PR target (default is repos default branch)",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "allow-maintainer-edits",
|
||||
Aliases: []string{"edits"},
|
||||
Usage: "Enable maintainers to push to the base branch of created pull",
|
||||
Value: true,
|
||||
},
|
||||
}, flags.IssuePRCreateFlags...),
|
||||
}, flags.IssuePREditFlags...),
|
||||
}
|
||||
|
||||
func runPullsCreate(cmd *cli.Context) error {
|
||||
|
@ -47,7 +42,7 @@ func runPullsCreate(cmd *cli.Context) error {
|
|||
}
|
||||
|
||||
// else use args to create PR
|
||||
opts, err := flags.GetIssuePRCreateFlags(ctx)
|
||||
opts, err := flags.GetIssuePREditFlags(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -56,7 +51,6 @@ func runPullsCreate(cmd *cli.Context) error {
|
|||
ctx,
|
||||
ctx.String("base"),
|
||||
ctx.String("head"),
|
||||
ctx.Bool("allow-maintainer-edits"),
|
||||
opts,
|
||||
)
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package pulls
|
||||
|
||||
|
@ -22,23 +23,16 @@ func editPullState(cmd *cli.Context, opts gitea.EditPullRequestOption) error {
|
|||
return fmt.Errorf("Please provide a Pull Request index")
|
||||
}
|
||||
|
||||
indices, err := utils.ArgsToIndices(ctx.Args().Slice())
|
||||
index, err := utils.ArgToIndex(ctx.Args().First())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
client := ctx.Login.Client()
|
||||
for _, index := range indices {
|
||||
pr, _, err := client.EditPullRequest(ctx.Owner, ctx.Repo, index, opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(indices) > 1 {
|
||||
fmt.Println(pr.HTMLURL)
|
||||
} else {
|
||||
print.PullDetails(pr, nil, nil)
|
||||
}
|
||||
pr, _, err := ctx.Login.Client().EditPullRequest(ctx.Owner, ctx.Repo, index, opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
print.PullDetails(pr, nil, nil)
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package pulls
|
||||
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
// Copyright 2021 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package pulls
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
"code.gitea.io/tea/cmd/flags"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
"code.gitea.io/tea/modules/interact"
|
||||
"code.gitea.io/tea/modules/task"
|
||||
"code.gitea.io/tea/modules/utils"
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
|
@ -44,8 +45,7 @@ var CmdPullsMerge = cli.Command{
|
|||
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
|
||||
|
||||
if ctx.Args().Len() != 1 {
|
||||
// If no PR index is provided, try interactive mode
|
||||
return interact.MergePull(ctx)
|
||||
return fmt.Errorf("Must specify a PR index")
|
||||
}
|
||||
|
||||
idx, err := utils.ArgToIndex(ctx.Args().First())
|
||||
|
@ -53,10 +53,18 @@ var CmdPullsMerge = cli.Command{
|
|||
return err
|
||||
}
|
||||
|
||||
return task.PullMerge(ctx.Login, ctx.Owner, ctx.Repo, idx, gitea.MergePullRequestOption{
|
||||
success, _, err := ctx.Login.Client().MergePullRequest(ctx.Owner, ctx.Repo, idx, gitea.MergePullRequestOption{
|
||||
Style: gitea.MergeStyle(ctx.String("style")),
|
||||
Title: ctx.String("title"),
|
||||
Message: ctx.String("message"),
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !success {
|
||||
return fmt.Errorf("Failed to merge PR. Is it still open?")
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package pulls
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package pulls
|
||||
|
||||
|
@ -14,9 +15,9 @@ import (
|
|||
var CmdPullsReopen = cli.Command{
|
||||
Name: "reopen",
|
||||
Aliases: []string{"open"},
|
||||
Usage: "Change state of one or more pull requests to 'open'",
|
||||
Description: `Change state of one or more pull requests to 'open'`,
|
||||
ArgsUsage: "<pull index> [<pull index>...]",
|
||||
Usage: "Change state of a pull request to 'open'",
|
||||
Description: `Change state of a pull request to 'open'`,
|
||||
ArgsUsage: "<pull index>",
|
||||
Action: func(ctx *cli.Context) error {
|
||||
var s = gitea.StateOpen
|
||||
return editPullState(ctx, gitea.EditPullRequestOption{State: &s})
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package pulls
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2018 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package cmd
|
||||
|
||||
|
@ -25,7 +26,6 @@ var CmdReleases = cli.Command{
|
|||
&releases.CmdReleaseCreate,
|
||||
&releases.CmdReleaseDelete,
|
||||
&releases.CmdReleaseEdit,
|
||||
&CmdReleaseAttachments,
|
||||
},
|
||||
Flags: flags.AllDefaultFlags,
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package releases
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package releases
|
||||
|
||||
|
@ -16,9 +17,9 @@ import (
|
|||
var CmdReleaseDelete = cli.Command{
|
||||
Name: "delete",
|
||||
Aliases: []string{"rm"},
|
||||
Usage: "Delete one or more releases",
|
||||
Description: `Delete one or more releases`,
|
||||
ArgsUsage: "<release tag> [<release tag>...]",
|
||||
Usage: "Delete a release",
|
||||
Description: `Delete a release`,
|
||||
ArgsUsage: "<release tag>",
|
||||
Action: runReleaseDelete,
|
||||
Flags: append([]cli.Flag{
|
||||
&cli.BoolFlag{
|
||||
|
@ -38,8 +39,9 @@ func runReleaseDelete(cmd *cli.Context) error {
|
|||
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
|
||||
client := ctx.Login.Client()
|
||||
|
||||
if !ctx.Args().Present() {
|
||||
fmt.Println("Release tag needed to edit")
|
||||
tag := ctx.Args().First()
|
||||
if len(tag) == 0 {
|
||||
fmt.Println("Release tag needed to delete")
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -48,20 +50,18 @@ func runReleaseDelete(cmd *cli.Context) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
for _, tag := range ctx.Args().Slice() {
|
||||
release, err := getReleaseByTag(ctx.Owner, ctx.Repo, tag, client)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = client.DeleteRelease(ctx.Owner, ctx.Repo, release.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
release, err := getReleaseByTag(ctx.Owner, ctx.Repo, tag, client)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = client.DeleteRelease(ctx.Owner, ctx.Repo, release.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if ctx.Bool("delete-tag") {
|
||||
_, err = client.DeleteTag(ctx.Owner, ctx.Repo, tag)
|
||||
return err
|
||||
}
|
||||
if ctx.Bool("delete-tag") {
|
||||
_, err = client.DeleteTag(ctx.Owner, ctx.Repo, tag)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package releases
|
||||
|
||||
|
@ -18,9 +19,9 @@ import (
|
|||
var CmdReleaseEdit = cli.Command{
|
||||
Name: "edit",
|
||||
Aliases: []string{"e"},
|
||||
Usage: "Edit one or more releases",
|
||||
Description: `Edit one or more releases`,
|
||||
ArgsUsage: "<release tag> [<release tag>...]",
|
||||
Usage: "Edit a release",
|
||||
Description: `Edit a release`,
|
||||
ArgsUsage: "<release tag>",
|
||||
Action: runReleaseEdit,
|
||||
Flags: append([]cli.Flag{
|
||||
&cli.StringFlag{
|
||||
|
@ -61,6 +62,16 @@ func runReleaseEdit(cmd *cli.Context) error {
|
|||
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
|
||||
client := ctx.Login.Client()
|
||||
|
||||
tag := ctx.Args().First()
|
||||
if len(tag) == 0 {
|
||||
fmt.Println("Release tag needed to edit")
|
||||
return nil
|
||||
}
|
||||
|
||||
release, err := getReleaseByTag(ctx.Owner, ctx.Repo, tag, client)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var isDraft, isPre *bool
|
||||
if ctx.IsSet("draft") {
|
||||
isDraft = gitea.OptionalBool(strings.ToLower(ctx.String("draft"))[:1] == "t")
|
||||
|
@ -69,28 +80,13 @@ func runReleaseEdit(cmd *cli.Context) error {
|
|||
isPre = gitea.OptionalBool(strings.ToLower(ctx.String("prerelease"))[:1] == "t")
|
||||
}
|
||||
|
||||
if !ctx.Args().Present() {
|
||||
fmt.Println("Release tag needed to edit")
|
||||
return nil
|
||||
}
|
||||
|
||||
for _, tag := range ctx.Args().Slice() {
|
||||
release, err := getReleaseByTag(ctx.Owner, ctx.Repo, tag, client)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, _, err = client.EditRelease(ctx.Owner, ctx.Repo, release.ID, gitea.EditReleaseOption{
|
||||
TagName: ctx.String("tag"),
|
||||
Target: ctx.String("target"),
|
||||
Title: ctx.String("title"),
|
||||
Note: ctx.String("note"),
|
||||
IsDraft: isDraft,
|
||||
IsPrerelease: isPre,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
_, _, err = client.EditRelease(ctx.Owner, ctx.Repo, release.ID, gitea.EditReleaseOption{
|
||||
TagName: ctx.String("tag"),
|
||||
Target: ctx.String("target"),
|
||||
Title: ctx.String("title"),
|
||||
Note: ctx.String("note"),
|
||||
IsDraft: isDraft,
|
||||
IsPrerelease: isPre,
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package releases
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package cmd
|
||||
|
||||
|
@ -28,8 +29,6 @@ var CmdRepos = cli.Command{
|
|||
&repos.CmdRepoCreate,
|
||||
&repos.CmdRepoCreateFromTemplate,
|
||||
&repos.CmdRepoFork,
|
||||
&repos.CmdRepoMigrate,
|
||||
&repos.CmdRepoRm,
|
||||
},
|
||||
Flags: repos.CmdReposListFlags,
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package repos
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2021 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package repos
|
||||
|
||||
|
|
|
@ -1,85 +0,0 @@
|
|||
// Copyright 2023 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package repos
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"code.gitea.io/tea/cmd/flags"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
|
||||
"github.com/AlecAivazis/survey/v2"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// CmdRepoRm represents a sub command of repos to delete an existing repo
|
||||
var CmdRepoRm = cli.Command{
|
||||
Name: "delete",
|
||||
Aliases: []string{"rm"},
|
||||
Usage: "Delete an existing repository",
|
||||
Description: "Removes a repository from Create a repository from an existing repo",
|
||||
ArgsUsage: " ", // command does not accept arguments
|
||||
Action: runRepoDelete,
|
||||
Flags: append([]cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "name",
|
||||
Aliases: []string{""},
|
||||
Required: true,
|
||||
Usage: "name of the repo",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "owner",
|
||||
Aliases: []string{"O"},
|
||||
Required: false,
|
||||
Usage: "owner of the repo",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "force",
|
||||
Aliases: []string{"f"},
|
||||
Required: false,
|
||||
Value: false,
|
||||
Usage: "Force the deletion and don't ask for confirmation",
|
||||
},
|
||||
}, flags.LoginOutputFlags...),
|
||||
}
|
||||
|
||||
func runRepoDelete(cmd *cli.Context) error {
|
||||
ctx := context.InitCommand(cmd)
|
||||
|
||||
client := ctx.Login.Client()
|
||||
|
||||
var owner string
|
||||
if ctx.IsSet("owner") {
|
||||
owner = ctx.String("owner")
|
||||
|
||||
} else {
|
||||
owner = ctx.Login.User
|
||||
}
|
||||
|
||||
repoName := ctx.String("name")
|
||||
|
||||
repoSlug := fmt.Sprintf("%s/%s", owner, repoName)
|
||||
|
||||
if !ctx.Bool("force") {
|
||||
var enteredRepoSlug string
|
||||
promptRepoName := &survey.Input{
|
||||
Message: fmt.Sprintf("Confirm the deletion of the repository '%s' by typing its name: ", repoSlug),
|
||||
}
|
||||
if err := survey.AskOne(promptRepoName, &enteredRepoSlug, survey.WithValidator(survey.Required)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if enteredRepoSlug != repoSlug {
|
||||
return fmt.Errorf("Entered wrong repository name '%s', expected '%s'", enteredRepoSlug, repoSlug)
|
||||
}
|
||||
}
|
||||
|
||||
_, err := client.DeleteRepo(owner, repoName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Printf("Successfully deleted %s/%s\n", owner, repoName)
|
||||
return nil
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package repos
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2021 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package repos
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package repos
|
||||
|
||||
|
|
|
@ -1,168 +0,0 @@
|
|||
// Copyright 2023 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package repos
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"code.gitea.io/tea/cmd/flags"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
"code.gitea.io/tea/modules/print"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// CmdRepoMigrate represents a sub command of repos to migrate one
|
||||
var CmdRepoMigrate = cli.Command{
|
||||
Name: "migrate",
|
||||
Aliases: []string{"m"},
|
||||
Usage: "Migrate a repository",
|
||||
Description: "Migrate a repository and or mirror it.",
|
||||
ArgsUsage: " ", // command does not accept arguments
|
||||
Action: runRepoMigrate,
|
||||
Flags: append([]cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "name",
|
||||
Usage: "Name of the repository",
|
||||
Required: true,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "owner",
|
||||
Usage: "Owner of the repository",
|
||||
Required: true,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "clone-url",
|
||||
Usage: "Clone URL of the repository",
|
||||
Required: true,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "service",
|
||||
Usage: string("Service to migrate from. Supported services are: " + gitea.GitServicePlain +
|
||||
", " + gitea.GitServiceGitea + ", " + gitea.GitServiceGitlab + ", " + gitea.GitServiceGogs),
|
||||
Required: true,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "mirror",
|
||||
Usage: "Mirror the repository",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "private",
|
||||
Usage: "Make the repository private",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "template",
|
||||
Usage: "Make the repository a template",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "wiki",
|
||||
Usage: "Copy the wiki",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "issues",
|
||||
Usage: "Copy the issues",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "pull-requests",
|
||||
Usage: "Copy the pull requests",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "releases",
|
||||
Usage: "Copy the releases",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "milestones",
|
||||
Usage: "Copy the milestones",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "mirror-interval",
|
||||
Usage: "Interval to mirror the repository.",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "lfs",
|
||||
Usage: "Copy the LFS objects",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "lfs-endpoint",
|
||||
Usage: "LFS endpoint to use",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "auth-user",
|
||||
Usage: "Username to use for authentication.",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "auth-password",
|
||||
Usage: "Password to use for authentication.",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "auth-token",
|
||||
Usage: "Token to use for authentication.",
|
||||
},
|
||||
}, flags.LoginOutputFlags...),
|
||||
}
|
||||
|
||||
func runRepoMigrate(cmd *cli.Context) error {
|
||||
ctx := context.InitCommand(cmd)
|
||||
client := ctx.Login.Client()
|
||||
var (
|
||||
repo *gitea.Repository
|
||||
err error
|
||||
service gitea.GitServiceType
|
||||
)
|
||||
|
||||
if ctx.IsSet("service") {
|
||||
switch ctx.String("service") {
|
||||
case "git":
|
||||
service = gitea.GitServicePlain
|
||||
case "gitea":
|
||||
service = gitea.GitServiceGitea
|
||||
case "gitlab":
|
||||
service = gitea.GitServiceGitlab
|
||||
case "gogs":
|
||||
service = gitea.GitServiceGogs
|
||||
case "github":
|
||||
service = gitea.GitServiceGithub
|
||||
default:
|
||||
return fmt.Errorf("unknown git service type '%s'", ctx.String("service"))
|
||||
}
|
||||
}
|
||||
|
||||
opts := gitea.MigrateRepoOption{
|
||||
RepoName: ctx.String("name"),
|
||||
RepoOwner: ctx.String("owner"),
|
||||
CloneAddr: ctx.String("clone-url"),
|
||||
Service: service,
|
||||
AuthUsername: ctx.String("auth-user"),
|
||||
AuthPassword: ctx.String("auth-password"),
|
||||
AuthToken: ctx.String("auth-token"),
|
||||
Mirror: ctx.Bool("mirror"),
|
||||
Private: ctx.Bool("private"),
|
||||
Description: ctx.String("description"),
|
||||
Wiki: ctx.Bool("wiki"),
|
||||
Milestones: ctx.Bool("milestones"),
|
||||
Labels: ctx.Bool("labels"),
|
||||
Issues: ctx.Bool("issues"),
|
||||
PullRequests: ctx.Bool("pull-requests"),
|
||||
Releases: ctx.Bool("releases"),
|
||||
MirrorInterval: ctx.String("mirror-interval"),
|
||||
LFS: ctx.Bool("lfs"),
|
||||
LFSEndpoint: ctx.String("lfs-endpoint"),
|
||||
}
|
||||
|
||||
repo, _, err = client.MigrateRepo(opts)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
topics, _, err := client.ListRepoTopics(repo.Owner.UserName, repo.Name, gitea.ListRepoTopicsOptions{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
print.RepoDetails(repo, topics)
|
||||
|
||||
fmt.Printf("%s\n", repo.HTMLURL)
|
||||
return nil
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package repos
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package cmd
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package times
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package times
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package times
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package times
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2021 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package cmd
|
||||
|
||||
|
|
15
devbox.json
15
devbox.json
|
@ -1,15 +0,0 @@
|
|||
{
|
||||
"packages": [
|
||||
"go@1.20",
|
||||
"gopls@latest",
|
||||
"gnumake@latest"
|
||||
],
|
||||
"shell": {
|
||||
"init_hook": [
|
||||
"echo 'Welcome to tea. Check out the Makefile for runnable targets.'"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "make"
|
||||
}
|
||||
}
|
||||
}
|
23
devbox.lock
23
devbox.lock
|
@ -1,23 +0,0 @@
|
|||
{
|
||||
"lockfile_version": "1",
|
||||
"packages": {
|
||||
"gnumake@latest": {
|
||||
"last_modified": "2023-08-30T00:25:28Z",
|
||||
"resolved": "github:NixOS/nixpkgs/a63a64b593dcf2fe05f7c5d666eb395950f36bc9#gnumake",
|
||||
"source": "devbox-search",
|
||||
"version": "4.4.1"
|
||||
},
|
||||
"go@1.20": {
|
||||
"last_modified": "2023-08-30T00:25:28Z",
|
||||
"resolved": "github:NixOS/nixpkgs/a63a64b593dcf2fe05f7c5d666eb395950f36bc9#go",
|
||||
"source": "devbox-search",
|
||||
"version": "1.20.7"
|
||||
},
|
||||
"gopls@latest": {
|
||||
"last_modified": "2023-08-30T00:25:28Z",
|
||||
"resolved": "github:NixOS/nixpkgs/a63a64b593dcf2fe05f7c5d666eb395950f36bc9#gopls",
|
||||
"source": "devbox-search",
|
||||
"version": "0.13.2"
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue