gitech

Форк
0
/
schemas_dynamic.go 
38 строк · 858.0 Байт
1
// Copyright 2022 The Gitea Authors. All rights reserved.
2
// SPDX-License-Identifier: MIT
3

4
//go:build !bindata
5

6
package migration
7

8
import (
9
	"io"
10
	"net/url"
11
	"os"
12
	"path"
13
	"path/filepath"
14
)
15

16
func openSchema(s string) (io.ReadCloser, error) {
17
	u, err := url.Parse(s)
18
	if err != nil {
19
		return nil, err
20
	}
21
	basename := path.Base(u.Path)
22
	filename := basename
23
	//
24
	// Schema reference each other within the schemas directory but
25
	// the tests run in the parent directory.
26
	//
27
	if _, err := os.Stat(filename); os.IsNotExist(err) {
28
		filename = filepath.Join("schemas", basename)
29
		//
30
		// Integration tests run from the git root directory, not the
31
		// directory in which the test source is located.
32
		//
33
		if _, err := os.Stat(filename); os.IsNotExist(err) {
34
			filename = filepath.Join("modules/migration/schemas", basename)
35
		}
36
	}
37
	return os.Open(filename)
38
}
39

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.