forked from forgejo/forgejo
Remove SavePatch and generate patches on the fly (#9302)
* Save patches to temporary files * Remove SavePatch and generate patches on the fly * Use ioutil.TempDir * fixup! Use ioutil.TempDir * fixup! fixup! Use ioutil.TempDir * RemoveAll LocalCopyPath() in initIntergrationTest * Default to status checking on PR creation * Remove unnecessary set to StatusChecking * Protect against unable to load repo * Handle conflicts * Restore original conflict setting * In TestPullRequests update status to StatusChecking before running TestPatch
This commit is contained in:
parent
8f16a2c37b
commit
74179d1b5e
16 changed files with 432 additions and 406 deletions
|
@ -6,15 +6,13 @@ package models
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
|
||||
"github.com/unknwon/com"
|
||||
)
|
||||
|
||||
// LocalCopyPath returns the local repository temporary copy path.
|
||||
|
@ -27,11 +25,15 @@ func LocalCopyPath() string {
|
|||
|
||||
// CreateTemporaryPath creates a temporary path
|
||||
func CreateTemporaryPath(prefix string) (string, error) {
|
||||
timeStr := com.ToStr(time.Now().Nanosecond()) // SHOULD USE SOMETHING UNIQUE
|
||||
basePath := path.Join(LocalCopyPath(), prefix+"-"+timeStr+".git")
|
||||
if err := os.MkdirAll(filepath.Dir(basePath), os.ModePerm); err != nil {
|
||||
log.Error("Unable to create temporary directory: %s (%v)", basePath, err)
|
||||
return "", fmt.Errorf("Failed to create dir %s: %v", basePath, err)
|
||||
if err := os.MkdirAll(LocalCopyPath(), os.ModePerm); err != nil {
|
||||
log.Error("Unable to create localcopypath directory: %s (%v)", LocalCopyPath(), err)
|
||||
return "", fmt.Errorf("Failed to create localcopypath directory %s: %v", LocalCopyPath(), err)
|
||||
}
|
||||
basePath, err := ioutil.TempDir(LocalCopyPath(), prefix+".git")
|
||||
if err != nil {
|
||||
log.Error("Unable to create temporary directory: %s-*.git (%v)", prefix, err)
|
||||
return "", fmt.Errorf("Failed to create dir %s-*.git: %v", prefix, err)
|
||||
|
||||
}
|
||||
return basePath, nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue