mirror of
https://github.com/go-gitea/gitea
synced 2024-12-30 17:05:55 +01:00
Fix zombie
This commit is contained in:
parent
e323604d78
commit
6696610aea
@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
> Thanks [drone](https://github.com/drone/drone) because this guidelines sheet is forked from its [CONTRIBUTING.md](https://github.com/drone/drone/blob/master/CONTRIBUTING.md).
|
> Thanks [drone](https://github.com/drone/drone) because this guidelines sheet is forked from its [CONTRIBUTING.md](https://github.com/drone/drone/blob/master/CONTRIBUTING.md).
|
||||||
|
|
||||||
**This document is pre^2 release, we're not ready for receiving contribution until v0.5.0 release.**
|
|
||||||
|
|
||||||
Want to hack on Gogs? Awesome! Here are instructions to get you started. They are probably not perfect, please let us know if anything feels wrong or incomplete.
|
Want to hack on Gogs? Awesome! Here are instructions to get you started. They are probably not perfect, please let us know if anything feels wrong or incomplete.
|
||||||
|
|
||||||
## Contribution guidelines
|
## Contribution guidelines
|
||||||
|
@ -67,7 +67,7 @@ func (diff *Diff) NumFiles() int {
|
|||||||
|
|
||||||
const DIFF_HEAD = "diff --git "
|
const DIFF_HEAD = "diff --git "
|
||||||
|
|
||||||
func ParsePatch(reader io.Reader) (*Diff, error) {
|
func ParsePatch(cmd *exec.Cmd, reader io.Reader) (*Diff, error) {
|
||||||
scanner := bufio.NewScanner(reader)
|
scanner := bufio.NewScanner(reader)
|
||||||
var (
|
var (
|
||||||
curFile *DiffFile
|
curFile *DiffFile
|
||||||
@ -168,6 +168,13 @@ func ParsePatch(reader io.Reader) (*Diff, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// In case process became zombie.
|
||||||
|
if !cmd.ProcessState.Exited() {
|
||||||
|
log.Debug("git_diff.ParsePatch: process doesn't exit and now will be killed")
|
||||||
|
if err := cmd.Process.Kill(); err != nil {
|
||||||
|
log.Error("git_diff.ParsePatch: fail to kill zombie process: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
return diff, nil
|
return diff, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,33 +189,23 @@ func GetDiff(repoPath, commitid string) (*Diff, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rd, wr := io.Pipe()
|
||||||
|
var cmd *exec.Cmd
|
||||||
// First commit of repository.
|
// First commit of repository.
|
||||||
if commit.ParentCount() == 0 {
|
if commit.ParentCount() == 0 {
|
||||||
rd, wr := io.Pipe()
|
cmd = exec.Command("git", "show", commitid)
|
||||||
go func() {
|
} else {
|
||||||
cmd := exec.Command("git", "show", commitid)
|
|
||||||
cmd.Dir = repoPath
|
|
||||||
cmd.Stdout = wr
|
|
||||||
cmd.Stdin = os.Stdin
|
|
||||||
cmd.Stderr = os.Stderr
|
|
||||||
cmd.Run()
|
|
||||||
wr.Close()
|
|
||||||
}()
|
|
||||||
defer rd.Close()
|
|
||||||
return ParsePatch(rd)
|
|
||||||
}
|
|
||||||
|
|
||||||
rd, wr := io.Pipe()
|
|
||||||
go func() {
|
|
||||||
c, _ := commit.Parent(0)
|
c, _ := commit.Parent(0)
|
||||||
cmd := exec.Command("git", "diff", c.Id.String(), commitid)
|
cmd = exec.Command("git", "diff", c.Id.String(), commitid)
|
||||||
cmd.Dir = repoPath
|
}
|
||||||
cmd.Stdout = wr
|
cmd.Dir = repoPath
|
||||||
cmd.Stdin = os.Stdin
|
cmd.Stdout = wr
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stdin = os.Stdin
|
||||||
|
cmd.Stderr = os.Stderr
|
||||||
|
go func() {
|
||||||
cmd.Run()
|
cmd.Run()
|
||||||
wr.Close()
|
wr.Close()
|
||||||
}()
|
}()
|
||||||
defer rd.Close()
|
defer rd.Close()
|
||||||
return ParsePatch(rd)
|
return ParsePatch(cmd, rd)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user