Support async gitops
This commit is contained in:
parent
00bc9d4b17
commit
3a1d1c2ce2
@ -4,9 +4,9 @@ A wiki engine.
|
|||||||
## 0.9
|
## 0.9
|
||||||
This is a development branch for 0.9 version. Features I want to implement in this release:
|
This is a development branch for 0.9 version. Features I want to implement in this release:
|
||||||
* [x] Recent changes page.
|
* [x] Recent changes page.
|
||||||
* [ ] Hypha deletion.
|
* [x] Hypha deletion.
|
||||||
* [ ] Hypha renaming.
|
* [ ] Hypha renaming.
|
||||||
* [ ] Support async git ops.
|
* [x] Support async git ops.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
```sh
|
```sh
|
||||||
|
|||||||
@ -99,10 +99,10 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// I pronounce it as [gɪt͡ʃ].
|
// I pronounce it as [gɪt͡ʃ].
|
||||||
|
// gitsh is async-safe, therefore all other git-related functions in this module are too.
|
||||||
func gitsh(args ...string) (out bytes.Buffer, err error) {
|
func gitsh(args ...string) (out bytes.Buffer, err error) {
|
||||||
fmt.Printf("$ %v\n", args)
|
fmt.Printf("$ %v\n", args)
|
||||||
cmd := exec.Command(gitpath, args...)
|
cmd := exec.Command(gitpath, args...)
|
||||||
|
|
||||||
cmd.Dir = util.WikiDir
|
cmd.Dir = util.WikiDir
|
||||||
|
|
||||||
b, err := cmd.CombinedOutput()
|
b, err := cmd.CombinedOutput()
|
||||||
|
|||||||
@ -4,10 +4,14 @@ package history
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"github.com/bouncepaw/mycorrhiza/util"
|
"github.com/bouncepaw/mycorrhiza/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// gitMutex is used for blocking git operations to avoid clashes.
|
||||||
|
var gitMutex = sync.Mutex{}
|
||||||
|
|
||||||
// OpType is the type a history operation has. Callers shall set appropriate optypes when creating history operations.
|
// OpType is the type a history operation has. Callers shall set appropriate optypes when creating history operations.
|
||||||
type OpType int
|
type OpType int
|
||||||
|
|
||||||
@ -31,6 +35,7 @@ type HistoryOp struct {
|
|||||||
|
|
||||||
// Operation is a constructor of a history operation.
|
// Operation is a constructor of a history operation.
|
||||||
func Operation(opType OpType) *HistoryOp {
|
func Operation(opType OpType) *HistoryOp {
|
||||||
|
gitMutex.Lock()
|
||||||
hop := &HistoryOp{
|
hop := &HistoryOp{
|
||||||
Errs: []error{},
|
Errs: []error{},
|
||||||
opType: opType,
|
opType: opType,
|
||||||
@ -75,6 +80,7 @@ func (hop *HistoryOp) Apply() *HistoryOp {
|
|||||||
"--author='"+hop.name+" <"+hop.email+">'",
|
"--author='"+hop.name+" <"+hop.email+">'",
|
||||||
"--message="+hop.userMsg,
|
"--message="+hop.userMsg,
|
||||||
)
|
)
|
||||||
|
gitMutex.Unlock()
|
||||||
return hop
|
return hop
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
Subproject commit ecaa76f841afcb3514b7061eb6708092bc17ee08
|
Subproject commit 2c0e43199ed28f7022a38463a0eec3af3ecb03c9
|
||||||
Loading…
Reference in New Issue
Block a user