Format prints the DescribeResult as a string.
(opts *DescribeFormatOptions)
| 190 | |
| 191 | // Format prints the DescribeResult as a string. |
| 192 | func (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. |
| 222 | func (result *DescribeResult) Free() { |