mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	Fixes 4762 - Content API for Creating, Updating, Deleting Files (#6314)
This commit is contained in:
		
				
					committed by
					
						
						techknowlogick
					
				
			
			
				
	
			
			
			
						parent
						
							059195b127
						
					
				
				
					commit
					2262811e40
				
			@@ -16,7 +16,10 @@ import (
 | 
			
		||||
	"math"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"net/url"
 | 
			
		||||
	"os"
 | 
			
		||||
	"path"
 | 
			
		||||
	"path/filepath"
 | 
			
		||||
	"runtime"
 | 
			
		||||
	"strconv"
 | 
			
		||||
	"strings"
 | 
			
		||||
	"time"
 | 
			
		||||
@@ -603,3 +606,25 @@ func EntryIcon(entry *git.TreeEntry) string {
 | 
			
		||||
 | 
			
		||||
	return "file-text"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// SetupGiteaRoot Sets GITEA_ROOT if it is not already set and returns the value
 | 
			
		||||
func SetupGiteaRoot() string {
 | 
			
		||||
	giteaRoot := os.Getenv("GITEA_ROOT")
 | 
			
		||||
	if giteaRoot == "" {
 | 
			
		||||
		_, filename, _, _ := runtime.Caller(0)
 | 
			
		||||
		giteaRoot = strings.TrimSuffix(filename, "modules/base/tool.go")
 | 
			
		||||
		wd, err := os.Getwd()
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			rel, err := filepath.Rel(giteaRoot, wd)
 | 
			
		||||
			if err != nil && strings.HasPrefix(filepath.ToSlash(rel), "../") {
 | 
			
		||||
				giteaRoot = wd
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		if _, err := os.Stat(filepath.Join(giteaRoot, "gitea")); os.IsNotExist(err) {
 | 
			
		||||
			giteaRoot = ""
 | 
			
		||||
		} else if err := os.Setenv("GITEA_ROOT", giteaRoot); err != nil {
 | 
			
		||||
			giteaRoot = ""
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return giteaRoot
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user