You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
1.0 KiB
30 lines
1.0 KiB
6 years ago
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||
|
// Use of this source code is governed by a MIT-style
|
||
|
// license that can be found in the LICENSE file.
|
||
|
|
||
2 years ago
|
package integration
|
||
6 years ago
|
|
||
|
import (
|
||
3 years ago
|
repo_model "code.gitea.io/gitea/models/repo"
|
||
3 years ago
|
user_model "code.gitea.io/gitea/models/user"
|
||
3 years ago
|
"code.gitea.io/gitea/modules/git"
|
||
6 years ago
|
api "code.gitea.io/gitea/modules/structs"
|
||
3 years ago
|
files_service "code.gitea.io/gitea/services/repository/files"
|
||
6 years ago
|
)
|
||
|
|
||
3 years ago
|
func createFileInBranch(user *user_model.User, repo *repo_model.Repository, treePath, branchName, content string) (*api.FileResponse, error) {
|
||
3 years ago
|
opts := &files_service.UpdateRepoFileOptions{
|
||
6 years ago
|
OldBranch: branchName,
|
||
|
TreePath: treePath,
|
||
4 years ago
|
Content: content,
|
||
6 years ago
|
IsNewFile: true,
|
||
|
Author: nil,
|
||
|
Committer: nil,
|
||
|
}
|
||
3 years ago
|
return files_service.CreateOrUpdateRepoFile(git.DefaultContext, repo, user, opts)
|
||
6 years ago
|
}
|
||
|
|
||
3 years ago
|
func createFile(user *user_model.User, repo *repo_model.Repository, treePath string) (*api.FileResponse, error) {
|
||
4 years ago
|
return createFileInBranch(user, repo, treePath, repo.DefaultBranch, "This is a NEW file")
|
||
6 years ago
|
}
|