-
Notifications
You must be signed in to change notification settings - Fork 6
/
callbacks.go
50 lines (44 loc) · 1.41 KB
/
callbacks.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
41
42
43
44
45
46
47
48
49
50
package svn
/*
#include <svn_repos.h>
#include <svn_compat.h>
#include <svn_io.h>
#include <svn_string.h>
*/
import "C"
import (
"unsafe"
)
// LogEntryReceiverCallback implements svn_repos_get_logs5 callback:
/*
static svn_error_t *
log_entry_receiver(void *baton,
svn_repos_log_entry_t *log_entry,
apr_pool_t *pool)
*/
//export LogEntryReceiverCallback
func LogEntryReceiverCallback(_obj, _entry, _pool unsafe.Pointer) unsafe.Pointer {
baton := (*CommitCollector)(_obj)
entry := (*C.svn_repos_log_entry_t)(_entry)
var author, date, msg *C.char
C.svn_compat_log_revprops_out(&author, &date, &msg, entry.revprops)
commit := Commit{int64(entry.revision), C.GoString(author), C.GoString(date), C.GoString(msg)}
baton.commits = append(baton.commits, commit)
return nil
}
// HistoryReceiverCallback implements svn_repos_get_history2 callback
/* static svn_error_t *
svn_repos_history_func_t(void *baton,
const char *path,
svn_revnum_t *log_entry,
apr_pool_t *pool)
*/
//export HistoryReceiverCallback
func HistoryReceiverCallback(_obj unsafe.Pointer, path *C.char, revision C.svn_revnum_t, _pool unsafe.Pointer) *C.svn_error_t {
baton := (*CommitCollector)(_obj)
baton.revisions = append(baton.revisions, int64(revision))
if len(baton.revisions) >= baton.limit {
return C.svn_error_create(C.SVN_ERR_CEASE_INVOCATION, nil, nil)
}
return nil
}