-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatus.go
40 lines (33 loc) · 800 Bytes
/
status.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package g
func CurrentStatus() (*FfileSet, error) {
// index
idx, err := ReadIndex()
if err != nil {
return nil, err
}
commitSha, err := CurrentCommit()
if err != nil {
return nil, err
}
return Status(idx, commitSha)
}
// Status returns a FfileSet containing all files from commit, index and working directory
// with the corresponding status.
func Status(idx *Index, commitSha Sha) (*FfileSet, error) {
var commitFiles, indexFiles, wtFiles []*FileStatus
var err error
// set commit files
if commitSha.IsSet() {
commitFiles, err = CommittedFiles(commitSha)
if err != nil {
return nil, err
}
}
indexFiles = idx.Files()
// set working tree files
wtFiles, err = Ls(Path())
if err != nil {
return nil, err
}
return NewFfileSet(commitFiles, indexFiles, wtFiles)
}