THIS IS A TEST INSTANCE ONLY! REPOSITORIES CAN BE DELETED AT ANY TIME!

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.

28 lines
860B

  1. // Copyright 2019 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. package integrations
  5. import (
  6. "code.gitea.io/gitea/models"
  7. "code.gitea.io/gitea/modules/repofiles"
  8. api "code.gitea.io/gitea/modules/structs"
  9. )
  10. func createFileInBranch(user *models.User, repo *models.Repository, treePath, branchName string) (*api.FileResponse, error) {
  11. opts := &repofiles.UpdateRepoFileOptions{
  12. OldBranch: branchName,
  13. TreePath: treePath,
  14. Content: "This is a NEW file",
  15. IsNewFile: true,
  16. Author: nil,
  17. Committer: nil,
  18. }
  19. return repofiles.CreateOrUpdateRepoFile(repo, user, opts)
  20. }
  21. func createFile(user *models.User, repo *models.Repository, treePath string) (*api.FileResponse, error) {
  22. return createFileInBranch(user, repo, treePath, repo.DefaultBranch)
  23. }