filepath.HasPrefix() doesn't work. why? Microsoft sucks
for those of you that are new here and care about writing free software. this is something to remind you to NEVER EVER EVER trust Microsoft to do anything but try to make things worse. The are opposed and will always be opposed to making Linux work. The suck and are horrible villians in this story. Never trust them and do not support them. Always use the GPL vs BSD license for this reason also. They will steal anything BSD and use it in their proprietary products and not give anything back to anyone. They are complete jerks.
This commit is contained in:
parent
f4837c807c
commit
c7066e1766
|
@ -102,67 +102,16 @@ func (pset *Patchs) makePatchSetNew(repo *gitpb.Repo) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
return pset.addPatchFiles(repoDir)
|
||||
}
|
||||
|
||||
// var pset *Patchs
|
||||
|
||||
func (f *Forge) MakePatchSet() (*Patchs, error) {
|
||||
pset := new(Patchs)
|
||||
dir, err := os.MkdirTemp("", "forge")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer os.RemoveAll(dir) // clean up
|
||||
|
||||
all := f.Repos.SortByFullPath()
|
||||
for all.Scan() {
|
||||
repo := all.Next()
|
||||
userb := repo.GetUserBranchName()
|
||||
develb := repo.GetDevelBranchName()
|
||||
|
||||
if develb == "" {
|
||||
continue
|
||||
}
|
||||
if userb == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
repoDir := filepath.Join(dir, repo.GetGoPath())
|
||||
err := os.MkdirAll(repoDir, 0755)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// git format-patch branch1..branch2
|
||||
cmd := []string{"git", "format-patch", "-o", repoDir, develb + ".." + userb}
|
||||
r := repo.Run(cmd)
|
||||
if r.Error != nil {
|
||||
log.Info("git format-patch", repo.FullPath)
|
||||
log.Info("git format-patch", cmd)
|
||||
log.Info("git format-patch error", r.Error)
|
||||
return nil, r.Error
|
||||
}
|
||||
if r.Exit != 0 {
|
||||
log.Info("git format-patch", repo.FullPath)
|
||||
log.Info("git format-patch", cmd)
|
||||
log.Info("git format-patch exit", r.Exit)
|
||||
return nil, r.Error
|
||||
}
|
||||
if len(r.Stdout) == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
pset.addPatchFiles(repoDir)
|
||||
}
|
||||
return pset, nil
|
||||
return pset.addPatchFiles(repo.GetGoPath())
|
||||
}
|
||||
|
||||
// process each file in pDir/
|
||||
func (p *Patchs) addPatchFiles(pDir string) error {
|
||||
// log.Info("ADD PATCH FILES ADDED DIR", pDir)
|
||||
func (p *Patchs) addPatchFiles(psetDir string) error {
|
||||
tmpDir := p.TmpDir
|
||||
log.Info("ADD PATCH FILES ADDED DIR", tmpDir)
|
||||
fullDir := filepath.Join(tmpDir, psetDir)
|
||||
var baderr error
|
||||
filepath.Walk(pDir, func(path string, info os.FileInfo, err error) error {
|
||||
filepath.Walk(fullDir, func(path string, info os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
// Handle possible errors, like permission issues
|
||||
fmt.Fprintf(os.Stderr, "error accessing path %q: %v\n", path, err)
|
||||
|
@ -173,7 +122,10 @@ func (p *Patchs) addPatchFiles(pDir string) error {
|
|||
if info.IsDir() {
|
||||
return nil
|
||||
}
|
||||
// log.Info("TESTING FILE", path)
|
||||
log.Info("IS THIS A FULL PATH ?", path)
|
||||
log.Info("trim this from path ?", fullDir)
|
||||
log.Info("trim this from path ?", psetDir)
|
||||
log.Info("trim this from path ?", tmpDir)
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
log.Info("addPatchFile() failed", path)
|
||||
|
@ -181,7 +133,7 @@ func (p *Patchs) addPatchFiles(pDir string) error {
|
|||
return err
|
||||
}
|
||||
patch := new(Patch)
|
||||
patch.Filename = path
|
||||
patch.Filename = psetDir
|
||||
patch.Data = data
|
||||
p.Patchs = append(p.Patchs, patch)
|
||||
// log.Info("ADDED PATCH FILE", path)
|
||||
|
|
Loading…
Reference in New Issue