MCPcopy Create free account
hub / github.com/libgit2/git2go / Format

Method Format

describe.go:192–219  ·  view source on GitHub ↗

Format prints the DescribeResult as a string.

(opts *DescribeFormatOptions)

Source from the content-addressed store, hash-verified

190
191// Format prints the DescribeResult as a string.
192func (result *DescribeResult) Format(opts *DescribeFormatOptions) (string, error) {
193 resultBuf := C.git_buf{}
194
195 var cFormatOpts *C.git_describe_format_options
196 if opts != nil {
197 cDirtySuffix := C.CString(opts.DirtySuffix)
198 defer C.free(unsafe.Pointer(cDirtySuffix))
199
200 cFormatOpts = &C.git_describe_format_options{
201 version: C.GIT_DESCRIBE_FORMAT_OPTIONS_VERSION,
202 abbreviated_size: C.uint(opts.AbbreviatedSize),
203 always_use_long_format: cbool(opts.AlwaysUseLongFormat),
204 dirty_suffix: cDirtySuffix,
205 }
206 }
207
208 runtime.LockOSThread()
209 defer runtime.UnlockOSThread()
210
211 ecode := C.git_describe_format(&resultBuf, result.ptr, cFormatOpts)
212 runtime.KeepAlive(result)
213 if ecode < 0 {
214 return "", MakeGitError(ecode)
215 }
216 defer C.git_buf_dispose(&resultBuf)
217
218 return C.GoString(resultBuf.ptr), nil
219}
220
221// Free cleans up the C reference.
222func (result *DescribeResult) Free() {

Callers 1

TestDescribeCommitFunction · 0.80

Calls 3

cboolFunction · 0.85
MakeGitErrorFunction · 0.85
freeMethod · 0.80

Tested by 1

TestDescribeCommitFunction · 0.64