Skip to content

Commit 8ee4097

Browse files
authored
Merge branch 'master' into oauth2-auto-register
2 parents 1373b78 + b337c60 commit 8ee4097

File tree

12 files changed

+97
-53
lines changed

12 files changed

+97
-53
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ help:
190190
go-check:
191191
$(eval GO_VERSION := $(shell printf "%03d%03d%03d" $(shell $(GO) version | grep -Eo '[0-9]+\.[0-9.]+' | tr '.' ' ');))
192192
@if [ "$(GO_VERSION)" -lt "$(MIN_GO_VERSION)" ]; then \
193-
echo "Gitea requires Go 1.13 or greater to build. You can get it at https://golang.org/dl/"; \
193+
echo "Gitea requires Go 1.14 or greater to build. You can get it at https://golang.org/dl/"; \
194194
exit 1; \
195195
fi
196196

cmd/dump.go

Lines changed: 24 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -49,38 +49,6 @@ func addFile(w archiver.Writer, filePath string, absPath string, verbose bool) e
4949
})
5050
}
5151

52-
func addRecursive(w archiver.Writer, dirPath string, absPath string, verbose bool) error {
53-
if verbose {
54-
log.Info("Adding dir %s\n", dirPath)
55-
}
56-
dir, err := os.Open(absPath)
57-
if err != nil {
58-
return fmt.Errorf("Could not open directory %s: %s", absPath, err)
59-
}
60-
defer dir.Close()
61-
62-
files, err := dir.Readdir(0)
63-
if err != nil {
64-
return fmt.Errorf("Unable to list files in %s: %s", absPath, err)
65-
}
66-
67-
if err := addFile(w, dirPath, absPath, false); err != nil {
68-
return err
69-
}
70-
71-
for _, fileInfo := range files {
72-
if fileInfo.IsDir() {
73-
err = addRecursive(w, filepath.Join(dirPath, fileInfo.Name()), filepath.Join(absPath, fileInfo.Name()), verbose)
74-
} else {
75-
err = addFile(w, filepath.Join(dirPath, fileInfo.Name()), filepath.Join(absPath, fileInfo.Name()), verbose)
76-
}
77-
if err != nil {
78-
return err
79-
}
80-
}
81-
return nil
82-
}
83-
8452
func isSubdir(upper string, lower string) (bool, error) {
8553
if relPath, err := filepath.Rel(upper, lower); err != nil {
8654
return false, err
@@ -157,6 +125,10 @@ It can be used for backup and capture Gitea server image to send to maintainer`,
157125
Name: "skip-log, L",
158126
Usage: "Skip the log dumping",
159127
},
128+
cli.BoolFlag{
129+
Name: "skip-custom-dir",
130+
Usage: "Skip custom directory",
131+
},
160132
cli.GenericFlag{
161133
Name: "type",
162134
Value: outputTypeEnum,
@@ -211,6 +183,11 @@ func runDump(ctx *cli.Context) error {
211183
}
212184
defer file.Close()
213185

186+
absFileName, err := filepath.Abs(fileName)
187+
if err != nil {
188+
return err
189+
}
190+
214191
verbose := ctx.Bool("verbose")
215192
outType := ctx.String("type")
216193
var iface interface{}
@@ -233,7 +210,7 @@ func runDump(ctx *cli.Context) error {
233210
log.Info("Skip dumping local repositories")
234211
} else {
235212
log.Info("Dumping local repositories... %s", setting.RepoRootPath)
236-
if err := addRecursive(w, "repos", setting.RepoRootPath, verbose); err != nil {
213+
if err := addRecursiveExclude(w, "repos", setting.RepoRootPath, []string{absFileName}, verbose); err != nil {
237214
fatal("Failed to include repositories: %v", err)
238215
}
239216

@@ -292,17 +269,21 @@ func runDump(ctx *cli.Context) error {
292269
}
293270
}
294271

295-
customDir, err := os.Stat(setting.CustomPath)
296-
if err == nil && customDir.IsDir() {
297-
if is, _ := isSubdir(setting.AppDataPath, setting.CustomPath); !is {
298-
if err := addRecursive(w, "custom", setting.CustomPath, verbose); err != nil {
299-
fatal("Failed to include custom: %v", err)
272+
if ctx.IsSet("skip-custom-dir") && ctx.Bool("skip-custom-dir") {
273+
log.Info("Skiping custom directory")
274+
} else {
275+
customDir, err := os.Stat(setting.CustomPath)
276+
if err == nil && customDir.IsDir() {
277+
if is, _ := isSubdir(setting.AppDataPath, setting.CustomPath); !is {
278+
if err := addRecursiveExclude(w, "custom", setting.CustomPath, []string{absFileName}, verbose); err != nil {
279+
fatal("Failed to include custom: %v", err)
280+
}
281+
} else {
282+
log.Info("Custom dir %s is inside data dir %s, skipped", setting.CustomPath, setting.AppDataPath)
300283
}
301284
} else {
302-
log.Info("Custom dir %s is inside data dir %s, skipped", setting.CustomPath, setting.AppDataPath)
285+
log.Info("Custom dir %s doesn't exist, skipped", setting.CustomPath)
303286
}
304-
} else {
305-
log.Info("Custom dir %s doesn't exist, skipped", setting.CustomPath)
306287
}
307288

308289
isExist, err := util.IsExist(setting.AppDataPath)
@@ -325,6 +306,7 @@ func runDump(ctx *cli.Context) error {
325306
excludes = append(excludes, setting.LFS.Path)
326307
excludes = append(excludes, setting.Attachment.Path)
327308
excludes = append(excludes, setting.LogRootPath)
309+
excludes = append(excludes, absFileName)
328310
if err := addRecursiveExclude(w, "data", setting.AppDataPath, excludes, verbose); err != nil {
329311
fatal("Failed to include data directory: %v", err)
330312
}
@@ -358,7 +340,7 @@ func runDump(ctx *cli.Context) error {
358340
log.Error("Unable to check if %s exists. Error: %v", setting.LogRootPath, err)
359341
}
360342
if isExist {
361-
if err := addRecursive(w, "log", setting.LogRootPath, verbose); err != nil {
343+
if err := addRecursiveExclude(w, "log", setting.LogRootPath, []string{absFileName}, verbose); err != nil {
362344
fatal("Failed to include log: %v", err)
363345
}
364346
}

docs/content/doc/installation/from-source.en-us.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,3 +186,11 @@ CC=aarch64-unknown-linux-gnu-gcc GOOS=linux GOARCH=arm64 TAGS="bindata sqlite sq
186186
```
187187

188188
Replace `CC`, `GOOS`, and `GOARCH` as appropriate for your architecture target.
189+
190+
You will sometimes need to build a static compiled image. To do this you will need to add:
191+
192+
```
193+
LDFLAGS="-linkmode external -extldflags '-static' $LDFLAGS" TAGS="netgo osusergo $TAGS" make build
194+
```
195+
196+
This can be combined with `CC`, `GOOS`, and `GOARCH` as above.

docs/content/doc/usage/command-line.en-us.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ in the current directory.
253253
- `--file name`, `-f name`: Name of the dump file with will be created. Optional. (default: gitea-dump-[timestamp].zip).
254254
- `--tempdir path`, `-t path`: Path to the temporary directory used. Optional. (default: /tmp).
255255
- `--skip-repository`, `-R`: Skip the repository dumping. Optional.
256+
- `--skip-custom-dir`: Skip dumping of the custom dir. Optional.
256257
- `--database`, `-d`: Specify the database SQL syntax. Optional.
257258
- `--verbose`, `-V`: If provided, shows additional details. Optional.
258259
- Examples:

models/issue.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -745,11 +745,11 @@ func AddDeletePRBranchComment(doer *User, repo *Repository, issueID int64, branc
745745
return err
746746
}
747747
var opts = &CreateCommentOptions{
748-
Type: CommentTypeDeleteBranch,
749-
Doer: doer,
750-
Repo: repo,
751-
Issue: issue,
752-
CommitSHA: branchName,
748+
Type: CommentTypeDeleteBranch,
749+
Doer: doer,
750+
Repo: repo,
751+
Issue: issue,
752+
OldRef: branchName,
753753
}
754754
if _, err = createComment(sess, opts); err != nil {
755755
return err

models/migrations/migrations.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,8 @@ var migrations = []Migration{
284284
NewMigration("Add user redirect", addUserRedirect),
285285
// v168 -> v169
286286
NewMigration("Recreate user table to fix default values", recreateUserTableToFixDefaultValues),
287+
// v169 -> v170
288+
NewMigration("Update DeleteBranch comments to set the old_ref to the commit_sha", commentTypeDeleteBranchUseOldRef),
287289
}
288290

289291
// GetCurrentDBVersion returns the current db version

models/migrations/v169.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright 2021 The Gitea Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
package migrations
6+
7+
import (
8+
"xorm.io/xorm"
9+
)
10+
11+
func commentTypeDeleteBranchUseOldRef(x *xorm.Engine) error {
12+
_, err := x.Exec("UPDATE comment SET old_ref = commit_sha, commit_sha = '' WHERE type = 11")
13+
return err
14+
}

modules/git/blob_nogogit.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ import (
1111
"io"
1212
"strconv"
1313
"strings"
14-
15-
gitea_log "code.gitea.io/gitea/modules/log"
1614
)
1715

1816
// Blob represents a Git object.
@@ -35,7 +33,6 @@ func (b *Blob) DataAsync() (io.ReadCloser, error) {
3533
err := NewCommand("cat-file", "--batch").RunInDirFullPipeline(b.repoPath, stdoutWriter, stderr, strings.NewReader(b.ID.String()+"\n"))
3634
if err != nil {
3735
err = ConcatenateError(err, stderr.String())
38-
gitea_log.Error("Blob.DataAsync Error: %v", err)
3936
_ = stdoutWriter.CloseWithError(err)
4037
} else {
4138
_ = stdoutWriter.Close()

options/locale/locale_es-ES.ini

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ write=Escribir
8686
preview=Vista previa
8787
loading=Cargando…
8888

89+
step1=Paso 1:
90+
step2=Paso 2:
8991

9092
error404=La página a la que está intentando acceder o <strong>no existe</strong> o <strong>no está autorizado</strong> para verla.
9193

@@ -214,6 +216,7 @@ my_mirrors=Mis réplicas
214216
view_home=Ver %s
215217
search_repos=Buscar un repositorio…
216218
filter=Otros filtros
219+
filter_by_team_repositories=Filtrar por repositorios de equipo
217220

218221
show_archived=Archivado
219222
show_both_archived_unarchived=Mostrar respositorios archivados y desarchivados
@@ -618,6 +621,7 @@ or_enter_secret=O introduzca el secreto: %s
618621
then_enter_passcode=E introduzca el código de acceso mostrado en la aplicación:
619622
passcode_invalid=El código de acceso es incorrecto. Vuelva a intentarlo.
620623
twofa_enrolled=Su cuenta ha sido inscrita en la autenticación de doble factor. ¡Guarde su código de respaldo (%s) en un lugar seguro, ya que sólo se muestra una vez!
624+
twofa_failed_get_secret=No se pudo obtener el secreto.
621625

622626
u2f_desc=Las claves de seguridad son dispositivos hardware que contienen claves criptográficas. Pueden ser usados para la autenticación de doble factor. Las claves de seguridad deben soportar el estándar <a href="https://fidoalliance.org/">FIDOU2F</a>.
623627
u2f_require_twofa=Su cuenta debe tener activada la autenticación de doble factor para utilizar claves de seguridad.
@@ -814,6 +818,8 @@ tag=Etiqueta
814818
released_this=publicó esto
815819
file_raw=Original
816820
file_history=Histórico
821+
file_view_source=Ver código fuente
822+
file_view_rendered=Ver procesado
817823
file_view_raw=Ver original
818824
file_permalink=Enlace permanente
819825
file_too_large=El archivo es demasiado grande para ser mostrado.
@@ -910,6 +916,8 @@ ext_issues=Incidencias externas
910916
ext_issues.desc=Enlace a un gestor de incidencias externo.
911917

912918
projects=Proyectos
919+
projects.description=Descripción (opcional)
920+
projects.description_placeholder=Descripción
913921
projects.create=Crear Proyecto
914922
projects.title=Título
915923
projects.new=Nuevo proyecto
@@ -1121,10 +1129,13 @@ issues.lock.title=Bloquear conversación sobre esta incidencia.
11211129
issues.unlock.title=Desbloquear conversación sobre esta incidencia.
11221130
issues.comment_on_locked=No puede comentar una incidencia bloqueada.
11231131
issues.tracker=Gestor de tiempo
1132+
issues.start_tracking_short=Iniciar temporizador
11241133
issues.start_tracking=Inicio de seguimiento de tiempo
11251134
issues.start_tracking_history=`ha empezado a trabajar %s`
11261135
issues.tracker_auto_close=El temporizador se detendrá automáticamente cuando se cierre este problema
1136+
issues.stop_tracking=Detener temporizador
11271137
issues.stop_tracking_history=`dejó de trabajar %s`
1138+
issues.cancel_tracking=Descartar
11281139
issues.cancel_tracking_history=`canceló el seguimiento de tiempo %s`
11291140
issues.add_time=Añadir tiempo gastado manualmente
11301141
issues.add_time_short=Añadir tiempo gastado
@@ -1204,6 +1215,7 @@ issues.review.resolve_conversation=Resolver conversación
12041215
issues.review.un_resolve_conversation=Marcar conversación sin resolver
12051216
issues.review.resolved_by=ha marcado esta conversación como resuelta
12061217
issues.assignee.error=No todos los asignados fueron añadidos debido a un error inesperado.
1218+
issues.reference_issue.body=Cuerpo
12071219

12081220
pulls.desc=Activar Pull Requests y revisiones de código.
12091221
pulls.new=Nuevo Pull Request
@@ -2030,6 +2042,7 @@ dashboard.resync_all_sshprincipals.desc=(No es necesario para el servidor SSH in
20302042
dashboard.resync_all_hooks=Resincronizar los hooks de pre-recepción, actualización y post-recepción de todos los repositorios.
20312043
dashboard.reinit_missing_repos=Reiniciar todos los repositorios Git faltantes de los que existen registros
20322044
dashboard.sync_external_users=Sincronizar datos de usuario externo
2045+
dashboard.cleanup_hook_task_table=Limpiar tabla hook_task
20332046
dashboard.server_uptime=Tiempo de actividad del servidor
20342047
dashboard.current_goroutine=Gorutinas actuales
20352048
dashboard.current_memory_usage=Uso de memoria actual
@@ -2180,6 +2193,7 @@ auths.enable_tls=Habilitar cifrado TLS
21802193
auths.skip_tls_verify=Omitir la verificación TLS
21812194
auths.pam_service_name=Nombre del Servicio PAM
21822195
auths.oauth2_provider=Proveedor OAuth2
2196+
auths.oauth2_icon_url=URL de icono
21832197
auths.oauth2_clientID=ID de cliente (clave)
21842198
auths.oauth2_clientSecret=Secreto del cliente
21852199
auths.openIdConnectAutoDiscoveryURL=URL de descubrimiento automático de OpenID Connect

routers/api/v1/repo/file.go

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ func GetRawFile(ctx *context.APIContext) {
4343
// description: filepath of the file to get
4444
// type: string
4545
// required: true
46+
// - name: ref
47+
// in: query
48+
// description: "The name of the commit/branch/tag. Default the repository’s default branch (usually master)"
49+
// type: string
50+
// required: false
4651
// responses:
4752
// 200:
4853
// description: success
@@ -54,7 +59,22 @@ func GetRawFile(ctx *context.APIContext) {
5459
return
5560
}
5661

57-
blob, err := ctx.Repo.Commit.GetBlobByPath(ctx.Repo.TreePath)
62+
commit := ctx.Repo.Commit
63+
64+
if ref := ctx.QueryTrim("ref"); len(ref) > 0 {
65+
var err error
66+
commit, err = ctx.Repo.GitRepo.GetCommit(ref)
67+
if err != nil {
68+
if git.IsErrNotExist(err) {
69+
ctx.NotFound()
70+
} else {
71+
ctx.Error(http.StatusInternalServerError, "GetBlobByPath", err)
72+
}
73+
return
74+
}
75+
}
76+
77+
blob, err := commit.GetBlobByPath(ctx.Repo.TreePath)
5878
if err != nil {
5979
if git.IsErrNotExist(err) {
6080
ctx.NotFound()

templates/repo/issue/view_content/comments.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@
251251
</a>
252252
<span class="text grey">
253253
<a class="author" href="{{.Poster.HomeLink}}">{{.Poster.GetDisplayName}}</a>
254-
{{$.i18n.Tr "repo.issues.delete_branch_at" (.CommitSHA|Escape) $createdStr | Safe}}
254+
{{$.i18n.Tr "repo.issues.delete_branch_at" (.OldRef|Escape) $createdStr | Safe}}
255255
</span>
256256
</div>
257257
{{else if eq .Type 12}}

templates/swagger/v1_json.tmpl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7845,6 +7845,12 @@
78457845
"name": "filepath",
78467846
"in": "path",
78477847
"required": true
7848+
},
7849+
{
7850+
"type": "string",
7851+
"description": "The name of the commit/branch/tag. Default the repository’s default branch (usually master)",
7852+
"name": "ref",
7853+
"in": "query"
78487854
}
78497855
],
78507856
"responses": {

0 commit comments

Comments
 (0)