id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
154,300 | salsaflow/salsaflow | Godeps/_workspace/src/golang.org/x/text/unicode/norm/composition.go | appendRune | func (rb *reorderBuffer) appendRune(r rune) {
bn := rb.nbyte
sz := utf8.EncodeRune(rb.byte[bn:], rune(r))
rb.nbyte += utf8.UTFMax
rb.rune[rb.nrune] = Properties{pos: bn, size: uint8(sz)}
rb.nrune++
} | go | func (rb *reorderBuffer) appendRune(r rune) {
bn := rb.nbyte
sz := utf8.EncodeRune(rb.byte[bn:], rune(r))
rb.nbyte += utf8.UTFMax
rb.rune[rb.nrune] = Properties{pos: bn, size: uint8(sz)}
rb.nrune++
} | [
"func",
"(",
"rb",
"*",
"reorderBuffer",
")",
"appendRune",
"(",
"r",
"rune",
")",
"{",
"bn",
":=",
"rb",
".",
"nbyte",
"\n",
"sz",
":=",
"utf8",
".",
"EncodeRune",
"(",
"rb",
".",
"byte",
"[",
"bn",
":",
"]",
",",
"rune",
"(",
"r",
")",
")",
... | // appendRune inserts a rune at the end of the buffer. It is used for Hangul. | [
"appendRune",
"inserts",
"a",
"rune",
"at",
"the",
"end",
"of",
"the",
"buffer",
".",
"It",
"is",
"used",
"for",
"Hangul",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/Godeps/_workspace/src/golang.org/x/text/unicode/norm/composition.go#L284-L290 |
154,301 | salsaflow/salsaflow | Godeps/_workspace/src/golang.org/x/text/unicode/norm/composition.go | assignRune | func (rb *reorderBuffer) assignRune(pos int, r rune) {
bn := rb.rune[pos].pos
sz := utf8.EncodeRune(rb.byte[bn:], rune(r))
rb.rune[pos] = Properties{pos: bn, size: uint8(sz)}
} | go | func (rb *reorderBuffer) assignRune(pos int, r rune) {
bn := rb.rune[pos].pos
sz := utf8.EncodeRune(rb.byte[bn:], rune(r))
rb.rune[pos] = Properties{pos: bn, size: uint8(sz)}
} | [
"func",
"(",
"rb",
"*",
"reorderBuffer",
")",
"assignRune",
"(",
"pos",
"int",
",",
"r",
"rune",
")",
"{",
"bn",
":=",
"rb",
".",
"rune",
"[",
"pos",
"]",
".",
"pos",
"\n",
"sz",
":=",
"utf8",
".",
"EncodeRune",
"(",
"rb",
".",
"byte",
"[",
"bn... | // assignRune sets a rune at position pos. It is used for Hangul and recomposition. | [
"assignRune",
"sets",
"a",
"rune",
"at",
"position",
"pos",
".",
"It",
"is",
"used",
"for",
"Hangul",
"and",
"recomposition",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/Godeps/_workspace/src/golang.org/x/text/unicode/norm/composition.go#L293-L297 |
154,302 | salsaflow/salsaflow | Godeps/_workspace/src/golang.org/x/text/unicode/norm/composition.go | runeAt | func (rb *reorderBuffer) runeAt(n int) rune {
inf := rb.rune[n]
r, _ := utf8.DecodeRune(rb.byte[inf.pos : inf.pos+inf.size])
return r
} | go | func (rb *reorderBuffer) runeAt(n int) rune {
inf := rb.rune[n]
r, _ := utf8.DecodeRune(rb.byte[inf.pos : inf.pos+inf.size])
return r
} | [
"func",
"(",
"rb",
"*",
"reorderBuffer",
")",
"runeAt",
"(",
"n",
"int",
")",
"rune",
"{",
"inf",
":=",
"rb",
".",
"rune",
"[",
"n",
"]",
"\n",
"r",
",",
"_",
":=",
"utf8",
".",
"DecodeRune",
"(",
"rb",
".",
"byte",
"[",
"inf",
".",
"pos",
":... | // runeAt returns the rune at position n. It is used for Hangul and recomposition. | [
"runeAt",
"returns",
"the",
"rune",
"at",
"position",
"n",
".",
"It",
"is",
"used",
"for",
"Hangul",
"and",
"recomposition",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/Godeps/_workspace/src/golang.org/x/text/unicode/norm/composition.go#L300-L304 |
154,303 | salsaflow/salsaflow | Godeps/_workspace/src/golang.org/x/text/unicode/norm/composition.go | bytesAt | func (rb *reorderBuffer) bytesAt(n int) []byte {
inf := rb.rune[n]
return rb.byte[inf.pos : int(inf.pos)+int(inf.size)]
} | go | func (rb *reorderBuffer) bytesAt(n int) []byte {
inf := rb.rune[n]
return rb.byte[inf.pos : int(inf.pos)+int(inf.size)]
} | [
"func",
"(",
"rb",
"*",
"reorderBuffer",
")",
"bytesAt",
"(",
"n",
"int",
")",
"[",
"]",
"byte",
"{",
"inf",
":=",
"rb",
".",
"rune",
"[",
"n",
"]",
"\n",
"return",
"rb",
".",
"byte",
"[",
"inf",
".",
"pos",
":",
"int",
"(",
"inf",
".",
"pos"... | // bytesAt returns the UTF-8 encoding of the rune at position n.
// It is used for Hangul and recomposition. | [
"bytesAt",
"returns",
"the",
"UTF",
"-",
"8",
"encoding",
"of",
"the",
"rune",
"at",
"position",
"n",
".",
"It",
"is",
"used",
"for",
"Hangul",
"and",
"recomposition",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/Godeps/_workspace/src/golang.org/x/text/unicode/norm/composition.go#L308-L311 |
154,304 | salsaflow/salsaflow | Godeps/_workspace/src/golang.org/x/text/unicode/norm/composition.go | compose | func (rb *reorderBuffer) compose() {
// UAX #15, section X5 , including Corrigendum #5
// "In any character sequence beginning with starter S, a character C is
// blocked from S if and only if there is some character B between S
// and C, and either B is a starter or it has the same or higher
// combining class as C."
bn := rb.nrune
if bn == 0 {
return
}
k := 1
b := rb.rune[:]
for s, i := 0, 1; i < bn; i++ {
if isJamoVT(rb.bytesAt(i)) {
// Redo from start in Hangul mode. Necessary to support
// U+320E..U+321E in NFKC mode.
rb.combineHangul(s, i, k)
return
}
ii := b[i]
// We can only use combineForward as a filter if we later
// get the info for the combined character. This is more
// expensive than using the filter. Using combinesBackward()
// is safe.
if ii.combinesBackward() {
cccB := b[k-1].ccc
cccC := ii.ccc
blocked := false // b[i] blocked by starter or greater or equal CCC?
if cccB == 0 {
s = k - 1
} else {
blocked = s != k-1 && cccB >= cccC
}
if !blocked {
combined := combine(rb.runeAt(s), rb.runeAt(i))
if combined != 0 {
rb.assignRune(s, combined)
continue
}
}
}
b[k] = b[i]
k++
}
rb.nrune = k
} | go | func (rb *reorderBuffer) compose() {
// UAX #15, section X5 , including Corrigendum #5
// "In any character sequence beginning with starter S, a character C is
// blocked from S if and only if there is some character B between S
// and C, and either B is a starter or it has the same or higher
// combining class as C."
bn := rb.nrune
if bn == 0 {
return
}
k := 1
b := rb.rune[:]
for s, i := 0, 1; i < bn; i++ {
if isJamoVT(rb.bytesAt(i)) {
// Redo from start in Hangul mode. Necessary to support
// U+320E..U+321E in NFKC mode.
rb.combineHangul(s, i, k)
return
}
ii := b[i]
// We can only use combineForward as a filter if we later
// get the info for the combined character. This is more
// expensive than using the filter. Using combinesBackward()
// is safe.
if ii.combinesBackward() {
cccB := b[k-1].ccc
cccC := ii.ccc
blocked := false // b[i] blocked by starter or greater or equal CCC?
if cccB == 0 {
s = k - 1
} else {
blocked = s != k-1 && cccB >= cccC
}
if !blocked {
combined := combine(rb.runeAt(s), rb.runeAt(i))
if combined != 0 {
rb.assignRune(s, combined)
continue
}
}
}
b[k] = b[i]
k++
}
rb.nrune = k
} | [
"func",
"(",
"rb",
"*",
"reorderBuffer",
")",
"compose",
"(",
")",
"{",
"// UAX #15, section X5 , including Corrigendum #5",
"// \"In any character sequence beginning with starter S, a character C is",
"// blocked from S if and only if there is some character B between S",
"// and C, and... | // compose recombines the runes in the buffer.
// It should only be used to recompose a single segment, as it will not
// handle alternations between Hangul and non-Hangul characters correctly. | [
"compose",
"recombines",
"the",
"runes",
"in",
"the",
"buffer",
".",
"It",
"should",
"only",
"be",
"used",
"to",
"recompose",
"a",
"single",
"segment",
"as",
"it",
"will",
"not",
"handle",
"alternations",
"between",
"Hangul",
"and",
"non",
"-",
"Hangul",
"... | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/Godeps/_workspace/src/golang.org/x/text/unicode/norm/composition.go#L469-L514 |
154,305 | salsaflow/salsaflow | Godeps/_workspace/src/golang.org/x/text/transform/transform.go | NewReader | func NewReader(r io.Reader, t Transformer) *Reader {
t.Reset()
return &Reader{
r: r,
t: t,
dst: make([]byte, defaultBufSize),
src: make([]byte, defaultBufSize),
}
} | go | func NewReader(r io.Reader, t Transformer) *Reader {
t.Reset()
return &Reader{
r: r,
t: t,
dst: make([]byte, defaultBufSize),
src: make([]byte, defaultBufSize),
}
} | [
"func",
"NewReader",
"(",
"r",
"io",
".",
"Reader",
",",
"t",
"Transformer",
")",
"*",
"Reader",
"{",
"t",
".",
"Reset",
"(",
")",
"\n",
"return",
"&",
"Reader",
"{",
"r",
":",
"r",
",",
"t",
":",
"t",
",",
"dst",
":",
"make",
"(",
"[",
"]",
... | // NewReader returns a new Reader that wraps r by transforming the bytes read
// via t. It calls Reset on t. | [
"NewReader",
"returns",
"a",
"new",
"Reader",
"that",
"wraps",
"r",
"by",
"transforming",
"the",
"bytes",
"read",
"via",
"t",
".",
"It",
"calls",
"Reset",
"on",
"t",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/Godeps/_workspace/src/golang.org/x/text/transform/transform.go#L95-L103 |
154,306 | salsaflow/salsaflow | Godeps/_workspace/src/golang.org/x/text/transform/transform.go | NewWriter | func NewWriter(w io.Writer, t Transformer) *Writer {
t.Reset()
return &Writer{
w: w,
t: t,
dst: make([]byte, defaultBufSize),
src: make([]byte, defaultBufSize),
}
} | go | func NewWriter(w io.Writer, t Transformer) *Writer {
t.Reset()
return &Writer{
w: w,
t: t,
dst: make([]byte, defaultBufSize),
src: make([]byte, defaultBufSize),
}
} | [
"func",
"NewWriter",
"(",
"w",
"io",
".",
"Writer",
",",
"t",
"Transformer",
")",
"*",
"Writer",
"{",
"t",
".",
"Reset",
"(",
")",
"\n",
"return",
"&",
"Writer",
"{",
"w",
":",
"w",
",",
"t",
":",
"t",
",",
"dst",
":",
"make",
"(",
"[",
"]",
... | // NewWriter returns a new Writer that wraps w by transforming the bytes written
// via t. It calls Reset on t. | [
"NewWriter",
"returns",
"a",
"new",
"Writer",
"that",
"wraps",
"w",
"by",
"transforming",
"the",
"bytes",
"written",
"via",
"t",
".",
"It",
"calls",
"Reset",
"on",
"t",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/Godeps/_workspace/src/golang.org/x/text/transform/transform.go#L182-L190 |
154,307 | salsaflow/salsaflow | Godeps/_workspace/src/golang.org/x/text/transform/transform.go | Write | func (w *Writer) Write(data []byte) (n int, err error) {
src := data
if w.n > 0 {
// Append bytes from data to the last remainder.
// TODO: limit the amount copied on first try.
n = copy(w.src[w.n:], data)
w.n += n
src = w.src[:w.n]
}
for {
nDst, nSrc, err := w.t.Transform(w.dst, src, false)
if _, werr := w.w.Write(w.dst[:nDst]); werr != nil {
return n, werr
}
src = src[nSrc:]
if w.n > 0 && len(src) <= n {
// Enough bytes from w.src have been consumed. We make src point
// to data instead to reduce the copying.
w.n = 0
n -= len(src)
src = data[n:]
if n < len(data) && (err == nil || err == ErrShortSrc) {
continue
}
} else {
n += nSrc
}
switch {
case err == ErrShortDst && (nDst > 0 || nSrc > 0):
case err == ErrShortSrc && len(src) < len(w.src):
m := copy(w.src, src)
// If w.n > 0, bytes from data were already copied to w.src and n
// was already set to the number of bytes consumed.
if w.n == 0 {
n += m
}
w.n = m
return n, nil
case err == nil && w.n > 0:
return n, errInconsistentByteCount
default:
return n, err
}
}
} | go | func (w *Writer) Write(data []byte) (n int, err error) {
src := data
if w.n > 0 {
// Append bytes from data to the last remainder.
// TODO: limit the amount copied on first try.
n = copy(w.src[w.n:], data)
w.n += n
src = w.src[:w.n]
}
for {
nDst, nSrc, err := w.t.Transform(w.dst, src, false)
if _, werr := w.w.Write(w.dst[:nDst]); werr != nil {
return n, werr
}
src = src[nSrc:]
if w.n > 0 && len(src) <= n {
// Enough bytes from w.src have been consumed. We make src point
// to data instead to reduce the copying.
w.n = 0
n -= len(src)
src = data[n:]
if n < len(data) && (err == nil || err == ErrShortSrc) {
continue
}
} else {
n += nSrc
}
switch {
case err == ErrShortDst && (nDst > 0 || nSrc > 0):
case err == ErrShortSrc && len(src) < len(w.src):
m := copy(w.src, src)
// If w.n > 0, bytes from data were already copied to w.src and n
// was already set to the number of bytes consumed.
if w.n == 0 {
n += m
}
w.n = m
return n, nil
case err == nil && w.n > 0:
return n, errInconsistentByteCount
default:
return n, err
}
}
} | [
"func",
"(",
"w",
"*",
"Writer",
")",
"Write",
"(",
"data",
"[",
"]",
"byte",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"src",
":=",
"data",
"\n",
"if",
"w",
".",
"n",
">",
"0",
"{",
"// Append bytes from data to the last remainder.",
"// ... | // Write implements the io.Writer interface. If there are not enough
// bytes available to complete a Transform, the bytes will be buffered
// for the next write. Call Close to convert the remaining bytes. | [
"Write",
"implements",
"the",
"io",
".",
"Writer",
"interface",
".",
"If",
"there",
"are",
"not",
"enough",
"bytes",
"available",
"to",
"complete",
"a",
"Transform",
"the",
"bytes",
"will",
"be",
"buffered",
"for",
"the",
"next",
"write",
".",
"Call",
"Clo... | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/Godeps/_workspace/src/golang.org/x/text/transform/transform.go#L195-L239 |
154,308 | salsaflow/salsaflow | Godeps/_workspace/src/golang.org/x/text/transform/transform.go | Chain | func Chain(t ...Transformer) Transformer {
if len(t) == 0 {
return nop{}
}
c := &chain{link: make([]link, len(t)+1)}
for i, tt := range t {
c.link[i].t = tt
}
// Allocate intermediate buffers.
b := make([][defaultBufSize]byte, len(t)-1)
for i := range b {
c.link[i+1].b = b[i][:]
}
return c
} | go | func Chain(t ...Transformer) Transformer {
if len(t) == 0 {
return nop{}
}
c := &chain{link: make([]link, len(t)+1)}
for i, tt := range t {
c.link[i].t = tt
}
// Allocate intermediate buffers.
b := make([][defaultBufSize]byte, len(t)-1)
for i := range b {
c.link[i+1].b = b[i][:]
}
return c
} | [
"func",
"Chain",
"(",
"t",
"...",
"Transformer",
")",
"Transformer",
"{",
"if",
"len",
"(",
"t",
")",
"==",
"0",
"{",
"return",
"nop",
"{",
"}",
"\n",
"}",
"\n",
"c",
":=",
"&",
"chain",
"{",
"link",
":",
"make",
"(",
"[",
"]",
"link",
",",
"... | // Chain returns a Transformer that applies t in sequence. | [
"Chain",
"returns",
"a",
"Transformer",
"that",
"applies",
"t",
"in",
"sequence",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/Godeps/_workspace/src/golang.org/x/text/transform/transform.go#L323-L337 |
154,309 | salsaflow/salsaflow | Godeps/_workspace/src/golang.org/x/text/transform/transform.go | Reset | func (c *chain) Reset() {
for i, l := range c.link {
if l.t != nil {
l.t.Reset()
}
c.link[i].p, c.link[i].n = 0, 0
}
} | go | func (c *chain) Reset() {
for i, l := range c.link {
if l.t != nil {
l.t.Reset()
}
c.link[i].p, c.link[i].n = 0, 0
}
} | [
"func",
"(",
"c",
"*",
"chain",
")",
"Reset",
"(",
")",
"{",
"for",
"i",
",",
"l",
":=",
"range",
"c",
".",
"link",
"{",
"if",
"l",
".",
"t",
"!=",
"nil",
"{",
"l",
".",
"t",
".",
"Reset",
"(",
")",
"\n",
"}",
"\n",
"c",
".",
"link",
"[... | // Reset resets the state of Chain. It calls Reset on all the Transformers. | [
"Reset",
"resets",
"the",
"state",
"of",
"Chain",
".",
"It",
"calls",
"Reset",
"on",
"all",
"the",
"Transformers",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/Godeps/_workspace/src/golang.org/x/text/transform/transform.go#L340-L347 |
154,310 | salsaflow/salsaflow | Godeps/_workspace/src/golang.org/x/text/transform/transform.go | Transform | func (c *chain) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err error) {
// Set up src and dst in the chain.
srcL := &c.link[0]
dstL := &c.link[len(c.link)-1]
srcL.b, srcL.p, srcL.n = src, 0, len(src)
dstL.b, dstL.n = dst, 0
var lastFull, needProgress bool // for detecting progress
// i is the index of the next Transformer to apply, for i in [low, high].
// low is the lowest index for which c.link[low] may still produce bytes.
// high is the highest index for which c.link[high] has a Transformer.
// The error returned by Transform determines whether to increase or
// decrease i. We try to completely fill a buffer before converting it.
for low, i, high := c.errStart, c.errStart, len(c.link)-2; low <= i && i <= high; {
in, out := &c.link[i], &c.link[i+1]
nDst, nSrc, err0 := in.t.Transform(out.dst(), in.src(), atEOF && low == i)
out.n += nDst
in.p += nSrc
if i > 0 && in.p == in.n {
in.p, in.n = 0, 0
}
needProgress, lastFull = lastFull, false
switch err0 {
case ErrShortDst:
// Process the destination buffer next. Return if we are already
// at the high index.
if i == high {
return dstL.n, srcL.p, ErrShortDst
}
if out.n != 0 {
i++
// If the Transformer at the next index is not able to process any
// source bytes there is nothing that can be done to make progress
// and the bytes will remain unprocessed. lastFull is used to
// detect this and break out of the loop with a fatal error.
lastFull = true
continue
}
// The destination buffer was too small, but is completely empty.
// Return a fatal error as this transformation can never complete.
c.fatalError(i, errShortInternal)
case ErrShortSrc:
if i == 0 {
// Save ErrShortSrc in err. All other errors take precedence.
err = ErrShortSrc
break
}
// Source bytes were depleted before filling up the destination buffer.
// Verify we made some progress, move the remaining bytes to the errStart
// and try to get more source bytes.
if needProgress && nSrc == 0 || in.n-in.p == len(in.b) {
// There were not enough source bytes to proceed while the source
// buffer cannot hold any more bytes. Return a fatal error as this
// transformation can never complete.
c.fatalError(i, errShortInternal)
break
}
// in.b is an internal buffer and we can make progress.
in.p, in.n = 0, copy(in.b, in.src())
fallthrough
case nil:
// if i == low, we have depleted the bytes at index i or any lower levels.
// In that case we increase low and i. In all other cases we decrease i to
// fetch more bytes before proceeding to the next index.
if i > low {
i--
continue
}
default:
c.fatalError(i, err0)
}
// Exhausted level low or fatal error: increase low and continue
// to process the bytes accepted so far.
i++
low = i
}
// If c.errStart > 0, this means we found a fatal error. We will clear
// all upstream buffers. At this point, no more progress can be made
// downstream, as Transform would have bailed while handling ErrShortDst.
if c.errStart > 0 {
for i := 1; i < c.errStart; i++ {
c.link[i].p, c.link[i].n = 0, 0
}
err, c.errStart, c.err = c.err, 0, nil
}
return dstL.n, srcL.p, err
} | go | func (c *chain) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err error) {
// Set up src and dst in the chain.
srcL := &c.link[0]
dstL := &c.link[len(c.link)-1]
srcL.b, srcL.p, srcL.n = src, 0, len(src)
dstL.b, dstL.n = dst, 0
var lastFull, needProgress bool // for detecting progress
// i is the index of the next Transformer to apply, for i in [low, high].
// low is the lowest index for which c.link[low] may still produce bytes.
// high is the highest index for which c.link[high] has a Transformer.
// The error returned by Transform determines whether to increase or
// decrease i. We try to completely fill a buffer before converting it.
for low, i, high := c.errStart, c.errStart, len(c.link)-2; low <= i && i <= high; {
in, out := &c.link[i], &c.link[i+1]
nDst, nSrc, err0 := in.t.Transform(out.dst(), in.src(), atEOF && low == i)
out.n += nDst
in.p += nSrc
if i > 0 && in.p == in.n {
in.p, in.n = 0, 0
}
needProgress, lastFull = lastFull, false
switch err0 {
case ErrShortDst:
// Process the destination buffer next. Return if we are already
// at the high index.
if i == high {
return dstL.n, srcL.p, ErrShortDst
}
if out.n != 0 {
i++
// If the Transformer at the next index is not able to process any
// source bytes there is nothing that can be done to make progress
// and the bytes will remain unprocessed. lastFull is used to
// detect this and break out of the loop with a fatal error.
lastFull = true
continue
}
// The destination buffer was too small, but is completely empty.
// Return a fatal error as this transformation can never complete.
c.fatalError(i, errShortInternal)
case ErrShortSrc:
if i == 0 {
// Save ErrShortSrc in err. All other errors take precedence.
err = ErrShortSrc
break
}
// Source bytes were depleted before filling up the destination buffer.
// Verify we made some progress, move the remaining bytes to the errStart
// and try to get more source bytes.
if needProgress && nSrc == 0 || in.n-in.p == len(in.b) {
// There were not enough source bytes to proceed while the source
// buffer cannot hold any more bytes. Return a fatal error as this
// transformation can never complete.
c.fatalError(i, errShortInternal)
break
}
// in.b is an internal buffer and we can make progress.
in.p, in.n = 0, copy(in.b, in.src())
fallthrough
case nil:
// if i == low, we have depleted the bytes at index i or any lower levels.
// In that case we increase low and i. In all other cases we decrease i to
// fetch more bytes before proceeding to the next index.
if i > low {
i--
continue
}
default:
c.fatalError(i, err0)
}
// Exhausted level low or fatal error: increase low and continue
// to process the bytes accepted so far.
i++
low = i
}
// If c.errStart > 0, this means we found a fatal error. We will clear
// all upstream buffers. At this point, no more progress can be made
// downstream, as Transform would have bailed while handling ErrShortDst.
if c.errStart > 0 {
for i := 1; i < c.errStart; i++ {
c.link[i].p, c.link[i].n = 0, 0
}
err, c.errStart, c.err = c.err, 0, nil
}
return dstL.n, srcL.p, err
} | [
"func",
"(",
"c",
"*",
"chain",
")",
"Transform",
"(",
"dst",
",",
"src",
"[",
"]",
"byte",
",",
"atEOF",
"bool",
")",
"(",
"nDst",
",",
"nSrc",
"int",
",",
"err",
"error",
")",
"{",
"// Set up src and dst in the chain.",
"srcL",
":=",
"&",
"c",
".",... | // Transform applies the transformers of c in sequence. | [
"Transform",
"applies",
"the",
"transformers",
"of",
"c",
"in",
"sequence",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/Godeps/_workspace/src/golang.org/x/text/transform/transform.go#L350-L437 |
154,311 | salsaflow/salsaflow | Godeps/_workspace/src/golang.org/x/text/transform/transform.go | Transform | func (t removeF) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err error) {
for r, sz := rune(0), 0; len(src) > 0; src = src[sz:] {
if r = rune(src[0]); r < utf8.RuneSelf {
sz = 1
} else {
r, sz = utf8.DecodeRune(src)
if sz == 1 {
// Invalid rune.
if !atEOF && !utf8.FullRune(src) {
err = ErrShortSrc
break
}
// We replace illegal bytes with RuneError. Not doing so might
// otherwise turn a sequence of invalid UTF-8 into valid UTF-8.
// The resulting byte sequence may subsequently contain runes
// for which t(r) is true that were passed unnoticed.
if !t(r) {
if nDst+3 > len(dst) {
err = ErrShortDst
break
}
nDst += copy(dst[nDst:], "\uFFFD")
}
nSrc++
continue
}
}
if !t(r) {
if nDst+sz > len(dst) {
err = ErrShortDst
break
}
nDst += copy(dst[nDst:], src[:sz])
}
nSrc += sz
}
return
} | go | func (t removeF) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err error) {
for r, sz := rune(0), 0; len(src) > 0; src = src[sz:] {
if r = rune(src[0]); r < utf8.RuneSelf {
sz = 1
} else {
r, sz = utf8.DecodeRune(src)
if sz == 1 {
// Invalid rune.
if !atEOF && !utf8.FullRune(src) {
err = ErrShortSrc
break
}
// We replace illegal bytes with RuneError. Not doing so might
// otherwise turn a sequence of invalid UTF-8 into valid UTF-8.
// The resulting byte sequence may subsequently contain runes
// for which t(r) is true that were passed unnoticed.
if !t(r) {
if nDst+3 > len(dst) {
err = ErrShortDst
break
}
nDst += copy(dst[nDst:], "\uFFFD")
}
nSrc++
continue
}
}
if !t(r) {
if nDst+sz > len(dst) {
err = ErrShortDst
break
}
nDst += copy(dst[nDst:], src[:sz])
}
nSrc += sz
}
return
} | [
"func",
"(",
"t",
"removeF",
")",
"Transform",
"(",
"dst",
",",
"src",
"[",
"]",
"byte",
",",
"atEOF",
"bool",
")",
"(",
"nDst",
",",
"nSrc",
"int",
",",
"err",
"error",
")",
"{",
"for",
"r",
",",
"sz",
":=",
"rune",
"(",
"0",
")",
",",
"0",
... | // Transform implements the Transformer interface. | [
"Transform",
"implements",
"the",
"Transformer",
"interface",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/Godeps/_workspace/src/golang.org/x/text/transform/transform.go#L450-L490 |
154,312 | alicebob/alac | alac.go | New | func New() (*Alac, error) {
a := create_alac(16, 2)
if a == nil {
return nil, fmt.Errorf("can't create alac. No idea why, though")
}
// TODO: fmtp stuff
// fmtp: 96 352 0 16 40 10 14 2 255 0 0 44100
a.setinfo_max_samples_per_frame = 352 // frame_size;
a.setinfo_7a = 0 // fmtp[2];
a.setinfo_sample_size = 16 // sample_size;
a.setinfo_rice_historymult = 40 // fmtp[4];
a.setinfo_rice_initialhistory = 10 // fmtp[5];
a.setinfo_rice_kmodifier = 14 // fmtp[6];
a.setinfo_7f = 2 // fmtp[7];
a.setinfo_80 = 255 // fmtp[8];
a.setinfo_82 = 0 // fmtp[9];
a.setinfo_86 = 0 // fmtp[10];
a.setinfo_8a_rate = 44100 // fmtp[11];
a.allocateBuffers()
return a, nil
} | go | func New() (*Alac, error) {
a := create_alac(16, 2)
if a == nil {
return nil, fmt.Errorf("can't create alac. No idea why, though")
}
// TODO: fmtp stuff
// fmtp: 96 352 0 16 40 10 14 2 255 0 0 44100
a.setinfo_max_samples_per_frame = 352 // frame_size;
a.setinfo_7a = 0 // fmtp[2];
a.setinfo_sample_size = 16 // sample_size;
a.setinfo_rice_historymult = 40 // fmtp[4];
a.setinfo_rice_initialhistory = 10 // fmtp[5];
a.setinfo_rice_kmodifier = 14 // fmtp[6];
a.setinfo_7f = 2 // fmtp[7];
a.setinfo_80 = 255 // fmtp[8];
a.setinfo_82 = 0 // fmtp[9];
a.setinfo_86 = 0 // fmtp[10];
a.setinfo_8a_rate = 44100 // fmtp[11];
a.allocateBuffers()
return a, nil
} | [
"func",
"New",
"(",
")",
"(",
"*",
"Alac",
",",
"error",
")",
"{",
"a",
":=",
"create_alac",
"(",
"16",
",",
"2",
")",
"\n",
"if",
"a",
"==",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"//... | // New alac decoder. Sample size 16, 2 chan! | [
"New",
"alac",
"decoder",
".",
"Sample",
"size",
"16",
"2",
"chan!"
] | 838a288e23c9bc47b04112f3bb68a5537ce0c092 | https://github.com/alicebob/alac/blob/838a288e23c9bc47b04112f3bb68a5537ce0c092/alac.go#L9-L30 |
154,313 | salsaflow/salsaflow | Godeps/_workspace/src/golang.org/x/text/unicode/norm/forminfo.go | BoundaryBefore | func (p Properties) BoundaryBefore() bool {
if p.ccc == 0 && !p.combinesBackward() {
return true
}
// We assume that the CCC of the first character in a decomposition
// is always non-zero if different from info.ccc and that we can return
// false at this point. This is verified by maketables.
return false
} | go | func (p Properties) BoundaryBefore() bool {
if p.ccc == 0 && !p.combinesBackward() {
return true
}
// We assume that the CCC of the first character in a decomposition
// is always non-zero if different from info.ccc and that we can return
// false at this point. This is verified by maketables.
return false
} | [
"func",
"(",
"p",
"Properties",
")",
"BoundaryBefore",
"(",
")",
"bool",
"{",
"if",
"p",
".",
"ccc",
"==",
"0",
"&&",
"!",
"p",
".",
"combinesBackward",
"(",
")",
"{",
"return",
"true",
"\n",
"}",
"\n",
"// We assume that the CCC of the first character in a ... | // We do not distinguish between boundaries for NFC, NFD, etc. to avoid
// unexpected behavior for the user. For example, in NFD, there is a boundary
// after 'a'. However, 'a' might combine with modifiers, so from the application's
// perspective it is not a good boundary. We will therefore always use the
// boundaries for the combining variants.
// BoundaryBefore returns true if this rune starts a new segment and
// cannot combine with any rune on the left. | [
"We",
"do",
"not",
"distinguish",
"between",
"boundaries",
"for",
"NFC",
"NFD",
"etc",
".",
"to",
"avoid",
"unexpected",
"behavior",
"for",
"the",
"user",
".",
"For",
"example",
"in",
"NFD",
"there",
"is",
"a",
"boundary",
"after",
"a",
".",
"However",
"... | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/Godeps/_workspace/src/golang.org/x/text/unicode/norm/forminfo.go#L90-L98 |
154,314 | salsaflow/salsaflow | Godeps/_workspace/src/golang.org/x/text/unicode/norm/forminfo.go | Decomposition | func (p Properties) Decomposition() []byte {
// TODO: create the decomposition for Hangul?
if p.index == 0 {
return nil
}
i := p.index
n := decomps[i] & headerLenMask
i++
return decomps[i : i+uint16(n)]
} | go | func (p Properties) Decomposition() []byte {
// TODO: create the decomposition for Hangul?
if p.index == 0 {
return nil
}
i := p.index
n := decomps[i] & headerLenMask
i++
return decomps[i : i+uint16(n)]
} | [
"func",
"(",
"p",
"Properties",
")",
"Decomposition",
"(",
")",
"[",
"]",
"byte",
"{",
"// TODO: create the decomposition for Hangul?",
"if",
"p",
".",
"index",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"i",
":=",
"p",
".",
"index",
"\n",
"n",
... | // Decomposition returns the decomposition for the underlying rune
// or nil if there is none. | [
"Decomposition",
"returns",
"the",
"decomposition",
"for",
"the",
"underlying",
"rune",
"or",
"nil",
"if",
"there",
"is",
"none",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/Godeps/_workspace/src/golang.org/x/text/unicode/norm/forminfo.go#L142-L151 |
154,315 | salsaflow/salsaflow | Godeps/_workspace/src/golang.org/x/text/unicode/norm/forminfo.go | CCC | func (p Properties) CCC() uint8 {
if p.index >= firstCCCZeroExcept {
return 0
}
return ccc[p.ccc]
} | go | func (p Properties) CCC() uint8 {
if p.index >= firstCCCZeroExcept {
return 0
}
return ccc[p.ccc]
} | [
"func",
"(",
"p",
"Properties",
")",
"CCC",
"(",
")",
"uint8",
"{",
"if",
"p",
".",
"index",
">=",
"firstCCCZeroExcept",
"{",
"return",
"0",
"\n",
"}",
"\n",
"return",
"ccc",
"[",
"p",
".",
"ccc",
"]",
"\n",
"}"
] | // CCC returns the canonical combining class of the underlying rune. | [
"CCC",
"returns",
"the",
"canonical",
"combining",
"class",
"of",
"the",
"underlying",
"rune",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/Godeps/_workspace/src/golang.org/x/text/unicode/norm/forminfo.go#L159-L164 |
154,316 | salsaflow/salsaflow | Godeps/_workspace/src/golang.org/x/text/unicode/norm/forminfo.go | Properties | func (f Form) Properties(s []byte) Properties {
if f == NFC || f == NFD {
return compInfo(nfcData.lookup(s))
}
return compInfo(nfkcData.lookup(s))
} | go | func (f Form) Properties(s []byte) Properties {
if f == NFC || f == NFD {
return compInfo(nfcData.lookup(s))
}
return compInfo(nfkcData.lookup(s))
} | [
"func",
"(",
"f",
"Form",
")",
"Properties",
"(",
"s",
"[",
"]",
"byte",
")",
"Properties",
"{",
"if",
"f",
"==",
"NFC",
"||",
"f",
"==",
"NFD",
"{",
"return",
"compInfo",
"(",
"nfcData",
".",
"lookup",
"(",
"s",
")",
")",
"\n",
"}",
"\n",
"ret... | // Properties returns properties for the first rune in s. | [
"Properties",
"returns",
"properties",
"for",
"the",
"first",
"rune",
"in",
"s",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/Godeps/_workspace/src/golang.org/x/text/unicode/norm/forminfo.go#L202-L207 |
154,317 | salsaflow/salsaflow | Godeps/_workspace/src/golang.org/x/text/unicode/norm/forminfo.go | PropertiesString | func (f Form) PropertiesString(s string) Properties {
if f == NFC || f == NFD {
return compInfo(nfcData.lookupString(s))
}
return compInfo(nfkcData.lookupString(s))
} | go | func (f Form) PropertiesString(s string) Properties {
if f == NFC || f == NFD {
return compInfo(nfcData.lookupString(s))
}
return compInfo(nfkcData.lookupString(s))
} | [
"func",
"(",
"f",
"Form",
")",
"PropertiesString",
"(",
"s",
"string",
")",
"Properties",
"{",
"if",
"f",
"==",
"NFC",
"||",
"f",
"==",
"NFD",
"{",
"return",
"compInfo",
"(",
"nfcData",
".",
"lookupString",
"(",
"s",
")",
")",
"\n",
"}",
"\n",
"ret... | // PropertiesString returns properties for the first rune in s. | [
"PropertiesString",
"returns",
"properties",
"for",
"the",
"first",
"rune",
"in",
"s",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/Godeps/_workspace/src/golang.org/x/text/unicode/norm/forminfo.go#L210-L215 |
154,318 | salsaflow/salsaflow | Godeps/_workspace/src/golang.org/x/text/unicode/norm/forminfo.go | compInfo | func compInfo(v uint16, sz int) Properties {
if v == 0 {
return Properties{size: uint8(sz)}
} else if v >= 0x8000 {
p := Properties{
size: uint8(sz),
ccc: uint8(v),
tccc: uint8(v),
flags: qcInfo(v >> 8),
}
if p.ccc > 0 || p.combinesBackward() {
p.nLead = uint8(p.flags & 0x3)
}
return p
}
// has decomposition
h := decomps[v]
f := (qcInfo(h&headerFlagsMask) >> 2) | 0x4
p := Properties{size: uint8(sz), flags: f, index: v}
if v >= firstCCC {
v += uint16(h&headerLenMask) + 1
c := decomps[v]
p.tccc = c >> 2
p.flags |= qcInfo(c & 0x3)
if v >= firstLeadingCCC {
p.nLead = c & 0x3
if v >= firstStarterWithNLead {
// We were tricked. Remove the decomposition.
p.flags &= 0x03
p.index = 0
return p
}
p.ccc = decomps[v+1]
}
}
return p
} | go | func compInfo(v uint16, sz int) Properties {
if v == 0 {
return Properties{size: uint8(sz)}
} else if v >= 0x8000 {
p := Properties{
size: uint8(sz),
ccc: uint8(v),
tccc: uint8(v),
flags: qcInfo(v >> 8),
}
if p.ccc > 0 || p.combinesBackward() {
p.nLead = uint8(p.flags & 0x3)
}
return p
}
// has decomposition
h := decomps[v]
f := (qcInfo(h&headerFlagsMask) >> 2) | 0x4
p := Properties{size: uint8(sz), flags: f, index: v}
if v >= firstCCC {
v += uint16(h&headerLenMask) + 1
c := decomps[v]
p.tccc = c >> 2
p.flags |= qcInfo(c & 0x3)
if v >= firstLeadingCCC {
p.nLead = c & 0x3
if v >= firstStarterWithNLead {
// We were tricked. Remove the decomposition.
p.flags &= 0x03
p.index = 0
return p
}
p.ccc = decomps[v+1]
}
}
return p
} | [
"func",
"compInfo",
"(",
"v",
"uint16",
",",
"sz",
"int",
")",
"Properties",
"{",
"if",
"v",
"==",
"0",
"{",
"return",
"Properties",
"{",
"size",
":",
"uint8",
"(",
"sz",
")",
"}",
"\n",
"}",
"else",
"if",
"v",
">=",
"0x8000",
"{",
"p",
":=",
"... | // compInfo converts the information contained in v and sz
// to a Properties. See the comment at the top of the file
// for more information on the format. | [
"compInfo",
"converts",
"the",
"information",
"contained",
"in",
"v",
"and",
"sz",
"to",
"a",
"Properties",
".",
"See",
"the",
"comment",
"at",
"the",
"top",
"of",
"the",
"file",
"for",
"more",
"information",
"on",
"the",
"format",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/Godeps/_workspace/src/golang.org/x/text/unicode/norm/forminfo.go#L220-L256 |
154,319 | salsaflow/salsaflow | changes/change_group.go | StoryChanges | func StoryChanges(stories []common.Story) ([]*StoryChangeGroup, error) {
// Prepare the regexp to use to select commits by commit messages.
// This regexp is ORing the chosen Story-Id tag values.
var grepFlag bytes.Buffer
fmt.Fprintf(&grepFlag, "^Story-Id: (%v", stories[0].Tag())
for _, story := range stories[1:] {
fmt.Fprintf(&grepFlag, "|%v", story.Tag())
}
fmt.Fprint(&grepFlag, ")$")
// Get the relevant commits.
commits, err := git.GrepCommitsCaseInsensitive(grepFlag.String(), "--all")
if err != nil {
return nil, err
}
okCommits := make([]*git.Commit, 0, len(commits))
for _, commit := range commits {
if commit.StoryIdTag == "" {
log.Warn(fmt.Sprintf(
"Found story commit %v, but failed to parse the Story-Id tag.", commit.SHA))
log.NewLine("Please check that commit manually.")
continue
}
okCommits = append(okCommits, commit)
}
commits = okCommits
// Return the change groups.
return StoryChangesFromCommits(commits)
} | go | func StoryChanges(stories []common.Story) ([]*StoryChangeGroup, error) {
// Prepare the regexp to use to select commits by commit messages.
// This regexp is ORing the chosen Story-Id tag values.
var grepFlag bytes.Buffer
fmt.Fprintf(&grepFlag, "^Story-Id: (%v", stories[0].Tag())
for _, story := range stories[1:] {
fmt.Fprintf(&grepFlag, "|%v", story.Tag())
}
fmt.Fprint(&grepFlag, ")$")
// Get the relevant commits.
commits, err := git.GrepCommitsCaseInsensitive(grepFlag.String(), "--all")
if err != nil {
return nil, err
}
okCommits := make([]*git.Commit, 0, len(commits))
for _, commit := range commits {
if commit.StoryIdTag == "" {
log.Warn(fmt.Sprintf(
"Found story commit %v, but failed to parse the Story-Id tag.", commit.SHA))
log.NewLine("Please check that commit manually.")
continue
}
okCommits = append(okCommits, commit)
}
commits = okCommits
// Return the change groups.
return StoryChangesFromCommits(commits)
} | [
"func",
"StoryChanges",
"(",
"stories",
"[",
"]",
"common",
".",
"Story",
")",
"(",
"[",
"]",
"*",
"StoryChangeGroup",
",",
"error",
")",
"{",
"// Prepare the regexp to use to select commits by commit messages.",
"// This regexp is ORing the chosen Story-Id tag values.",
"v... | // StoryChanges returns the list of changes grouped by Story-Id. | [
"StoryChanges",
"returns",
"the",
"list",
"of",
"changes",
"grouped",
"by",
"Story",
"-",
"Id",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/changes/change_group.go#L49-L79 |
154,320 | salsaflow/salsaflow | changes/change_group.go | DumpStoryChanges | func DumpStoryChanges(
writer io.Writer,
groups []*StoryChangeGroup,
tracker common.IssueTracker,
porcelain bool,
) error {
tw := tabwriter.NewWriter(writer, 0, 8, 2, '\t', 0)
if !porcelain {
_, err := io.WriteString(tw, "Story\tChange\tCommit SHA\tCommit Source\tCommit Title\n")
if err != nil {
return err
}
_, err = io.WriteString(tw, "=====\t======\t==========\t=============\t============\n")
if err != nil {
return err
}
}
for _, group := range groups {
storyId, err := tracker.StoryTagToReadableStoryId(group.StoryIdTag)
if err != nil {
return err
}
for _, change := range group.Changes {
changeId := change.ChangeIdTag
// Print the first line.
var (
commit = change.Commits[0]
commitMessageTitle = prompt.ShortenCommitTitle(commit.MessageTitle)
)
printChange := func(commit *git.Commit) error {
_, err := fmt.Fprintf(tw, "%v\t%v\t%v\t%v\t%v\n",
storyId, changeId, commit.SHA, commit.Source, commitMessageTitle)
return err
}
if err := printChange(commit); err != nil {
return err
}
// Make some of the columns empty in case we are not porcelain.
if !porcelain {
storyId = ""
changeId = ""
}
// Print the rest with the chosen columns being empty.
for _, commit := range change.Commits[1:] {
if err := printChange(commit); err != nil {
return err
}
}
}
}
return tw.Flush()
} | go | func DumpStoryChanges(
writer io.Writer,
groups []*StoryChangeGroup,
tracker common.IssueTracker,
porcelain bool,
) error {
tw := tabwriter.NewWriter(writer, 0, 8, 2, '\t', 0)
if !porcelain {
_, err := io.WriteString(tw, "Story\tChange\tCommit SHA\tCommit Source\tCommit Title\n")
if err != nil {
return err
}
_, err = io.WriteString(tw, "=====\t======\t==========\t=============\t============\n")
if err != nil {
return err
}
}
for _, group := range groups {
storyId, err := tracker.StoryTagToReadableStoryId(group.StoryIdTag)
if err != nil {
return err
}
for _, change := range group.Changes {
changeId := change.ChangeIdTag
// Print the first line.
var (
commit = change.Commits[0]
commitMessageTitle = prompt.ShortenCommitTitle(commit.MessageTitle)
)
printChange := func(commit *git.Commit) error {
_, err := fmt.Fprintf(tw, "%v\t%v\t%v\t%v\t%v\n",
storyId, changeId, commit.SHA, commit.Source, commitMessageTitle)
return err
}
if err := printChange(commit); err != nil {
return err
}
// Make some of the columns empty in case we are not porcelain.
if !porcelain {
storyId = ""
changeId = ""
}
// Print the rest with the chosen columns being empty.
for _, commit := range change.Commits[1:] {
if err := printChange(commit); err != nil {
return err
}
}
}
}
return tw.Flush()
} | [
"func",
"DumpStoryChanges",
"(",
"writer",
"io",
".",
"Writer",
",",
"groups",
"[",
"]",
"*",
"StoryChangeGroup",
",",
"tracker",
"common",
".",
"IssueTracker",
",",
"porcelain",
"bool",
",",
")",
"error",
"{",
"tw",
":=",
"tabwriter",
".",
"NewWriter",
"(... | // DumpStoryChanges writes a nicely formatted output to the io.Writer passed in.
//
// In case the porcelain argument is true, the output is printed in a more machine-friendly way. | [
"DumpStoryChanges",
"writes",
"a",
"nicely",
"formatted",
"output",
"to",
"the",
"io",
".",
"Writer",
"passed",
"in",
".",
"In",
"case",
"the",
"porcelain",
"argument",
"is",
"true",
"the",
"output",
"is",
"printed",
"in",
"a",
"more",
"machine",
"-",
"fri... | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/changes/change_group.go#L142-L202 |
154,321 | salsaflow/salsaflow | Godeps/_workspace/src/gopkg.in/tchap/gocli.v2/app.go | NewApp | func NewApp(name string) *App {
app := &App{
Name: name,
Command: &Command{
Action: helpAction(1),
},
}
app.Command.helpTemplate = AppHelpTemplate
app.Command.helpTemplateData = app
app.Command.Flags.Var((*helpValue)(app.Command), "h", "print help and exit")
return app
} | go | func NewApp(name string) *App {
app := &App{
Name: name,
Command: &Command{
Action: helpAction(1),
},
}
app.Command.helpTemplate = AppHelpTemplate
app.Command.helpTemplateData = app
app.Command.Flags.Var((*helpValue)(app.Command), "h", "print help and exit")
return app
} | [
"func",
"NewApp",
"(",
"name",
"string",
")",
"*",
"App",
"{",
"app",
":=",
"&",
"App",
"{",
"Name",
":",
"name",
",",
"Command",
":",
"&",
"Command",
"{",
"Action",
":",
"helpAction",
"(",
"1",
")",
",",
"}",
",",
"}",
"\n",
"app",
".",
"Comma... | // App constructor. Unfortunately App could not be written in a way that would
// allow to simply use a struct literal. | [
"App",
"constructor",
".",
"Unfortunately",
"App",
"could",
"not",
"be",
"written",
"in",
"a",
"way",
"that",
"would",
"allow",
"to",
"simply",
"use",
"a",
"struct",
"literal",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/Godeps/_workspace/src/gopkg.in/tchap/gocli.v2/app.go#L36-L49 |
154,322 | GeoNet/map180 | map.go | layerGetter | func layerGetter(ctx groupcache.Context, key string, dest groupcache.Sink) error {
m, err := fromKey(key)
if err != nil {
return err
}
land, err := m.nePolySVG(m.zoom, 0)
if err != nil {
return err
}
lakes, err := m.nePolySVG(m.zoom, 1)
if err != nil {
return err
}
l, err := m.labels()
if err != nil {
return err
}
var b bytes.Buffer
b.WriteString(fmt.Sprintf("<path fill=\"wheat\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke=\"lightslategrey\" d=\"%s\"/>", land))
b.WriteString(fmt.Sprintf("<path fill=\"azure\" stroke-width=\"1\" stroke=\"lightslategrey\" d=\"%s\"/>", lakes))
b.WriteString(labelsToSVG(l))
return dest.SetString(b.String())
} | go | func layerGetter(ctx groupcache.Context, key string, dest groupcache.Sink) error {
m, err := fromKey(key)
if err != nil {
return err
}
land, err := m.nePolySVG(m.zoom, 0)
if err != nil {
return err
}
lakes, err := m.nePolySVG(m.zoom, 1)
if err != nil {
return err
}
l, err := m.labels()
if err != nil {
return err
}
var b bytes.Buffer
b.WriteString(fmt.Sprintf("<path fill=\"wheat\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke=\"lightslategrey\" d=\"%s\"/>", land))
b.WriteString(fmt.Sprintf("<path fill=\"azure\" stroke-width=\"1\" stroke=\"lightslategrey\" d=\"%s\"/>", lakes))
b.WriteString(labelsToSVG(l))
return dest.SetString(b.String())
} | [
"func",
"layerGetter",
"(",
"ctx",
"groupcache",
".",
"Context",
",",
"key",
"string",
",",
"dest",
"groupcache",
".",
"Sink",
")",
"error",
"{",
"m",
",",
"err",
":=",
"fromKey",
"(",
"key",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",... | // Functions for map layers with groupcache. | [
"Functions",
"for",
"map",
"layers",
"with",
"groupcache",
"."
] | 9dfd58c339375915a35c96438b0db973c4ece9d4 | https://github.com/GeoNet/map180/blob/9dfd58c339375915a35c96438b0db973c4ece9d4/map.go#L433-L461 |
154,323 | seven5/seven5 | client/view.go | HtmlIdFromModel | func HtmlIdFromModel(tag string, m ModelName) HtmlId {
id := fmt.Sprintf("%s-%s", strings.ToLower(tag), m.Id())
return NewHtmlId(tag, id)
} | go | func HtmlIdFromModel(tag string, m ModelName) HtmlId {
id := fmt.Sprintf("%s-%s", strings.ToLower(tag), m.Id())
return NewHtmlId(tag, id)
} | [
"func",
"HtmlIdFromModel",
"(",
"tag",
"string",
",",
"m",
"ModelName",
")",
"HtmlId",
"{",
"id",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"strings",
".",
"ToLower",
"(",
"tag",
")",
",",
"m",
".",
"Id",
"(",
")",
")",
"\n",
"return",
"... | //HtmlIdFromModel returns an HtmlId object from the given modelname and
//tagname. Resulting id is unique to the modelname and tag, but not
//between tags with the same name. | [
"HtmlIdFromModel",
"returns",
"an",
"HtmlId",
"object",
"from",
"the",
"given",
"modelname",
"and",
"tagname",
".",
"Resulting",
"id",
"is",
"unique",
"to",
"the",
"modelname",
"and",
"tag",
"but",
"not",
"between",
"tags",
"with",
"the",
"same",
"name",
"."... | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/client/view.go#L136-L139 |
154,324 | seven5/seven5 | client/view.go | ParseHtml | func ParseHtml(t string) NarrowDom {
parsed := jquery.ParseHTML(t)
var nDom NarrowDom
if TestMode {
nDom = newTestOps()
} else {
if len(parsed) > 1 {
div := jquery.NewJQuery(jquery.ParseHTML("<div/>"))
div.Append(parsed...)
return wrap(div)
} else {
nDom = wrap(jquery.NewJQuery(parsed[0]))
}
}
return nDom
} | go | func ParseHtml(t string) NarrowDom {
parsed := jquery.ParseHTML(t)
var nDom NarrowDom
if TestMode {
nDom = newTestOps()
} else {
if len(parsed) > 1 {
div := jquery.NewJQuery(jquery.ParseHTML("<div/>"))
div.Append(parsed...)
return wrap(div)
} else {
nDom = wrap(jquery.NewJQuery(parsed[0]))
}
}
return nDom
} | [
"func",
"ParseHtml",
"(",
"t",
"string",
")",
"NarrowDom",
"{",
"parsed",
":=",
"jquery",
".",
"ParseHTML",
"(",
"t",
")",
"\n",
"var",
"nDom",
"NarrowDom",
"\n",
"if",
"TestMode",
"{",
"nDom",
"=",
"newTestOps",
"(",
")",
"\n",
"}",
"else",
"{",
"if... | //ParseHtml returns a NarrowDom that points at the fragment
//of HTML provided in t. No attempt is made to validate that
//the HTML is sensible, much less syntatically correct. | [
"ParseHtml",
"returns",
"a",
"NarrowDom",
"that",
"points",
"at",
"the",
"fragment",
"of",
"HTML",
"provided",
"in",
"t",
".",
"No",
"attempt",
"is",
"made",
"to",
"validate",
"that",
"the",
"HTML",
"is",
"sensible",
"much",
"less",
"syntatically",
"correct"... | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/client/view.go#L144-L159 |
154,325 | muesli/goprogressbar | progressbar.go | percentage | func (p *ProgressBar) percentage() float64 {
pct := float64(p.Current) / float64(p.Total)
if p.Total == 0 {
if p.Current == 0 {
// When both Total and Current are 0, show a full progressbar
pct = 1
} else {
pct = 0
}
}
// percentage is bound between 0 and 1
return math.Min(1, math.Max(0, pct))
} | go | func (p *ProgressBar) percentage() float64 {
pct := float64(p.Current) / float64(p.Total)
if p.Total == 0 {
if p.Current == 0 {
// When both Total and Current are 0, show a full progressbar
pct = 1
} else {
pct = 0
}
}
// percentage is bound between 0 and 1
return math.Min(1, math.Max(0, pct))
} | [
"func",
"(",
"p",
"*",
"ProgressBar",
")",
"percentage",
"(",
")",
"float64",
"{",
"pct",
":=",
"float64",
"(",
"p",
".",
"Current",
")",
"/",
"float64",
"(",
"p",
".",
"Total",
")",
"\n",
"if",
"p",
".",
"Total",
"==",
"0",
"{",
"if",
"p",
"."... | // percentage returns the percentage bound between 0.0 and 1.0 | [
"percentage",
"returns",
"the",
"percentage",
"bound",
"between",
"0",
".",
"0",
"and",
"1",
".",
"0"
] | 8ba388894ed9b3d8fef35f68045b1c2ffe64163a | https://github.com/muesli/goprogressbar/blob/8ba388894ed9b3d8fef35f68045b1c2ffe64163a/progressbar.go#L60-L73 |
154,326 | muesli/goprogressbar | progressbar.go | UpdateRequired | func (p *ProgressBar) UpdateRequired() bool {
return p.Current == 0 || p.Current == p.Total
} | go | func (p *ProgressBar) UpdateRequired() bool {
return p.Current == 0 || p.Current == p.Total
} | [
"func",
"(",
"p",
"*",
"ProgressBar",
")",
"UpdateRequired",
"(",
")",
"bool",
"{",
"return",
"p",
".",
"Current",
"==",
"0",
"||",
"p",
".",
"Current",
"==",
"p",
".",
"Total",
"\n",
"}"
] | // UpdateRequired returns true when this progressbar wants an update regardless
// of fps limitation | [
"UpdateRequired",
"returns",
"true",
"when",
"this",
"progressbar",
"wants",
"an",
"update",
"regardless",
"of",
"fps",
"limitation"
] | 8ba388894ed9b3d8fef35f68045b1c2ffe64163a | https://github.com/muesli/goprogressbar/blob/8ba388894ed9b3d8fef35f68045b1c2ffe64163a/progressbar.go#L77-L79 |
154,327 | muesli/goprogressbar | progressbar.go | LazyPrint | func (p *ProgressBar) LazyPrint() {
now := time.Now()
if p.UpdateRequired() || now.Sub(p.lastPrintTime) > time.Second/fps {
p.lastPrintTime = now
p.Print()
}
} | go | func (p *ProgressBar) LazyPrint() {
now := time.Now()
if p.UpdateRequired() || now.Sub(p.lastPrintTime) > time.Second/fps {
p.lastPrintTime = now
p.Print()
}
} | [
"func",
"(",
"p",
"*",
"ProgressBar",
")",
"LazyPrint",
"(",
")",
"{",
"now",
":=",
"time",
".",
"Now",
"(",
")",
"\n",
"if",
"p",
".",
"UpdateRequired",
"(",
")",
"||",
"now",
".",
"Sub",
"(",
"p",
".",
"lastPrintTime",
")",
">",
"time",
".",
... | // LazyPrint writes the progress bar to stdout if a significant update occurred | [
"LazyPrint",
"writes",
"the",
"progress",
"bar",
"to",
"stdout",
"if",
"a",
"significant",
"update",
"occurred"
] | 8ba388894ed9b3d8fef35f68045b1c2ffe64163a | https://github.com/muesli/goprogressbar/blob/8ba388894ed9b3d8fef35f68045b1c2ffe64163a/progressbar.go#L82-L88 |
154,328 | muesli/goprogressbar | progressbar.go | Print | func (p *ProgressBar) Print() {
if p.PrependTextFunc != nil {
p.PrependText = p.PrependTextFunc(p)
}
pct := p.percentage()
clearCurrentLine()
pcts := fmt.Sprintf("%.2f%%", pct*100)
for len(pcts) < 7 {
pcts = " " + pcts
}
tiWidth, _, _ := terminal.GetSize(int(syscall.Stdin))
if tiWidth < 0 {
// we're not running inside a real terminal (e.g. CI)
// we assume a width of 80
tiWidth = 80
}
barWidth := uint(math.Min(float64(p.Width), float64(tiWidth)/2.0))
size := int(barWidth) - len(pcts) - 4
fill := int(math.Max(2, math.Floor((float64(size)*pct)+.5)))
if size < 16 {
barWidth = 0
}
text := p.Text
textLen := utf8.RuneCountInString(p.Text)
maxTextWidth := tiWidth - 3 - int(barWidth) - utf8.RuneCountInString(p.PrependText)
if maxTextWidth < 0 {
maxTextWidth = 0
}
if textLen > maxTextWidth {
if textLen-maxTextWidth+3 < textLen {
text = "..." + string([]rune(p.Text)[textLen-maxTextWidth+3:])
} else {
text = ""
}
}
// Print text
s := fmt.Sprintf("%s%s %s ",
text,
strings.Repeat(" ", maxTextWidth-utf8.RuneCountInString(text)),
p.PrependText)
fmt.Fprint(Stdout, s)
if barWidth > 0 {
progChar := BarFormat[2]
if p.Current == p.Total {
progChar = BarFormat[1]
}
// Print progress bar
fmt.Fprintf(Stdout, "%c%s%c%s%c %s",
BarFormat[0],
strings.Repeat(string(BarFormat[1]), fill-1),
progChar,
strings.Repeat(string(BarFormat[3]), size-fill),
BarFormat[4],
pcts)
}
} | go | func (p *ProgressBar) Print() {
if p.PrependTextFunc != nil {
p.PrependText = p.PrependTextFunc(p)
}
pct := p.percentage()
clearCurrentLine()
pcts := fmt.Sprintf("%.2f%%", pct*100)
for len(pcts) < 7 {
pcts = " " + pcts
}
tiWidth, _, _ := terminal.GetSize(int(syscall.Stdin))
if tiWidth < 0 {
// we're not running inside a real terminal (e.g. CI)
// we assume a width of 80
tiWidth = 80
}
barWidth := uint(math.Min(float64(p.Width), float64(tiWidth)/2.0))
size := int(barWidth) - len(pcts) - 4
fill := int(math.Max(2, math.Floor((float64(size)*pct)+.5)))
if size < 16 {
barWidth = 0
}
text := p.Text
textLen := utf8.RuneCountInString(p.Text)
maxTextWidth := tiWidth - 3 - int(barWidth) - utf8.RuneCountInString(p.PrependText)
if maxTextWidth < 0 {
maxTextWidth = 0
}
if textLen > maxTextWidth {
if textLen-maxTextWidth+3 < textLen {
text = "..." + string([]rune(p.Text)[textLen-maxTextWidth+3:])
} else {
text = ""
}
}
// Print text
s := fmt.Sprintf("%s%s %s ",
text,
strings.Repeat(" ", maxTextWidth-utf8.RuneCountInString(text)),
p.PrependText)
fmt.Fprint(Stdout, s)
if barWidth > 0 {
progChar := BarFormat[2]
if p.Current == p.Total {
progChar = BarFormat[1]
}
// Print progress bar
fmt.Fprintf(Stdout, "%c%s%c%s%c %s",
BarFormat[0],
strings.Repeat(string(BarFormat[1]), fill-1),
progChar,
strings.Repeat(string(BarFormat[3]), size-fill),
BarFormat[4],
pcts)
}
} | [
"func",
"(",
"p",
"*",
"ProgressBar",
")",
"Print",
"(",
")",
"{",
"if",
"p",
".",
"PrependTextFunc",
"!=",
"nil",
"{",
"p",
".",
"PrependText",
"=",
"p",
".",
"PrependTextFunc",
"(",
"p",
")",
"\n",
"}",
"\n",
"pct",
":=",
"p",
".",
"percentage",
... | // Print writes the progress bar to stdout | [
"Print",
"writes",
"the",
"progress",
"bar",
"to",
"stdout"
] | 8ba388894ed9b3d8fef35f68045b1c2ffe64163a | https://github.com/muesli/goprogressbar/blob/8ba388894ed9b3d8fef35f68045b1c2ffe64163a/progressbar.go#L96-L158 |
154,329 | muesli/goprogressbar | progressbar.go | AddProgressBar | func (mp *MultiProgressBar) AddProgressBar(p *ProgressBar) {
mp.ProgressBars = append(mp.ProgressBars, p)
if len(mp.ProgressBars) > 1 {
fmt.Println()
}
mp.Print()
} | go | func (mp *MultiProgressBar) AddProgressBar(p *ProgressBar) {
mp.ProgressBars = append(mp.ProgressBars, p)
if len(mp.ProgressBars) > 1 {
fmt.Println()
}
mp.Print()
} | [
"func",
"(",
"mp",
"*",
"MultiProgressBar",
")",
"AddProgressBar",
"(",
"p",
"*",
"ProgressBar",
")",
"{",
"mp",
".",
"ProgressBars",
"=",
"append",
"(",
"mp",
".",
"ProgressBars",
",",
"p",
")",
"\n\n",
"if",
"len",
"(",
"mp",
".",
"ProgressBars",
")"... | // AddProgressBar adds another progress bar to the multi struct | [
"AddProgressBar",
"adds",
"another",
"progress",
"bar",
"to",
"the",
"multi",
"struct"
] | 8ba388894ed9b3d8fef35f68045b1c2ffe64163a | https://github.com/muesli/goprogressbar/blob/8ba388894ed9b3d8fef35f68045b1c2ffe64163a/progressbar.go#L161-L168 |
154,330 | muesli/goprogressbar | progressbar.go | Print | func (mp *MultiProgressBar) Print() {
moveCursorUp(uint(len(mp.ProgressBars)))
for _, p := range mp.ProgressBars {
moveCursorDown(1)
p.Print()
}
} | go | func (mp *MultiProgressBar) Print() {
moveCursorUp(uint(len(mp.ProgressBars)))
for _, p := range mp.ProgressBars {
moveCursorDown(1)
p.Print()
}
} | [
"func",
"(",
"mp",
"*",
"MultiProgressBar",
")",
"Print",
"(",
")",
"{",
"moveCursorUp",
"(",
"uint",
"(",
"len",
"(",
"mp",
".",
"ProgressBars",
")",
")",
")",
"\n\n",
"for",
"_",
",",
"p",
":=",
"range",
"mp",
".",
"ProgressBars",
"{",
"moveCursorD... | // Print writes all progress bars to stdout | [
"Print",
"writes",
"all",
"progress",
"bars",
"to",
"stdout"
] | 8ba388894ed9b3d8fef35f68045b1c2ffe64163a | https://github.com/muesli/goprogressbar/blob/8ba388894ed9b3d8fef35f68045b1c2ffe64163a/progressbar.go#L171-L178 |
154,331 | muesli/goprogressbar | progressbar.go | LazyPrint | func (mp *MultiProgressBar) LazyPrint() {
forced := false
for _, p := range mp.ProgressBars {
if p.UpdateRequired() {
forced = true
break
}
}
now := time.Now()
if !forced {
forced = now.Sub(mp.lastPrintTime) > time.Second/fps
}
if forced {
mp.lastPrintTime = now
moveCursorUp(uint(len(mp.ProgressBars)))
for _, p := range mp.ProgressBars {
moveCursorDown(1)
p.Print()
}
}
} | go | func (mp *MultiProgressBar) LazyPrint() {
forced := false
for _, p := range mp.ProgressBars {
if p.UpdateRequired() {
forced = true
break
}
}
now := time.Now()
if !forced {
forced = now.Sub(mp.lastPrintTime) > time.Second/fps
}
if forced {
mp.lastPrintTime = now
moveCursorUp(uint(len(mp.ProgressBars)))
for _, p := range mp.ProgressBars {
moveCursorDown(1)
p.Print()
}
}
} | [
"func",
"(",
"mp",
"*",
"MultiProgressBar",
")",
"LazyPrint",
"(",
")",
"{",
"forced",
":=",
"false",
"\n",
"for",
"_",
",",
"p",
":=",
"range",
"mp",
".",
"ProgressBars",
"{",
"if",
"p",
".",
"UpdateRequired",
"(",
")",
"{",
"forced",
"=",
"true",
... | // LazyPrint writes all progress bars to stdout if a significant update occurred | [
"LazyPrint",
"writes",
"all",
"progress",
"bars",
"to",
"stdout",
"if",
"a",
"significant",
"update",
"occurred"
] | 8ba388894ed9b3d8fef35f68045b1c2ffe64163a | https://github.com/muesli/goprogressbar/blob/8ba388894ed9b3d8fef35f68045b1c2ffe64163a/progressbar.go#L181-L204 |
154,332 | salsaflow/salsaflow | github/client.go | Token | func (ts *tokenSource) Token() (*oauth2.Token, error) {
return &oauth2.Token{AccessToken: ts.token}, nil
} | go | func (ts *tokenSource) Token() (*oauth2.Token, error) {
return &oauth2.Token{AccessToken: ts.token}, nil
} | [
"func",
"(",
"ts",
"*",
"tokenSource",
")",
"Token",
"(",
")",
"(",
"*",
"oauth2",
".",
"Token",
",",
"error",
")",
"{",
"return",
"&",
"oauth2",
".",
"Token",
"{",
"AccessToken",
":",
"ts",
".",
"token",
"}",
",",
"nil",
"\n",
"}"
] | // Token implements oauth2.TokenSource interface. | [
"Token",
"implements",
"oauth2",
".",
"TokenSource",
"interface",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/github/client.go#L18-L20 |
154,333 | salsaflow/salsaflow | prompt/storyprompt/dialog.go | PushOptions | func (dialog *Dialog) PushOptions(opts ...*DialogOption) {
dialog.opts = append(dialog.opts, opts...)
} | go | func (dialog *Dialog) PushOptions(opts ...*DialogOption) {
dialog.opts = append(dialog.opts, opts...)
} | [
"func",
"(",
"dialog",
"*",
"Dialog",
")",
"PushOptions",
"(",
"opts",
"...",
"*",
"DialogOption",
")",
"{",
"dialog",
".",
"opts",
"=",
"append",
"(",
"dialog",
".",
"opts",
",",
"opts",
"...",
")",
"\n",
"}"
] | // PushOptions can be used to add options to the option chain.
//
// The dialog will try to find the matching option based on the order
// the options are matching, so in case there is an option matching
// any input pushed as the first option, no other option body will
// ever be executed. | [
"PushOptions",
"can",
"be",
"used",
"to",
"add",
"options",
"to",
"the",
"option",
"chain",
".",
"The",
"dialog",
"will",
"try",
"to",
"find",
"the",
"matching",
"option",
"based",
"on",
"the",
"order",
"the",
"options",
"are",
"matching",
"so",
"in",
"c... | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/prompt/storyprompt/dialog.go#L70-L72 |
154,334 | salsaflow/salsaflow | prompt/storyprompt/dialog.go | NewSubdialog | func (dialog *Dialog) NewSubdialog() *Dialog {
return &Dialog{
depth: dialog.depth,
isSub: true,
}
} | go | func (dialog *Dialog) NewSubdialog() *Dialog {
return &Dialog{
depth: dialog.depth,
isSub: true,
}
} | [
"func",
"(",
"dialog",
"*",
"Dialog",
")",
"NewSubdialog",
"(",
")",
"*",
"Dialog",
"{",
"return",
"&",
"Dialog",
"{",
"depth",
":",
"dialog",
".",
"depth",
",",
"isSub",
":",
"true",
",",
"}",
"\n",
"}"
] | // NewSubdialog can be used to create a new dialog based on the current dialog.
// The option list is empty again, just the dialog depth is inherited. | [
"NewSubdialog",
"can",
"be",
"used",
"to",
"create",
"a",
"new",
"dialog",
"based",
"on",
"the",
"current",
"dialog",
".",
"The",
"option",
"list",
"is",
"empty",
"again",
"just",
"the",
"dialog",
"depth",
"is",
"inherited",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/prompt/storyprompt/dialog.go#L76-L81 |
154,335 | salsaflow/salsaflow | prompt/storyprompt/dialog.go | Run | func (dialog *Dialog) Run(stories []common.Story) (common.Story, error) {
// Return an error when no options are set.
if len(dialog.opts) == 0 {
return nil, errors.New("storyprompt.Dialog.Run(): no options were specified")
}
// Increment the dialog depth on enter.
dialog.depth++
// Decrement the dialog depth on return.
defer func() {
dialog.depth--
}()
// Enter the dialog loop.
DialogLoop:
for {
var (
opts = dialog.opts
depth = dialog.depth
)
// Present the stories to the user.
if err := ListStories(stories, os.Stdout); err != nil {
return nil, err
}
// Print the options based on the dialog depth.
fmt.Println()
fmt.Println("Now you can do one of the following:")
fmt.Println()
// Collect the list of active options.
activeOpts := make([]*DialogOption, 0, len(opts))
for _, opt := range opts {
if isActive := opt.IsActive; isActive != nil && isActive(stories, depth) {
activeOpts = append(activeOpts, opt)
}
}
// Print the description for the active options.
for _, opt := range activeOpts {
if desc := opt.Description; len(desc) != 0 {
fmt.Println(" -", strings.Join(desc, "\n "))
}
}
fmt.Println()
// Prompt the user for their choice.
fmt.Println("Current dialog depth:", depth)
input, err := prompt.Prompt("Choose what to do next: ")
// We ignore prompt.ErrCanceled here and simply continue.
// That is because an empty input is a valid input here as well.
if err != nil && err != prompt.ErrCanceled {
return nil, err
}
input = strings.TrimSpace(input)
// Find the first matching option.
var matchingOpt *DialogOption
for _, opt := range activeOpts {
if matchFunc := opt.MatchesInput; matchFunc != nil && matchFunc(input, stories) {
matchingOpt = opt
break
}
}
// Loop again in case no match is found.
if matchingOpt == nil {
fmt.Println()
fmt.Println("Error: no matching option found")
fmt.Println()
continue DialogLoop
}
// Run the selected select function.
if selectFunc := matchingOpt.SelectStory; selectFunc != nil {
story, err := selectFunc(input, stories, dialog)
if err != nil {
switch err {
case ErrContinue:
// Continue looping on ErrContinue.
fmt.Println()
continue DialogLoop
case ErrReturn:
// Go one dialog up by returning ErrContinue.
// This makes the dialog loop of the parent dialog continue,
// effectively re-printing and re-running that dialog.
if dialog.isSub {
return nil, ErrContinue
}
// In case this is a top-level dialog, abort.
fallthrough
case ErrAbort:
// Panic prompt.ErrCanceled on ErrAbort, returning immediately
// from any dialog depth.
prompt.PanicCancel()
}
// In case the error is not any of the recognized control errors,
// print the error and loop again, making the user choose again.
fmt.Println()
fmt.Println("Error:", err)
fmt.Println()
continue DialogLoop
}
return story, nil
}
// No SelectStory function specified for the matching option,
// that is a programming error, let's just panic.
panic(errors.New("SelectStory function not specified"))
}
} | go | func (dialog *Dialog) Run(stories []common.Story) (common.Story, error) {
// Return an error when no options are set.
if len(dialog.opts) == 0 {
return nil, errors.New("storyprompt.Dialog.Run(): no options were specified")
}
// Increment the dialog depth on enter.
dialog.depth++
// Decrement the dialog depth on return.
defer func() {
dialog.depth--
}()
// Enter the dialog loop.
DialogLoop:
for {
var (
opts = dialog.opts
depth = dialog.depth
)
// Present the stories to the user.
if err := ListStories(stories, os.Stdout); err != nil {
return nil, err
}
// Print the options based on the dialog depth.
fmt.Println()
fmt.Println("Now you can do one of the following:")
fmt.Println()
// Collect the list of active options.
activeOpts := make([]*DialogOption, 0, len(opts))
for _, opt := range opts {
if isActive := opt.IsActive; isActive != nil && isActive(stories, depth) {
activeOpts = append(activeOpts, opt)
}
}
// Print the description for the active options.
for _, opt := range activeOpts {
if desc := opt.Description; len(desc) != 0 {
fmt.Println(" -", strings.Join(desc, "\n "))
}
}
fmt.Println()
// Prompt the user for their choice.
fmt.Println("Current dialog depth:", depth)
input, err := prompt.Prompt("Choose what to do next: ")
// We ignore prompt.ErrCanceled here and simply continue.
// That is because an empty input is a valid input here as well.
if err != nil && err != prompt.ErrCanceled {
return nil, err
}
input = strings.TrimSpace(input)
// Find the first matching option.
var matchingOpt *DialogOption
for _, opt := range activeOpts {
if matchFunc := opt.MatchesInput; matchFunc != nil && matchFunc(input, stories) {
matchingOpt = opt
break
}
}
// Loop again in case no match is found.
if matchingOpt == nil {
fmt.Println()
fmt.Println("Error: no matching option found")
fmt.Println()
continue DialogLoop
}
// Run the selected select function.
if selectFunc := matchingOpt.SelectStory; selectFunc != nil {
story, err := selectFunc(input, stories, dialog)
if err != nil {
switch err {
case ErrContinue:
// Continue looping on ErrContinue.
fmt.Println()
continue DialogLoop
case ErrReturn:
// Go one dialog up by returning ErrContinue.
// This makes the dialog loop of the parent dialog continue,
// effectively re-printing and re-running that dialog.
if dialog.isSub {
return nil, ErrContinue
}
// In case this is a top-level dialog, abort.
fallthrough
case ErrAbort:
// Panic prompt.ErrCanceled on ErrAbort, returning immediately
// from any dialog depth.
prompt.PanicCancel()
}
// In case the error is not any of the recognized control errors,
// print the error and loop again, making the user choose again.
fmt.Println()
fmt.Println("Error:", err)
fmt.Println()
continue DialogLoop
}
return story, nil
}
// No SelectStory function specified for the matching option,
// that is a programming error, let's just panic.
panic(errors.New("SelectStory function not specified"))
}
} | [
"func",
"(",
"dialog",
"*",
"Dialog",
")",
"Run",
"(",
"stories",
"[",
"]",
"common",
".",
"Story",
")",
"(",
"common",
".",
"Story",
",",
"error",
")",
"{",
"// Return an error when no options are set.",
"if",
"len",
"(",
"dialog",
".",
"opts",
")",
"==... | // Run starts the dialog after the options are set. It uses the given story list
// to prompt the user for a story using the given options. | [
"Run",
"starts",
"the",
"dialog",
"after",
"the",
"options",
"are",
"set",
".",
"It",
"uses",
"the",
"given",
"story",
"list",
"to",
"prompt",
"the",
"user",
"for",
"a",
"story",
"using",
"the",
"given",
"options",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/prompt/storyprompt/dialog.go#L85-L197 |
154,336 | salsaflow/salsaflow | version/scripts.go | Get | func Get() (*Version, error) {
// Run the get_version script.
stdout, err := scripts.Run(scripts.ScriptNameGetVersion)
if err != nil {
return nil, err
}
// Parse the output and return the version.
return Parse(strings.TrimSpace(stdout.String()))
} | go | func Get() (*Version, error) {
// Run the get_version script.
stdout, err := scripts.Run(scripts.ScriptNameGetVersion)
if err != nil {
return nil, err
}
// Parse the output and return the version.
return Parse(strings.TrimSpace(stdout.String()))
} | [
"func",
"Get",
"(",
")",
"(",
"*",
"Version",
",",
"error",
")",
"{",
"// Run the get_version script.",
"stdout",
",",
"err",
":=",
"scripts",
".",
"Run",
"(",
"scripts",
".",
"ScriptNameGetVersion",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"n... | // Get runs the get_version script. | [
"Get",
"runs",
"the",
"get_version",
"script",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/version/scripts.go#L12-L21 |
154,337 | salsaflow/salsaflow | version/scripts.go | Set | func Set(ver *Version) error {
// Run the set_version script.
_, err := scripts.Run(scripts.ScriptNameSetVersion, ver.String())
return err
} | go | func Set(ver *Version) error {
// Run the set_version script.
_, err := scripts.Run(scripts.ScriptNameSetVersion, ver.String())
return err
} | [
"func",
"Set",
"(",
"ver",
"*",
"Version",
")",
"error",
"{",
"// Run the set_version script.",
"_",
",",
"err",
":=",
"scripts",
".",
"Run",
"(",
"scripts",
".",
"ScriptNameSetVersion",
",",
"ver",
".",
"String",
"(",
")",
")",
"\n",
"return",
"err",
"\... | // Set runs the set_version script. | [
"Set",
"runs",
"the",
"set_version",
"script",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/version/scripts.go#L24-L28 |
154,338 | seven5/seven5 | client/form.go | NewInputTextId | func NewInputTextId(id string) InputTextId {
result := inputTextIdImpl{
htmlIdImpl: NewHtmlId("input", id).(htmlIdImpl),
}
result.attr = NewAttribute(VALUE_ONLY, result.value, nil)
result.htmlIdImpl.Dom().On(INPUT_EVENT, func(jquery.Event) {
result.attr.markDirty()
})
return result
} | go | func NewInputTextId(id string) InputTextId {
result := inputTextIdImpl{
htmlIdImpl: NewHtmlId("input", id).(htmlIdImpl),
}
result.attr = NewAttribute(VALUE_ONLY, result.value, nil)
result.htmlIdImpl.Dom().On(INPUT_EVENT, func(jquery.Event) {
result.attr.markDirty()
})
return result
} | [
"func",
"NewInputTextId",
"(",
"id",
"string",
")",
"InputTextId",
"{",
"result",
":=",
"inputTextIdImpl",
"{",
"htmlIdImpl",
":",
"NewHtmlId",
"(",
"\"",
"\"",
",",
"id",
")",
".",
"(",
"htmlIdImpl",
")",
",",
"}",
"\n",
"result",
".",
"attr",
"=",
"N... | //NewInputTextId returns a reference to a static part of the DOM that is the
//an input tag with the given id. | [
"NewInputTextId",
"returns",
"a",
"reference",
"to",
"a",
"static",
"part",
"of",
"the",
"DOM",
"that",
"is",
"the",
"an",
"input",
"tag",
"with",
"the",
"given",
"id",
"."
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/client/form.go#L50-L59 |
154,339 | seven5/seven5 | client/form.go | Val | func (self inputTextIdImpl) Val() string {
v := self.htmlIdImpl.t.Val()
if v == "undefined" {
return ""
}
return v
} | go | func (self inputTextIdImpl) Val() string {
v := self.htmlIdImpl.t.Val()
if v == "undefined" {
return ""
}
return v
} | [
"func",
"(",
"self",
"inputTextIdImpl",
")",
"Val",
"(",
")",
"string",
"{",
"v",
":=",
"self",
".",
"htmlIdImpl",
".",
"t",
".",
"Val",
"(",
")",
"\n",
"if",
"v",
"==",
"\"",
"\"",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"v",
"\n... | //Val returns the value of an input field. | [
"Val",
"returns",
"the",
"value",
"of",
"an",
"input",
"field",
"."
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/client/form.go#L68-L74 |
154,340 | seven5/seven5 | client/form.go | NewRadioGroup | func NewRadioGroup(name string) RadioGroup {
selector := "input:radio[name=\"" + name + "\"]"
result := radioGroupImpl{selector: selector}
if TestMode {
result.dom = newTestOps()
} else {
result.dom = wrap(jquery.NewJQuery(selector))
}
result.attr = NewAttribute(VALUE_ONLY, result.value, nil)
result.dom.On(CLICK, func(jquery.Event) {
result.attr.markDirty()
})
return result
} | go | func NewRadioGroup(name string) RadioGroup {
selector := "input:radio[name=\"" + name + "\"]"
result := radioGroupImpl{selector: selector}
if TestMode {
result.dom = newTestOps()
} else {
result.dom = wrap(jquery.NewJQuery(selector))
}
result.attr = NewAttribute(VALUE_ONLY, result.value, nil)
result.dom.On(CLICK, func(jquery.Event) {
result.attr.markDirty()
})
return result
} | [
"func",
"NewRadioGroup",
"(",
"name",
"string",
")",
"RadioGroup",
"{",
"selector",
":=",
"\"",
"\\\"",
"\"",
"+",
"name",
"+",
"\"",
"\\\"",
"\"",
"\n",
"result",
":=",
"radioGroupImpl",
"{",
"selector",
":",
"selector",
"}",
"\n",
"if",
"TestMode",
"{"... | //NewRadioGroup selects a named set of radio button elements
//with a given name. | [
"NewRadioGroup",
"selects",
"a",
"named",
"set",
"of",
"radio",
"button",
"elements",
"with",
"a",
"given",
"name",
"."
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/client/form.go#L86-L99 |
154,341 | seven5/seven5 | client/form.go | NewSelectGroupId | func NewSelectGroupId(id string) SelectGroup {
selector := "select#" + id
result := selectGroupImpl{selector: selector}
if TestMode {
result.dom = newTestOps()
} else {
result.dom = wrap(jquery.NewJQuery(selector))
}
result.attr = NewAttribute(VALUE_ONLY, result.value, nil)
result.dom.On(CLICK, func(jquery.Event) {
result.attr.markDirty()
})
return result
} | go | func NewSelectGroupId(id string) SelectGroup {
selector := "select#" + id
result := selectGroupImpl{selector: selector}
if TestMode {
result.dom = newTestOps()
} else {
result.dom = wrap(jquery.NewJQuery(selector))
}
result.attr = NewAttribute(VALUE_ONLY, result.value, nil)
result.dom.On(CLICK, func(jquery.Event) {
result.attr.markDirty()
})
return result
} | [
"func",
"NewSelectGroupId",
"(",
"id",
"string",
")",
"SelectGroup",
"{",
"selector",
":=",
"\"",
"\"",
"+",
"id",
"\n",
"result",
":=",
"selectGroupImpl",
"{",
"selector",
":",
"selector",
"}",
"\n",
"if",
"TestMode",
"{",
"result",
".",
"dom",
"=",
"ne... | //NewSelectGroup selects one of a named set of elements, usually
//rendered as a drop down list. | [
"NewSelectGroup",
"selects",
"one",
"of",
"a",
"named",
"set",
"of",
"elements",
"usually",
"rendered",
"as",
"a",
"drop",
"down",
"list",
"."
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/client/form.go#L152-L165 |
154,342 | seven5/seven5 | client/form.go | SetVal | func (self selectGroupImpl) SetVal(s string) {
switch d := self.dom.(type) {
case jqueryWrapper:
child := d.jq.Filter(fmt.Sprintf("[value=\"%s\"]", s))
child.SetProp("selected", true)
case *testOpsImpl:
d.SetVal(s)
d.Trigger(CLICK)
default:
panic("unknown type of dom pointer!")
}
} | go | func (self selectGroupImpl) SetVal(s string) {
switch d := self.dom.(type) {
case jqueryWrapper:
child := d.jq.Filter(fmt.Sprintf("[value=\"%s\"]", s))
child.SetProp("selected", true)
case *testOpsImpl:
d.SetVal(s)
d.Trigger(CLICK)
default:
panic("unknown type of dom pointer!")
}
} | [
"func",
"(",
"self",
"selectGroupImpl",
")",
"SetVal",
"(",
"s",
"string",
")",
"{",
"switch",
"d",
":=",
"self",
".",
"dom",
".",
"(",
"type",
")",
"{",
"case",
"jqueryWrapper",
":",
"child",
":=",
"d",
".",
"jq",
".",
"Filter",
"(",
"fmt",
".",
... | //SetVal sets the current value of the group defined in
//in the selectGroup. | [
"SetVal",
"sets",
"the",
"current",
"value",
"of",
"the",
"group",
"defined",
"in",
"in",
"the",
"selectGroup",
"."
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/client/form.go#L203-L214 |
154,343 | seven5/seven5 | client/form.go | NewFormValidConstraint | func NewFormValidConstraint(fn formValidFunc, id ...FormElement) formValidConstraint {
return formValidConstraint{fn: fn, id: id}
} | go | func NewFormValidConstraint(fn formValidFunc, id ...FormElement) formValidConstraint {
return formValidConstraint{fn: fn, id: id}
} | [
"func",
"NewFormValidConstraint",
"(",
"fn",
"formValidFunc",
",",
"id",
"...",
"FormElement",
")",
"formValidConstraint",
"{",
"return",
"formValidConstraint",
"{",
"fn",
":",
"fn",
",",
"id",
":",
"id",
"}",
"\n",
"}"
] | //NewFormValidConstraint creates a constraint that uses the function
//supplied to compute a value and has dependencies on all the remaining
//parameters. | [
"NewFormValidConstraint",
"creates",
"a",
"constraint",
"that",
"uses",
"the",
"function",
"supplied",
"to",
"compute",
"a",
"value",
"and",
"has",
"dependencies",
"on",
"all",
"the",
"remaining",
"parameters",
"."
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/client/form.go#L245-L247 |
154,344 | seven5/seven5 | pwd_auth.go | Check | func (self *SimplePasswordHandler) Check(username, pwd string) (Session, error) {
uniq, userData, err := self.vsm.ValidateCredentials(username, pwd)
if err != nil {
return nil, err
}
if uniq == "" {
return nil, nil
}
return self.vsm.Assign(uniq, userData, time.Time{})
} | go | func (self *SimplePasswordHandler) Check(username, pwd string) (Session, error) {
uniq, userData, err := self.vsm.ValidateCredentials(username, pwd)
if err != nil {
return nil, err
}
if uniq == "" {
return nil, nil
}
return self.vsm.Assign(uniq, userData, time.Time{})
} | [
"func",
"(",
"self",
"*",
"SimplePasswordHandler",
")",
"Check",
"(",
"username",
",",
"pwd",
"string",
")",
"(",
"Session",
",",
"error",
")",
"{",
"uniq",
",",
"userData",
",",
"err",
":=",
"self",
".",
"vsm",
".",
"ValidateCredentials",
"(",
"username... | //
// Check verifies that the username and password provided are the ones we expect
// via a calle the ValidatingSessionManager. It returns nil,nil in the case of a
// failed check on the password provided.
// | [
"Check",
"verifies",
"that",
"the",
"username",
"and",
"password",
"provided",
"are",
"the",
"ones",
"we",
"expect",
"via",
"a",
"calle",
"the",
"ValidatingSessionManager",
".",
"It",
"returns",
"nil",
"nil",
"in",
"the",
"case",
"of",
"a",
"failed",
"check"... | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/pwd_auth.go#L72-L81 |
154,345 | seven5/seven5 | pwd_auth.go | MeHandler | func (self *SimplePasswordHandler) MeHandler(w http.ResponseWriter, r *http.Request) {
w.Header().Add("Cache-Control", "no-cache, must-revalidate") //HTTP 1.1
w.Header().Add("Pragma", "no-cache") //HTTP 1.0
val, err := self.cm.Value(r)
if err != nil && err != NO_SUCH_COOKIE {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
if err != nil { //no cookie
http.Error(w, "no cookie", http.StatusUnauthorized)
return
}
sr, err := self.vsm.Find(strings.TrimSpace(val))
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
if sr == nil {
http.Error(w, "no session", http.StatusUnauthorized)
return
}
if sr.Session != nil {
if err := self.vsm.SendUserDetails(sr.Session.UserData(), w); err != nil {
log.Printf("failed to send user data: %v", err)
}
return
}
i, err := self.vsm.Generate(sr.UniqueId)
if err != nil {
http.Error(w, fmt.Sprintf("unable to recover session: %v", err), http.StatusInternalServerError)
return
}
recovered, err := self.vsm.Assign(sr.UniqueId, i, time.Time{})
if err := self.vsm.SendUserDetails(recovered.UserData(), w); err != nil {
log.Printf("failed to send user data: %v", err)
}
return
} | go | func (self *SimplePasswordHandler) MeHandler(w http.ResponseWriter, r *http.Request) {
w.Header().Add("Cache-Control", "no-cache, must-revalidate") //HTTP 1.1
w.Header().Add("Pragma", "no-cache") //HTTP 1.0
val, err := self.cm.Value(r)
if err != nil && err != NO_SUCH_COOKIE {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
if err != nil { //no cookie
http.Error(w, "no cookie", http.StatusUnauthorized)
return
}
sr, err := self.vsm.Find(strings.TrimSpace(val))
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
if sr == nil {
http.Error(w, "no session", http.StatusUnauthorized)
return
}
if sr.Session != nil {
if err := self.vsm.SendUserDetails(sr.Session.UserData(), w); err != nil {
log.Printf("failed to send user data: %v", err)
}
return
}
i, err := self.vsm.Generate(sr.UniqueId)
if err != nil {
http.Error(w, fmt.Sprintf("unable to recover session: %v", err), http.StatusInternalServerError)
return
}
recovered, err := self.vsm.Assign(sr.UniqueId, i, time.Time{})
if err := self.vsm.SendUserDetails(recovered.UserData(), w); err != nil {
log.Printf("failed to send user data: %v", err)
}
return
} | [
"func",
"(",
"self",
"*",
"SimplePasswordHandler",
")",
"MeHandler",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"w",
".",
"Header",
"(",
")",
".",
"Add",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"//HTTP ... | //
// Me returns the currently logged in user to the client.
// | [
"Me",
"returns",
"the",
"currently",
"logged",
"in",
"user",
"to",
"the",
"client",
"."
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/pwd_auth.go#L86-L126 |
154,346 | itchio/httpkit | htfs/backtracker/backtracker.go | New | func New(offset int64, upstream io.Reader, cacheSize int64) Backtracker {
return &backtracker{
upstream: bufio.NewReader(upstream),
discardBuf: make([]byte, 256*1024),
cache: make([]byte, cacheSize),
cached: 0,
backtrack: 0,
offset: offset,
}
} | go | func New(offset int64, upstream io.Reader, cacheSize int64) Backtracker {
return &backtracker{
upstream: bufio.NewReader(upstream),
discardBuf: make([]byte, 256*1024),
cache: make([]byte, cacheSize),
cached: 0,
backtrack: 0,
offset: offset,
}
} | [
"func",
"New",
"(",
"offset",
"int64",
",",
"upstream",
"io",
".",
"Reader",
",",
"cacheSize",
"int64",
")",
"Backtracker",
"{",
"return",
"&",
"backtracker",
"{",
"upstream",
":",
"bufio",
".",
"NewReader",
"(",
"upstream",
")",
",",
"discardBuf",
":",
... | // New returns a Backtracker reading from upstream | [
"New",
"returns",
"a",
"Backtracker",
"reading",
"from",
"upstream"
] | f7051ef345456d077d49344cf6ec98b4059214f5 | https://github.com/itchio/httpkit/blob/f7051ef345456d077d49344cf6ec98b4059214f5/htfs/backtracker/backtracker.go#L36-L45 |
154,347 | salsaflow/salsaflow | Godeps/_workspace/src/golang.org/x/text/unicode/norm/readwriter.go | Write | func (w *normWriter) Write(data []byte) (n int, err error) {
// Process data in pieces to keep w.buf size bounded.
const chunk = 4000
for len(data) > 0 {
// Normalize into w.buf.
m := len(data)
if m > chunk {
m = chunk
}
w.rb.src = inputBytes(data[:m])
w.rb.nsrc = m
w.buf = doAppend(&w.rb, w.buf, 0)
data = data[m:]
n += m
// Write out complete prefix, save remainder.
// Note that lastBoundary looks back at most 31 runes.
i := lastBoundary(&w.rb.f, w.buf)
if i == -1 {
i = 0
}
if i > 0 {
if _, err = w.w.Write(w.buf[:i]); err != nil {
break
}
bn := copy(w.buf, w.buf[i:])
w.buf = w.buf[:bn]
}
}
return n, err
} | go | func (w *normWriter) Write(data []byte) (n int, err error) {
// Process data in pieces to keep w.buf size bounded.
const chunk = 4000
for len(data) > 0 {
// Normalize into w.buf.
m := len(data)
if m > chunk {
m = chunk
}
w.rb.src = inputBytes(data[:m])
w.rb.nsrc = m
w.buf = doAppend(&w.rb, w.buf, 0)
data = data[m:]
n += m
// Write out complete prefix, save remainder.
// Note that lastBoundary looks back at most 31 runes.
i := lastBoundary(&w.rb.f, w.buf)
if i == -1 {
i = 0
}
if i > 0 {
if _, err = w.w.Write(w.buf[:i]); err != nil {
break
}
bn := copy(w.buf, w.buf[i:])
w.buf = w.buf[:bn]
}
}
return n, err
} | [
"func",
"(",
"w",
"*",
"normWriter",
")",
"Write",
"(",
"data",
"[",
"]",
"byte",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"// Process data in pieces to keep w.buf size bounded.",
"const",
"chunk",
"=",
"4000",
"\n\n",
"for",
"len",
"(",
"data"... | // Write implements the standard write interface. If the last characters are
// not at a normalization boundary, the bytes will be buffered for the next
// write. The remaining bytes will be written on close. | [
"Write",
"implements",
"the",
"standard",
"write",
"interface",
".",
"If",
"the",
"last",
"characters",
"are",
"not",
"at",
"a",
"normalization",
"boundary",
"the",
"bytes",
"will",
"be",
"buffered",
"for",
"the",
"next",
"write",
".",
"The",
"remaining",
"b... | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/Godeps/_workspace/src/golang.org/x/text/unicode/norm/readwriter.go#L18-L49 |
154,348 | salsaflow/salsaflow | Godeps/_workspace/src/golang.org/x/text/unicode/norm/readwriter.go | Close | func (w *normWriter) Close() error {
if len(w.buf) > 0 {
_, err := w.w.Write(w.buf)
if err != nil {
return err
}
}
return nil
} | go | func (w *normWriter) Close() error {
if len(w.buf) > 0 {
_, err := w.w.Write(w.buf)
if err != nil {
return err
}
}
return nil
} | [
"func",
"(",
"w",
"*",
"normWriter",
")",
"Close",
"(",
")",
"error",
"{",
"if",
"len",
"(",
"w",
".",
"buf",
")",
">",
"0",
"{",
"_",
",",
"err",
":=",
"w",
".",
"w",
".",
"Write",
"(",
"w",
".",
"buf",
")",
"\n",
"if",
"err",
"!=",
"nil... | // Close forces data that remains in the buffer to be written. | [
"Close",
"forces",
"data",
"that",
"remains",
"in",
"the",
"buffer",
"to",
"be",
"written",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/Godeps/_workspace/src/golang.org/x/text/unicode/norm/readwriter.go#L52-L60 |
154,349 | salsaflow/salsaflow | Godeps/_workspace/src/golang.org/x/text/unicode/norm/readwriter.go | Read | func (r *normReader) Read(p []byte) (int, error) {
for {
if r.lastBoundary-r.bufStart > 0 {
n := copy(p, r.outbuf[r.bufStart:r.lastBoundary])
r.bufStart += n
if r.lastBoundary-r.bufStart > 0 {
return n, nil
}
return n, r.err
}
if r.err != nil {
return 0, r.err
}
outn := copy(r.outbuf, r.outbuf[r.lastBoundary:])
r.outbuf = r.outbuf[0:outn]
r.bufStart = 0
n, err := r.r.Read(r.inbuf)
r.rb.src = inputBytes(r.inbuf[0:n])
r.rb.nsrc, r.err = n, err
if n > 0 {
r.outbuf = doAppend(&r.rb, r.outbuf, 0)
}
if err == io.EOF {
r.lastBoundary = len(r.outbuf)
} else {
r.lastBoundary = lastBoundary(&r.rb.f, r.outbuf)
if r.lastBoundary == -1 {
r.lastBoundary = 0
}
}
}
panic("should not reach here")
} | go | func (r *normReader) Read(p []byte) (int, error) {
for {
if r.lastBoundary-r.bufStart > 0 {
n := copy(p, r.outbuf[r.bufStart:r.lastBoundary])
r.bufStart += n
if r.lastBoundary-r.bufStart > 0 {
return n, nil
}
return n, r.err
}
if r.err != nil {
return 0, r.err
}
outn := copy(r.outbuf, r.outbuf[r.lastBoundary:])
r.outbuf = r.outbuf[0:outn]
r.bufStart = 0
n, err := r.r.Read(r.inbuf)
r.rb.src = inputBytes(r.inbuf[0:n])
r.rb.nsrc, r.err = n, err
if n > 0 {
r.outbuf = doAppend(&r.rb, r.outbuf, 0)
}
if err == io.EOF {
r.lastBoundary = len(r.outbuf)
} else {
r.lastBoundary = lastBoundary(&r.rb.f, r.outbuf)
if r.lastBoundary == -1 {
r.lastBoundary = 0
}
}
}
panic("should not reach here")
} | [
"func",
"(",
"r",
"*",
"normReader",
")",
"Read",
"(",
"p",
"[",
"]",
"byte",
")",
"(",
"int",
",",
"error",
")",
"{",
"for",
"{",
"if",
"r",
".",
"lastBoundary",
"-",
"r",
".",
"bufStart",
">",
"0",
"{",
"n",
":=",
"copy",
"(",
"p",
",",
"... | // Read implements the standard read interface. | [
"Read",
"implements",
"the",
"standard",
"read",
"interface",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/Godeps/_workspace/src/golang.org/x/text/unicode/norm/readwriter.go#L83-L116 |
154,350 | seven5/seven5 | migrate/postgres.go | DestroyMigrationRecords | func (m *postgresMigrator) DestroyMigrationRecords() error {
_, err := m.db.Exec(m.deleteAll())
return err
} | go | func (m *postgresMigrator) DestroyMigrationRecords() error {
_, err := m.db.Exec(m.deleteAll())
return err
} | [
"func",
"(",
"m",
"*",
"postgresMigrator",
")",
"DestroyMigrationRecords",
"(",
")",
"error",
"{",
"_",
",",
"err",
":=",
"m",
".",
"db",
".",
"Exec",
"(",
"m",
".",
"deleteAll",
"(",
")",
")",
"\n",
"return",
"err",
"\n",
"}"
] | //DestroyMigrationRecords destroys the records kept about migrations. This
//is almost certanily a bad idea anywhere except in a test. | [
"DestroyMigrationRecords",
"destroys",
"the",
"records",
"kept",
"about",
"migrations",
".",
"This",
"is",
"almost",
"certanily",
"a",
"bad",
"idea",
"anywhere",
"except",
"in",
"a",
"test",
"."
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/migrate/postgres.go#L17-L20 |
154,351 | seven5/seven5 | migrate/postgres.go | Close | func (m *postgresMigrator) Close() error {
if m.db != nil {
return m.db.Close()
}
return nil
} | go | func (m *postgresMigrator) Close() error {
if m.db != nil {
return m.db.Close()
}
return nil
} | [
"func",
"(",
"m",
"*",
"postgresMigrator",
")",
"Close",
"(",
")",
"error",
"{",
"if",
"m",
".",
"db",
"!=",
"nil",
"{",
"return",
"m",
".",
"db",
".",
"Close",
"(",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | //Close severs the db connection, if it exists. | [
"Close",
"severs",
"the",
"db",
"connection",
"if",
"it",
"exists",
"."
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/migrate/postgres.go#L23-L28 |
154,352 | seven5/seven5 | migrate/postgres.go | createTableIfNotExists | func (m *postgresMigrator) createTableIfNotExists() error {
_, err := m.db.Exec(m.createTable())
return err
} | go | func (m *postgresMigrator) createTableIfNotExists() error {
_, err := m.db.Exec(m.createTable())
return err
} | [
"func",
"(",
"m",
"*",
"postgresMigrator",
")",
"createTableIfNotExists",
"(",
")",
"error",
"{",
"_",
",",
"err",
":=",
"m",
".",
"db",
".",
"Exec",
"(",
"m",
".",
"createTable",
"(",
")",
")",
"\n",
"return",
"err",
"\n",
"}"
] | //createTableIfNotExists creates the table if it doesn't yet exist
//otherwise does nothing. | [
"createTableIfNotExists",
"creates",
"the",
"table",
"if",
"it",
"doesn",
"t",
"yet",
"exist",
"otherwise",
"does",
"nothing",
"."
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/migrate/postgres.go#L58-L61 |
154,353 | seven5/seven5 | migrate/postgres.go | CurrentMigrationNumber | func (m *postgresMigrator) CurrentMigrationNumber() (int, error) {
curr := -9018
row := m.db.QueryRow(m.numQuery())
err := row.Scan(&curr)
if err != nil && err != sql.ErrNoRows {
return -1917, err
}
if err == sql.ErrNoRows {
return 0, nil
}
return curr, nil
} | go | func (m *postgresMigrator) CurrentMigrationNumber() (int, error) {
curr := -9018
row := m.db.QueryRow(m.numQuery())
err := row.Scan(&curr)
if err != nil && err != sql.ErrNoRows {
return -1917, err
}
if err == sql.ErrNoRows {
return 0, nil
}
return curr, nil
} | [
"func",
"(",
"m",
"*",
"postgresMigrator",
")",
"CurrentMigrationNumber",
"(",
")",
"(",
"int",
",",
"error",
")",
"{",
"curr",
":=",
"-",
"9018",
"\n",
"row",
":=",
"m",
".",
"db",
".",
"QueryRow",
"(",
"m",
".",
"numQuery",
"(",
")",
")",
"\n",
... | //CurrentMigration returns the current migration number found in the
//migrations table. If no migrations have been performed, this returns
//zero. | [
"CurrentMigration",
"returns",
"the",
"current",
"migration",
"number",
"found",
"in",
"the",
"migrations",
"table",
".",
"If",
"no",
"migrations",
"have",
"been",
"performed",
"this",
"returns",
"zero",
"."
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/migrate/postgres.go#L66-L77 |
154,354 | seven5/seven5 | migrate/postgres.go | UpTo | func (m *postgresMigrator) UpTo(target int, migrations map[int]MigrationFunc) (int, error) {
curr, err := m.CurrentMigrationNumber()
if err != nil {
return 0, err
}
success := 0
for i := 0; i < target; i++ {
if i < curr {
continue
}
fmt.Printf("[migrator] attempting migration UP %03d\n", i+1)
err := m.step(migrations[i+1])
if err != nil {
return success, err
}
success++
_, err = m.db.Exec(m.insertRow(i + 1))
if err != nil {
return success, err
}
}
return success, nil
} | go | func (m *postgresMigrator) UpTo(target int, migrations map[int]MigrationFunc) (int, error) {
curr, err := m.CurrentMigrationNumber()
if err != nil {
return 0, err
}
success := 0
for i := 0; i < target; i++ {
if i < curr {
continue
}
fmt.Printf("[migrator] attempting migration UP %03d\n", i+1)
err := m.step(migrations[i+1])
if err != nil {
return success, err
}
success++
_, err = m.db.Exec(m.insertRow(i + 1))
if err != nil {
return success, err
}
}
return success, nil
} | [
"func",
"(",
"m",
"*",
"postgresMigrator",
")",
"UpTo",
"(",
"target",
"int",
",",
"migrations",
"map",
"[",
"int",
"]",
"MigrationFunc",
")",
"(",
"int",
",",
"error",
")",
"{",
"curr",
",",
"err",
":=",
"m",
".",
"CurrentMigrationNumber",
"(",
")",
... | //Goes Up to the migration given.Returns the number of migrations
//successfully performed. Migrations are done in a transaction. If
//the current migration level is equal to or greater than the target
//this is a noop. Note that you pass where you want to BE after this
//is done, not the migration to be performed. For example, passing
//1 as target implies running migration 1. | [
"Goes",
"Up",
"to",
"the",
"migration",
"given",
".",
"Returns",
"the",
"number",
"of",
"migrations",
"successfully",
"performed",
".",
"Migrations",
"are",
"done",
"in",
"a",
"transaction",
".",
"If",
"the",
"current",
"migration",
"level",
"is",
"equal",
"... | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/migrate/postgres.go#L92-L115 |
154,355 | seven5/seven5 | migrate/postgres.go | step | func (m *postgresMigrator) step(fn MigrationFunc) error {
if fn == nil {
panic("step called but no function!")
}
tx, err := m.db.Begin()
if err != nil {
return err
}
if err := fn(tx); err != nil {
fmt.Printf("got an error trying to run a step: %v", err)
if err := tx.Rollback(); err != nil {
panic(fmt.Sprintf("unable to rollback migration transaction:%v", err))
}
return err
}
if err := tx.Commit(); err != nil {
panic(fmt.Sprintf("unable to commit migration transaction:%v", err))
}
return nil
} | go | func (m *postgresMigrator) step(fn MigrationFunc) error {
if fn == nil {
panic("step called but no function!")
}
tx, err := m.db.Begin()
if err != nil {
return err
}
if err := fn(tx); err != nil {
fmt.Printf("got an error trying to run a step: %v", err)
if err := tx.Rollback(); err != nil {
panic(fmt.Sprintf("unable to rollback migration transaction:%v", err))
}
return err
}
if err := tx.Commit(); err != nil {
panic(fmt.Sprintf("unable to commit migration transaction:%v", err))
}
return nil
} | [
"func",
"(",
"m",
"*",
"postgresMigrator",
")",
"step",
"(",
"fn",
"MigrationFunc",
")",
"error",
"{",
"if",
"fn",
"==",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"tx",
",",
"err",
":=",
"m",
".",
"db",
".",
"Begin",
"(",
")",... | //Single step, given a function. There is no need for f | [
"Single",
"step",
"given",
"a",
"function",
".",
"There",
"is",
"no",
"need",
"for",
"f"
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/migrate/postgres.go#L150-L169 |
154,356 | seven5/seven5 | migrate/postgres.go | insertRow | func (m *postgresMigrator) insertRow(i int) string {
return fmt.Sprintf("INSERT INTO %s (n) VALUES(%d)", MIGRATION_TABLE, i)
} | go | func (m *postgresMigrator) insertRow(i int) string {
return fmt.Sprintf("INSERT INTO %s (n) VALUES(%d)", MIGRATION_TABLE, i)
} | [
"func",
"(",
"m",
"*",
"postgresMigrator",
")",
"insertRow",
"(",
"i",
"int",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"MIGRATION_TABLE",
",",
"i",
")",
"\n",
"}"
] | //make it easier to port to other DB | [
"make",
"it",
"easier",
"to",
"port",
"to",
"other",
"DB"
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/migrate/postgres.go#L214-L216 |
154,357 | itchio/httpkit | progress/ewma.go | Add | func (e *EWMA) Add(value float64) {
if e.value == 0 { // perhaps first input, no decay factor needed
e.value = value
return
}
e.value = (value * Decay) + (e.value * (1 - Decay))
} | go | func (e *EWMA) Add(value float64) {
if e.value == 0 { // perhaps first input, no decay factor needed
e.value = value
return
}
e.value = (value * Decay) + (e.value * (1 - Decay))
} | [
"func",
"(",
"e",
"*",
"EWMA",
")",
"Add",
"(",
"value",
"float64",
")",
"{",
"if",
"e",
".",
"value",
"==",
"0",
"{",
"// perhaps first input, no decay factor needed",
"e",
".",
"value",
"=",
"value",
"\n",
"return",
"\n",
"}",
"\n",
"e",
".",
"value"... | // Add a value to the series and update the moving average. | [
"Add",
"a",
"value",
"to",
"the",
"series",
"and",
"update",
"the",
"moving",
"average",
"."
] | f7051ef345456d077d49344cf6ec98b4059214f5 | https://github.com/itchio/httpkit/blob/f7051ef345456d077d49344cf6ec98b4059214f5/progress/ewma.go#L18-L24 |
154,358 | salsaflow/salsaflow | Godeps/_workspace/src/golang.org/x/text/unicode/norm/normalize.go | patchTail | func patchTail(rb *reorderBuffer) bool {
info, p := lastRuneStart(&rb.f, rb.out)
if p == -1 || info.size == 0 {
return true
}
end := p + int(info.size)
extra := len(rb.out) - end
if extra > 0 {
// Potentially allocating memory. However, this only
// happens with ill-formed UTF-8.
x := make([]byte, 0)
x = append(x, rb.out[len(rb.out)-extra:]...)
rb.out = rb.out[:end]
decomposeToLastBoundary(rb)
rb.doFlush()
rb.out = append(rb.out, x...)
return false
}
buf := rb.out[p:]
rb.out = rb.out[:p]
decomposeToLastBoundary(rb)
if s := rb.ss.next(info); s == ssStarter {
rb.doFlush()
rb.ss.first(info)
} else if s == ssOverflow {
rb.doFlush()
rb.insertCGJ()
rb.ss = 0
}
rb.insertUnsafe(inputBytes(buf), 0, info)
return true
} | go | func patchTail(rb *reorderBuffer) bool {
info, p := lastRuneStart(&rb.f, rb.out)
if p == -1 || info.size == 0 {
return true
}
end := p + int(info.size)
extra := len(rb.out) - end
if extra > 0 {
// Potentially allocating memory. However, this only
// happens with ill-formed UTF-8.
x := make([]byte, 0)
x = append(x, rb.out[len(rb.out)-extra:]...)
rb.out = rb.out[:end]
decomposeToLastBoundary(rb)
rb.doFlush()
rb.out = append(rb.out, x...)
return false
}
buf := rb.out[p:]
rb.out = rb.out[:p]
decomposeToLastBoundary(rb)
if s := rb.ss.next(info); s == ssStarter {
rb.doFlush()
rb.ss.first(info)
} else if s == ssOverflow {
rb.doFlush()
rb.insertCGJ()
rb.ss = 0
}
rb.insertUnsafe(inputBytes(buf), 0, info)
return true
} | [
"func",
"patchTail",
"(",
"rb",
"*",
"reorderBuffer",
")",
"bool",
"{",
"info",
",",
"p",
":=",
"lastRuneStart",
"(",
"&",
"rb",
".",
"f",
",",
"rb",
".",
"out",
")",
"\n",
"if",
"p",
"==",
"-",
"1",
"||",
"info",
".",
"size",
"==",
"0",
"{",
... | // patchTail fixes a case where a rune may be incorrectly normalized
// if it is followed by illegal continuation bytes. It returns the
// patched buffer and whether the decomposition is still in progress. | [
"patchTail",
"fixes",
"a",
"case",
"where",
"a",
"rune",
"may",
"be",
"incorrectly",
"normalized",
"if",
"it",
"is",
"followed",
"by",
"illegal",
"continuation",
"bytes",
".",
"It",
"returns",
"the",
"patched",
"buffer",
"and",
"whether",
"the",
"decomposition... | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/Godeps/_workspace/src/golang.org/x/text/unicode/norm/normalize.go#L143-L174 |
154,359 | salsaflow/salsaflow | Godeps/_workspace/src/golang.org/x/text/unicode/norm/normalize.go | FirstBoundary | func (f Form) FirstBoundary(b []byte) int {
return f.firstBoundary(inputBytes(b), len(b))
} | go | func (f Form) FirstBoundary(b []byte) int {
return f.firstBoundary(inputBytes(b), len(b))
} | [
"func",
"(",
"f",
"Form",
")",
"FirstBoundary",
"(",
"b",
"[",
"]",
"byte",
")",
"int",
"{",
"return",
"f",
".",
"firstBoundary",
"(",
"inputBytes",
"(",
"b",
")",
",",
"len",
"(",
"b",
")",
")",
"\n",
"}"
] | // FirstBoundary returns the position i of the first boundary in b
// or -1 if b contains no boundary. | [
"FirstBoundary",
"returns",
"the",
"position",
"i",
"of",
"the",
"first",
"boundary",
"in",
"b",
"or",
"-",
"1",
"if",
"b",
"contains",
"no",
"boundary",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/Godeps/_workspace/src/golang.org/x/text/unicode/norm/normalize.go#L333-L335 |
154,360 | salsaflow/salsaflow | Godeps/_workspace/src/golang.org/x/text/unicode/norm/normalize.go | FirstBoundaryInString | func (f Form) FirstBoundaryInString(s string) int {
return f.firstBoundary(inputString(s), len(s))
} | go | func (f Form) FirstBoundaryInString(s string) int {
return f.firstBoundary(inputString(s), len(s))
} | [
"func",
"(",
"f",
"Form",
")",
"FirstBoundaryInString",
"(",
"s",
"string",
")",
"int",
"{",
"return",
"f",
".",
"firstBoundary",
"(",
"inputString",
"(",
"s",
")",
",",
"len",
"(",
"s",
")",
")",
"\n",
"}"
] | // FirstBoundaryInString returns the position i of the first boundary in s
// or -1 if s contains no boundary. | [
"FirstBoundaryInString",
"returns",
"the",
"position",
"i",
"of",
"the",
"first",
"boundary",
"in",
"s",
"or",
"-",
"1",
"if",
"s",
"contains",
"no",
"boundary",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/Godeps/_workspace/src/golang.org/x/text/unicode/norm/normalize.go#L368-L370 |
154,361 | salsaflow/salsaflow | Godeps/_workspace/src/golang.org/x/text/unicode/norm/normalize.go | LastBoundary | func (f Form) LastBoundary(b []byte) int {
return lastBoundary(formTable[f], b)
} | go | func (f Form) LastBoundary(b []byte) int {
return lastBoundary(formTable[f], b)
} | [
"func",
"(",
"f",
"Form",
")",
"LastBoundary",
"(",
"b",
"[",
"]",
"byte",
")",
"int",
"{",
"return",
"lastBoundary",
"(",
"formTable",
"[",
"f",
"]",
",",
"b",
")",
"\n",
"}"
] | // LastBoundary returns the position i of the last boundary in b
// or -1 if b contains no boundary. | [
"LastBoundary",
"returns",
"the",
"position",
"i",
"of",
"the",
"last",
"boundary",
"in",
"b",
"or",
"-",
"1",
"if",
"b",
"contains",
"no",
"boundary",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/Godeps/_workspace/src/golang.org/x/text/unicode/norm/normalize.go#L374-L376 |
154,362 | salsaflow/salsaflow | Godeps/_workspace/src/golang.org/x/text/unicode/norm/normalize.go | lastRuneStart | func lastRuneStart(fd *formInfo, buf []byte) (Properties, int) {
p := len(buf) - 1
for ; p >= 0 && !utf8.RuneStart(buf[p]); p-- {
}
if p < 0 {
return Properties{}, -1
}
return fd.info(inputBytes(buf), p), p
} | go | func lastRuneStart(fd *formInfo, buf []byte) (Properties, int) {
p := len(buf) - 1
for ; p >= 0 && !utf8.RuneStart(buf[p]); p-- {
}
if p < 0 {
return Properties{}, -1
}
return fd.info(inputBytes(buf), p), p
} | [
"func",
"lastRuneStart",
"(",
"fd",
"*",
"formInfo",
",",
"buf",
"[",
"]",
"byte",
")",
"(",
"Properties",
",",
"int",
")",
"{",
"p",
":=",
"len",
"(",
"buf",
")",
"-",
"1",
"\n",
"for",
";",
"p",
">=",
"0",
"&&",
"!",
"utf8",
".",
"RuneStart",... | // lastRuneStart returns the runeInfo and position of the last
// rune in buf or the zero runeInfo and -1 if no rune was found. | [
"lastRuneStart",
"returns",
"the",
"runeInfo",
"and",
"position",
"of",
"the",
"last",
"rune",
"in",
"buf",
"or",
"the",
"zero",
"runeInfo",
"and",
"-",
"1",
"if",
"no",
"rune",
"was",
"found",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/Godeps/_workspace/src/golang.org/x/text/unicode/norm/normalize.go#L473-L481 |
154,363 | salsaflow/salsaflow | Godeps/_workspace/src/golang.org/x/text/unicode/norm/normalize.go | decomposeToLastBoundary | func decomposeToLastBoundary(rb *reorderBuffer) {
fd := &rb.f
info, i := lastRuneStart(fd, rb.out)
if int(info.size) != len(rb.out)-i {
// illegal trailing continuation bytes
return
}
if info.BoundaryAfter() {
return
}
var add [maxNonStarters + 1]Properties // stores runeInfo in reverse order
padd := 0
ss := streamSafe(0)
p := len(rb.out)
for {
add[padd] = info
v := ss.backwards(info)
if v == ssOverflow {
// Note that if we have an overflow, it the string we are appending to
// is not correctly normalized. In this case the behavior is undefined.
break
}
padd++
p -= int(info.size)
if v == ssStarter || p < 0 {
break
}
info, i = lastRuneStart(fd, rb.out[:p])
if int(info.size) != p-i {
break
}
}
rb.ss = ss
// Copy bytes for insertion as we may need to overwrite rb.out.
var buf [maxBufferSize * utf8.UTFMax]byte
cp := buf[:copy(buf[:], rb.out[p:])]
rb.out = rb.out[:p]
for padd--; padd >= 0; padd-- {
info = add[padd]
rb.insertUnsafe(inputBytes(cp), 0, info)
cp = cp[info.size:]
}
} | go | func decomposeToLastBoundary(rb *reorderBuffer) {
fd := &rb.f
info, i := lastRuneStart(fd, rb.out)
if int(info.size) != len(rb.out)-i {
// illegal trailing continuation bytes
return
}
if info.BoundaryAfter() {
return
}
var add [maxNonStarters + 1]Properties // stores runeInfo in reverse order
padd := 0
ss := streamSafe(0)
p := len(rb.out)
for {
add[padd] = info
v := ss.backwards(info)
if v == ssOverflow {
// Note that if we have an overflow, it the string we are appending to
// is not correctly normalized. In this case the behavior is undefined.
break
}
padd++
p -= int(info.size)
if v == ssStarter || p < 0 {
break
}
info, i = lastRuneStart(fd, rb.out[:p])
if int(info.size) != p-i {
break
}
}
rb.ss = ss
// Copy bytes for insertion as we may need to overwrite rb.out.
var buf [maxBufferSize * utf8.UTFMax]byte
cp := buf[:copy(buf[:], rb.out[p:])]
rb.out = rb.out[:p]
for padd--; padd >= 0; padd-- {
info = add[padd]
rb.insertUnsafe(inputBytes(cp), 0, info)
cp = cp[info.size:]
}
} | [
"func",
"decomposeToLastBoundary",
"(",
"rb",
"*",
"reorderBuffer",
")",
"{",
"fd",
":=",
"&",
"rb",
".",
"f",
"\n",
"info",
",",
"i",
":=",
"lastRuneStart",
"(",
"fd",
",",
"rb",
".",
"out",
")",
"\n",
"if",
"int",
"(",
"info",
".",
"size",
")",
... | // decomposeToLastBoundary finds an open segment at the end of the buffer
// and scans it into rb. Returns the buffer minus the last segment. | [
"decomposeToLastBoundary",
"finds",
"an",
"open",
"segment",
"at",
"the",
"end",
"of",
"the",
"buffer",
"and",
"scans",
"it",
"into",
"rb",
".",
"Returns",
"the",
"buffer",
"minus",
"the",
"last",
"segment",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/Godeps/_workspace/src/golang.org/x/text/unicode/norm/normalize.go#L485-L527 |
154,364 | salsaflow/salsaflow | modules/issue_tracking/github/release_running.go | Stories | func (release *runningRelease) Stories() ([]common.Story, error) {
issues, err := release.loadIssues()
if err != nil {
return nil, err
}
return toCommonStories(issues, release.tracker), nil
} | go | func (release *runningRelease) Stories() ([]common.Story, error) {
issues, err := release.loadIssues()
if err != nil {
return nil, err
}
return toCommonStories(issues, release.tracker), nil
} | [
"func",
"(",
"release",
"*",
"runningRelease",
")",
"Stories",
"(",
")",
"(",
"[",
"]",
"common",
".",
"Story",
",",
"error",
")",
"{",
"issues",
",",
"err",
":=",
"release",
".",
"loadIssues",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return... | // Stories is a part of common.RunningRelease interface. | [
"Stories",
"is",
"a",
"part",
"of",
"common",
".",
"RunningRelease",
"interface",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/modules/issue_tracking/github/release_running.go#L44-L50 |
154,365 | salsaflow/salsaflow | modules/issue_tracking/github/release_running.go | EnsureStageable | func (release *runningRelease) EnsureStageable() error {
task := "Make sure the issues can be staged"
log.Run(task)
// Load the assigned issues.
issues, err := release.loadIssues()
if err != nil {
return errs.NewError(task, err)
}
// Check the states.
var details bytes.Buffer
tw := tabwriter.NewWriter(&details, 0, 8, 4, '\t', 0)
io.WriteString(tw, "\n")
io.WriteString(tw, "Issue URL\tError\n")
io.WriteString(tw, "=========\t=====\n")
skipLabels := release.tracker.config.SkipCheckLabels
shouldBeSkipped := func(issue *github.Issue) bool {
for _, skipLabel := range skipLabels {
if labeled(issue, skipLabel) {
return true
}
}
return false
}
for _, issue := range issues {
// Skip the story in case it is labeled with a skip label.
if shouldBeSkipped(issue) {
continue
}
// Check the abstract state.
var pwned bool
state := abstractState(issue, release.tracker.config)
switch state {
case common.StoryStateNew:
pwned = true
case common.StoryStateApproved:
pwned = true
case common.StoryStateBeingImplemented:
pwned = true
case common.StoryStateImplemented:
pwned = true
case common.StoryStateReviewed:
pwned = true
case common.StoryStateBeingTested:
pwned = true
case common.StoryStateTested:
// OK
case common.StoryStateStaged:
// OK
case common.StoryStateAccepted:
// OK
case common.StoryStateRejected:
pwned = true
case common.StoryStateClosed:
// OK
case common.StoryStateInvalid:
pwned = true
default:
panic("unknown abstract issues state")
}
if pwned {
fmt.Fprintf(tw, "%v\tinvalid state: %v\n", *issue.HTMLURL, state)
err = common.ErrNotStageable
}
}
if err != nil {
io.WriteString(tw, "\n")
tw.Flush()
return errs.NewErrorWithHint(task, err, details.String())
}
return nil
} | go | func (release *runningRelease) EnsureStageable() error {
task := "Make sure the issues can be staged"
log.Run(task)
// Load the assigned issues.
issues, err := release.loadIssues()
if err != nil {
return errs.NewError(task, err)
}
// Check the states.
var details bytes.Buffer
tw := tabwriter.NewWriter(&details, 0, 8, 4, '\t', 0)
io.WriteString(tw, "\n")
io.WriteString(tw, "Issue URL\tError\n")
io.WriteString(tw, "=========\t=====\n")
skipLabels := release.tracker.config.SkipCheckLabels
shouldBeSkipped := func(issue *github.Issue) bool {
for _, skipLabel := range skipLabels {
if labeled(issue, skipLabel) {
return true
}
}
return false
}
for _, issue := range issues {
// Skip the story in case it is labeled with a skip label.
if shouldBeSkipped(issue) {
continue
}
// Check the abstract state.
var pwned bool
state := abstractState(issue, release.tracker.config)
switch state {
case common.StoryStateNew:
pwned = true
case common.StoryStateApproved:
pwned = true
case common.StoryStateBeingImplemented:
pwned = true
case common.StoryStateImplemented:
pwned = true
case common.StoryStateReviewed:
pwned = true
case common.StoryStateBeingTested:
pwned = true
case common.StoryStateTested:
// OK
case common.StoryStateStaged:
// OK
case common.StoryStateAccepted:
// OK
case common.StoryStateRejected:
pwned = true
case common.StoryStateClosed:
// OK
case common.StoryStateInvalid:
pwned = true
default:
panic("unknown abstract issues state")
}
if pwned {
fmt.Fprintf(tw, "%v\tinvalid state: %v\n", *issue.HTMLURL, state)
err = common.ErrNotStageable
}
}
if err != nil {
io.WriteString(tw, "\n")
tw.Flush()
return errs.NewErrorWithHint(task, err, details.String())
}
return nil
} | [
"func",
"(",
"release",
"*",
"runningRelease",
")",
"EnsureStageable",
"(",
")",
"error",
"{",
"task",
":=",
"\"",
"\"",
"\n",
"log",
".",
"Run",
"(",
"task",
")",
"\n\n",
"// Load the assigned issues.",
"issues",
",",
"err",
":=",
"release",
".",
"loadIss... | // EnsureStageable is a part of common.RunningRelease interface. | [
"EnsureStageable",
"is",
"a",
"part",
"of",
"common",
".",
"RunningRelease",
"interface",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/modules/issue_tracking/github/release_running.go#L53-L129 |
154,366 | salsaflow/salsaflow | modules/issue_tracking/github/release_running.go | EnsureClosable | func (release *runningRelease) EnsureClosable() error {
var (
config = release.tracker.config
vString = release.version.BaseString()
)
task := fmt.Sprintf(
"Make sure that the issues associated with release %v can be released", vString)
log.Run(task)
// Make sure the issues are loaded.
issues, err := release.loadIssues()
if err != nil {
return errs.NewError(task, err)
}
// Make sure all relevant issues are accepted.
// This includes the issues with SkipCheckLabels.
notAccepted := filterIssues(issues, func(issue *github.Issue) bool {
return abstractState(issue, config) != common.StoryStateAccepted
})
// In case there are no issues in a wrong state, we are done.
if len(notAccepted) == 0 {
return nil
}
// Generate the error hint.
var hint bytes.Buffer
tw := tabwriter.NewWriter(&hint, 0, 8, 2, '\t', 0)
fmt.Fprintf(tw, "\nThe following issues are blocking the release:\n\n")
fmt.Fprintf(tw, "Issue URL\tState\n")
fmt.Fprintf(tw, "=========\t=====\n")
for _, issue := range notAccepted {
fmt.Fprintf(tw, "%v\t%v\n", *issue.HTMLURL, abstractState(issue, config))
}
fmt.Fprintf(tw, "\n")
tw.Flush()
return errs.NewErrorWithHint(task, common.ErrNotClosable, hint.String())
} | go | func (release *runningRelease) EnsureClosable() error {
var (
config = release.tracker.config
vString = release.version.BaseString()
)
task := fmt.Sprintf(
"Make sure that the issues associated with release %v can be released", vString)
log.Run(task)
// Make sure the issues are loaded.
issues, err := release.loadIssues()
if err != nil {
return errs.NewError(task, err)
}
// Make sure all relevant issues are accepted.
// This includes the issues with SkipCheckLabels.
notAccepted := filterIssues(issues, func(issue *github.Issue) bool {
return abstractState(issue, config) != common.StoryStateAccepted
})
// In case there are no issues in a wrong state, we are done.
if len(notAccepted) == 0 {
return nil
}
// Generate the error hint.
var hint bytes.Buffer
tw := tabwriter.NewWriter(&hint, 0, 8, 2, '\t', 0)
fmt.Fprintf(tw, "\nThe following issues are blocking the release:\n\n")
fmt.Fprintf(tw, "Issue URL\tState\n")
fmt.Fprintf(tw, "=========\t=====\n")
for _, issue := range notAccepted {
fmt.Fprintf(tw, "%v\t%v\n", *issue.HTMLURL, abstractState(issue, config))
}
fmt.Fprintf(tw, "\n")
tw.Flush()
return errs.NewErrorWithHint(task, common.ErrNotClosable, hint.String())
} | [
"func",
"(",
"release",
"*",
"runningRelease",
")",
"EnsureClosable",
"(",
")",
"error",
"{",
"var",
"(",
"config",
"=",
"release",
".",
"tracker",
".",
"config",
"\n",
"vString",
"=",
"release",
".",
"version",
".",
"BaseString",
"(",
")",
"\n",
")",
... | // EnsureClosable is a part of common.RunningRelease interface. | [
"EnsureClosable",
"is",
"a",
"part",
"of",
"common",
".",
"RunningRelease",
"interface",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/modules/issue_tracking/github/release_running.go#L222-L262 |
154,367 | salsaflow/salsaflow | modules/issue_tracking/github/release_running.go | Close | func (release *runningRelease) Close() (action.Action, error) {
_, act, err := release.tracker.closeMilestone(release.version)
return act, err
} | go | func (release *runningRelease) Close() (action.Action, error) {
_, act, err := release.tracker.closeMilestone(release.version)
return act, err
} | [
"func",
"(",
"release",
"*",
"runningRelease",
")",
"Close",
"(",
")",
"(",
"action",
".",
"Action",
",",
"error",
")",
"{",
"_",
",",
"act",
",",
"err",
":=",
"release",
".",
"tracker",
".",
"closeMilestone",
"(",
"release",
".",
"version",
")",
"\n... | // Close is a part of common.RunningRelease interface. | [
"Close",
"is",
"a",
"part",
"of",
"common",
".",
"RunningRelease",
"interface",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/modules/issue_tracking/github/release_running.go#L265-L268 |
154,368 | seven5/seven5 | qbs_store.go | ParamsToDSN | func ParamsToDSN(dbname string, driver string, user string) *qbs.DataSourceName {
if driver == "" {
driver = "postgres"
}
if user == "" {
if u := os.Getenv("PGUSER"); u != "" {
user = u
} else {
user = "postgres"
}
}
dsn := &qbs.DataSourceName{}
dsn.DbName = dbname
dsn.Dialect = StringToDialect(driver)
dsn.Host = "localhost"
dsn.Port = "5432"
dsn.Username = user
return dsn
} | go | func ParamsToDSN(dbname string, driver string, user string) *qbs.DataSourceName {
if driver == "" {
driver = "postgres"
}
if user == "" {
if u := os.Getenv("PGUSER"); u != "" {
user = u
} else {
user = "postgres"
}
}
dsn := &qbs.DataSourceName{}
dsn.DbName = dbname
dsn.Dialect = StringToDialect(driver)
dsn.Host = "localhost"
dsn.Port = "5432"
dsn.Username = user
return dsn
} | [
"func",
"ParamsToDSN",
"(",
"dbname",
"string",
",",
"driver",
"string",
",",
"user",
"string",
")",
"*",
"qbs",
".",
"DataSourceName",
"{",
"if",
"driver",
"==",
"\"",
"\"",
"{",
"driver",
"=",
"\"",
"\"",
"\n",
"}",
"\n",
"if",
"user",
"==",
"\"",
... | //ParamsToDSN allows you to create a DSN directly from some values. This
//is useful for testing. If driver or user is "", the default driver and
//user are used. | [
"ParamsToDSN",
"allows",
"you",
"to",
"create",
"a",
"DSN",
"directly",
"from",
"some",
"values",
".",
"This",
"is",
"useful",
"for",
"testing",
".",
"If",
"driver",
"or",
"user",
"is",
"the",
"default",
"driver",
"and",
"user",
"are",
"used",
"."
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/qbs_store.go#L34-L52 |
154,369 | seven5/seven5 | qbs_store.go | GetDSNOrDie | func GetDSNOrDie() *qbs.DataSourceName {
db := os.Getenv("DATABASE_URL")
if db == "" {
panic("no DATABASE_URL found, cannot connect to a *QbsStore")
}
u, err := url.Parse(db)
if err != nil {
panic(fmt.Sprintf("unable to parse database URL: %s", err))
}
log.Printf("DATABASE_URL found, connecting to %+v\n", u)
dsn := &qbs.DataSourceName{}
dsn.DbName = u.Path[1:]
dsn.Host = u.Host
if strings.Index(u.Host, ":") != -1 {
pair := strings.Split(u.Host, ":")
if len(pair) != 2 {
panic("badly formed host:port")
}
dsn.Host = pair[0]
dsn.Port = pair[1]
}
p, set := u.User.Password()
if set {
dsn.Password = p
}
dsn.Username = u.User.Username()
dsn.Dialect = StringToDialect(u.Scheme)
return dsn
} | go | func GetDSNOrDie() *qbs.DataSourceName {
db := os.Getenv("DATABASE_URL")
if db == "" {
panic("no DATABASE_URL found, cannot connect to a *QbsStore")
}
u, err := url.Parse(db)
if err != nil {
panic(fmt.Sprintf("unable to parse database URL: %s", err))
}
log.Printf("DATABASE_URL found, connecting to %+v\n", u)
dsn := &qbs.DataSourceName{}
dsn.DbName = u.Path[1:]
dsn.Host = u.Host
if strings.Index(u.Host, ":") != -1 {
pair := strings.Split(u.Host, ":")
if len(pair) != 2 {
panic("badly formed host:port")
}
dsn.Host = pair[0]
dsn.Port = pair[1]
}
p, set := u.User.Password()
if set {
dsn.Password = p
}
dsn.Username = u.User.Username()
dsn.Dialect = StringToDialect(u.Scheme)
return dsn
} | [
"func",
"GetDSNOrDie",
"(",
")",
"*",
"qbs",
".",
"DataSourceName",
"{",
"db",
":=",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
"\n",
"if",
"db",
"==",
"\"",
"\"",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"u",
",",
"err",
":=",
"u... | //This function returns the datasource name for the DATABASE_URL
//in the environment. If the value cannot be found, this panics. | [
"This",
"function",
"returns",
"the",
"datasource",
"name",
"for",
"the",
"DATABASE_URL",
"in",
"the",
"environment",
".",
"If",
"the",
"value",
"cannot",
"be",
"found",
"this",
"panics",
"."
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/qbs_store.go#L56-L85 |
154,370 | seven5/seven5 | qbs_store.go | StringToDialect | func StringToDialect(n string) qbs.Dialect {
switch n {
case "postgres":
return qbs.NewPostgres()
case "sqlite3":
return qbs.NewSqlite3()
}
panic(fmt.Sprintf("unable to deal with db dialect provided %s", n))
} | go | func StringToDialect(n string) qbs.Dialect {
switch n {
case "postgres":
return qbs.NewPostgres()
case "sqlite3":
return qbs.NewSqlite3()
}
panic(fmt.Sprintf("unable to deal with db dialect provided %s", n))
} | [
"func",
"StringToDialect",
"(",
"n",
"string",
")",
"qbs",
".",
"Dialect",
"{",
"switch",
"n",
"{",
"case",
"\"",
"\"",
":",
"return",
"qbs",
".",
"NewPostgres",
"(",
")",
"\n",
"case",
"\"",
"\"",
":",
"return",
"qbs",
".",
"NewSqlite3",
"(",
")",
... | //StringToDialect returns an sql dialect for use with QBS given a string
//name. IF the name is not known, this code panics. | [
"StringToDialect",
"returns",
"an",
"sql",
"dialect",
"for",
"use",
"with",
"QBS",
"given",
"a",
"string",
"name",
".",
"IF",
"the",
"name",
"is",
"not",
"known",
"this",
"code",
"panics",
"."
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/qbs_store.go#L89-L97 |
154,371 | seven5/seven5 | qbs_store.go | StartTransaction | func (self *QbsDefaultOrmTransactionPolicy) StartTransaction(q *qbs.Qbs) *qbs.Qbs {
if err := q.Begin(); err != nil {
if err.Error() == "EOF" {
log.Printf("It's likely there is something listening on your server port that isn't the database you expected.")
}
panic(err)
}
return q
} | go | func (self *QbsDefaultOrmTransactionPolicy) StartTransaction(q *qbs.Qbs) *qbs.Qbs {
if err := q.Begin(); err != nil {
if err.Error() == "EOF" {
log.Printf("It's likely there is something listening on your server port that isn't the database you expected.")
}
panic(err)
}
return q
} | [
"func",
"(",
"self",
"*",
"QbsDefaultOrmTransactionPolicy",
")",
"StartTransaction",
"(",
"q",
"*",
"qbs",
".",
"Qbs",
")",
"*",
"qbs",
".",
"Qbs",
"{",
"if",
"err",
":=",
"q",
".",
"Begin",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"if",
"err",
".",... | //StartTransaction returns a new qbs object after creating the transaction. | [
"StartTransaction",
"returns",
"a",
"new",
"qbs",
"object",
"after",
"creating",
"the",
"transaction",
"."
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/qbs_store.go#L108-L116 |
154,372 | seven5/seven5 | qbs_store.go | HandleResult | func (self *QbsDefaultOrmTransactionPolicy) HandleResult(tx *qbs.Qbs, value interface{}, err error) (interface{}, error) {
if err != nil {
switch e := err.(type) {
case *Error:
if e.StatusCode >= 400 {
rerr := tx.Rollback()
if rerr != nil {
return nil, rerr
}
}
default:
rerr := tx.Rollback()
if rerr != nil {
return nil, rerr
}
return nil, HTTPError(http.StatusInternalServerError, fmt.Sprintf("%v", err))
}
} else {
if cerr := tx.Commit(); cerr != nil {
return nil, cerr
}
}
return value, err
} | go | func (self *QbsDefaultOrmTransactionPolicy) HandleResult(tx *qbs.Qbs, value interface{}, err error) (interface{}, error) {
if err != nil {
switch e := err.(type) {
case *Error:
if e.StatusCode >= 400 {
rerr := tx.Rollback()
if rerr != nil {
return nil, rerr
}
}
default:
rerr := tx.Rollback()
if rerr != nil {
return nil, rerr
}
return nil, HTTPError(http.StatusInternalServerError, fmt.Sprintf("%v", err))
}
} else {
if cerr := tx.Commit(); cerr != nil {
return nil, cerr
}
}
return value, err
} | [
"func",
"(",
"self",
"*",
"QbsDefaultOrmTransactionPolicy",
")",
"HandleResult",
"(",
"tx",
"*",
"qbs",
".",
"Qbs",
",",
"value",
"interface",
"{",
"}",
",",
"err",
"error",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"if",
"err",
"!=",
... | //HandleResult determines whether or not the transaction provided should be rolled
//back or if it should be committed. It rolls back when the result value is
//a non-http error, if it is an Error and the status code is >= 400. | [
"HandleResult",
"determines",
"whether",
"or",
"not",
"the",
"transaction",
"provided",
"should",
"be",
"rolled",
"back",
"or",
"if",
"it",
"should",
"be",
"committed",
".",
"It",
"rolls",
"back",
"when",
"the",
"result",
"value",
"is",
"a",
"non",
"-",
"h... | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/qbs_store.go#L121-L144 |
154,373 | seven5/seven5 | qbs_store.go | HandlePanic | func (self *QbsDefaultOrmTransactionPolicy) HandlePanic(tx *qbs.Qbs, err interface{}) (interface{}, error) {
log.Printf("got panic, rolling back and returning 500 to client (%v)\n", err)
if rerr := tx.Rollback(); rerr != nil {
panic(rerr)
}
return nil, HTTPError(http.StatusInternalServerError, fmt.Sprintf("panic: %v", err))
} | go | func (self *QbsDefaultOrmTransactionPolicy) HandlePanic(tx *qbs.Qbs, err interface{}) (interface{}, error) {
log.Printf("got panic, rolling back and returning 500 to client (%v)\n", err)
if rerr := tx.Rollback(); rerr != nil {
panic(rerr)
}
return nil, HTTPError(http.StatusInternalServerError, fmt.Sprintf("panic: %v", err))
} | [
"func",
"(",
"self",
"*",
"QbsDefaultOrmTransactionPolicy",
")",
"HandlePanic",
"(",
"tx",
"*",
"qbs",
".",
"Qbs",
",",
"err",
"interface",
"{",
"}",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\\n",
"\"... | //HandlePanic rolls back the transiction provided and then panics again. | [
"HandlePanic",
"rolls",
"back",
"the",
"transiction",
"provided",
"and",
"then",
"panics",
"again",
"."
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/qbs_store.go#L147-L153 |
154,374 | salsaflow/salsaflow | config/loader/bootstrap.go | RegisterBootstrapConfigSpec | func RegisterBootstrapConfigSpec(spec ConfigSpec) {
key := spec.ConfigKey()
for _, s := range bootstrapSpecs {
if s.ConfigKey() == key {
return
}
}
bootstrapSpecs = append(bootstrapSpecs, spec)
} | go | func RegisterBootstrapConfigSpec(spec ConfigSpec) {
key := spec.ConfigKey()
for _, s := range bootstrapSpecs {
if s.ConfigKey() == key {
return
}
}
bootstrapSpecs = append(bootstrapSpecs, spec)
} | [
"func",
"RegisterBootstrapConfigSpec",
"(",
"spec",
"ConfigSpec",
")",
"{",
"key",
":=",
"spec",
".",
"ConfigKey",
"(",
")",
"\n",
"for",
"_",
",",
"s",
":=",
"range",
"bootstrapSpecs",
"{",
"if",
"s",
".",
"ConfigKey",
"(",
")",
"==",
"key",
"{",
"ret... | // RegisterBootstrapConfigSpec can be used to register a config spec
// that is run during `repo bootstrap`.
//
// This function is exported for internal use by SalsaFlow packages,
// it is not supposed to be used by modules. | [
"RegisterBootstrapConfigSpec",
"can",
"be",
"used",
"to",
"register",
"a",
"config",
"spec",
"that",
"is",
"run",
"during",
"repo",
"bootstrap",
".",
"This",
"function",
"is",
"exported",
"for",
"internal",
"use",
"by",
"SalsaFlow",
"packages",
"it",
"is",
"no... | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/config/loader/bootstrap.go#L10-L18 |
154,375 | seven5/seven5 | client/css.go | newHtmlIdNoCheck | func newHtmlIdNoCheck(tag, id string) HtmlId {
if TestMode {
return htmlIdImpl{
tag: tag,
id: id,
t: newTestOps(),
cache: make(map[string]DomAttribute),
}
}
jq := jquery.NewJQuery(tag + "#" + id)
return htmlIdImpl{
tag: tag,
id: id,
t: wrap(jq),
cache: make(map[string]DomAttribute),
}
} | go | func newHtmlIdNoCheck(tag, id string) HtmlId {
if TestMode {
return htmlIdImpl{
tag: tag,
id: id,
t: newTestOps(),
cache: make(map[string]DomAttribute),
}
}
jq := jquery.NewJQuery(tag + "#" + id)
return htmlIdImpl{
tag: tag,
id: id,
t: wrap(jq),
cache: make(map[string]DomAttribute),
}
} | [
"func",
"newHtmlIdNoCheck",
"(",
"tag",
",",
"id",
"string",
")",
"HtmlId",
"{",
"if",
"TestMode",
"{",
"return",
"htmlIdImpl",
"{",
"tag",
":",
"tag",
",",
"id",
":",
"id",
",",
"t",
":",
"newTestOps",
"(",
")",
",",
"cache",
":",
"make",
"(",
"ma... | //newHtmlIdNoCheck is the same as NewHtmlId except that no check is performed
//to see if the named element exists in the DOM. This is useful in a few cases
//where dynamically constructed HTML but should not be used by client code
//because it is error prone. | [
"newHtmlIdNoCheck",
"is",
"the",
"same",
"as",
"NewHtmlId",
"except",
"that",
"no",
"check",
"is",
"performed",
"to",
"see",
"if",
"the",
"named",
"element",
"exists",
"in",
"the",
"DOM",
".",
"This",
"is",
"useful",
"in",
"a",
"few",
"cases",
"where",
"... | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/client/css.go#L60-L77 |
154,376 | seven5/seven5 | client/css.go | StyleAttribute | func (self htmlIdImpl) StyleAttribute(name string) DomAttribute {
return self.getOrCreateAttribute("style:"+name, func() DomAttribute {
return NewStyleAttr(name, self.t)
})
} | go | func (self htmlIdImpl) StyleAttribute(name string) DomAttribute {
return self.getOrCreateAttribute("style:"+name, func() DomAttribute {
return NewStyleAttr(name, self.t)
})
} | [
"func",
"(",
"self",
"htmlIdImpl",
")",
"StyleAttribute",
"(",
"name",
"string",
")",
"DomAttribute",
"{",
"return",
"self",
".",
"getOrCreateAttribute",
"(",
"\"",
"\"",
"+",
"name",
",",
"func",
"(",
")",
"DomAttribute",
"{",
"return",
"NewStyleAttr",
"(",... | //StyleAttribute returns the dom style attribute for the given name
//on the dom element selected by this object. | [
"StyleAttribute",
"returns",
"the",
"dom",
"style",
"attribute",
"for",
"the",
"given",
"name",
"on",
"the",
"dom",
"element",
"selected",
"by",
"this",
"object",
"."
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/client/css.go#L146-L150 |
154,377 | seven5/seven5 | client/css.go | DisplayAttribute | func (self htmlIdImpl) DisplayAttribute() DomAttribute {
return self.getOrCreateAttribute("display", func() DomAttribute {
return NewDisplayAttr(self.t)
})
} | go | func (self htmlIdImpl) DisplayAttribute() DomAttribute {
return self.getOrCreateAttribute("display", func() DomAttribute {
return NewDisplayAttr(self.t)
})
} | [
"func",
"(",
"self",
"htmlIdImpl",
")",
"DisplayAttribute",
"(",
")",
"DomAttribute",
"{",
"return",
"self",
".",
"getOrCreateAttribute",
"(",
"\"",
"\"",
",",
"func",
"(",
")",
"DomAttribute",
"{",
"return",
"NewDisplayAttr",
"(",
"self",
".",
"t",
")",
"... | //DisplayAttribute returns the dom style attribute "display" and
//expects this to be connected to a constraint returning boolean. | [
"DisplayAttribute",
"returns",
"the",
"dom",
"style",
"attribute",
"display",
"and",
"expects",
"this",
"to",
"be",
"connected",
"to",
"a",
"constraint",
"returning",
"boolean",
"."
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/client/css.go#L154-L158 |
154,378 | seven5/seven5 | client/css.go | CssExistenceAttribute | func (self htmlIdImpl) CssExistenceAttribute(clazz CssClass) DomAttribute {
return self.getOrCreateAttribute("cssexist:"+clazz.ClassName(), func() DomAttribute {
return NewCssExistenceAttr(self.t, clazz)
})
} | go | func (self htmlIdImpl) CssExistenceAttribute(clazz CssClass) DomAttribute {
return self.getOrCreateAttribute("cssexist:"+clazz.ClassName(), func() DomAttribute {
return NewCssExistenceAttr(self.t, clazz)
})
} | [
"func",
"(",
"self",
"htmlIdImpl",
")",
"CssExistenceAttribute",
"(",
"clazz",
"CssClass",
")",
"DomAttribute",
"{",
"return",
"self",
".",
"getOrCreateAttribute",
"(",
"\"",
"\"",
"+",
"clazz",
".",
"ClassName",
"(",
")",
",",
"func",
"(",
")",
"DomAttribut... | //CssExistenceAttribute returns an attribute that is hooked to
//particular CSS closs. | [
"CssExistenceAttribute",
"returns",
"an",
"attribute",
"that",
"is",
"hooked",
"to",
"particular",
"CSS",
"closs",
"."
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/client/css.go#L162-L166 |
154,379 | seven5/seven5 | client/css.go | TextAttribute | func (self htmlIdImpl) TextAttribute() DomAttribute {
return self.getOrCreateAttribute("text", func() DomAttribute {
return NewTextAttr(self.t)
})
} | go | func (self htmlIdImpl) TextAttribute() DomAttribute {
return self.getOrCreateAttribute("text", func() DomAttribute {
return NewTextAttr(self.t)
})
} | [
"func",
"(",
"self",
"htmlIdImpl",
")",
"TextAttribute",
"(",
")",
"DomAttribute",
"{",
"return",
"self",
".",
"getOrCreateAttribute",
"(",
"\"",
"\"",
",",
"func",
"(",
")",
"DomAttribute",
"{",
"return",
"NewTextAttr",
"(",
"self",
".",
"t",
")",
"\n",
... | //TextAttribute returns the dom text attribute for the dom element
//selected by this object. | [
"TextAttribute",
"returns",
"the",
"dom",
"text",
"attribute",
"for",
"the",
"dom",
"element",
"selected",
"by",
"this",
"object",
"."
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/client/css.go#L170-L174 |
154,380 | seven5/seven5 | err.go | WriteError | func WriteError(w http.ResponseWriter, err error) {
ourError, ok := err.(*Error)
if ok {
http.Error(w, ourError.Msg, ourError.StatusCode)
} else {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
} | go | func WriteError(w http.ResponseWriter, err error) {
ourError, ok := err.(*Error)
if ok {
http.Error(w, ourError.Msg, ourError.StatusCode)
} else {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
} | [
"func",
"WriteError",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"err",
"error",
")",
"{",
"ourError",
",",
"ok",
":=",
"err",
".",
"(",
"*",
"Error",
")",
"\n",
"if",
"ok",
"{",
"http",
".",
"Error",
"(",
"w",
",",
"ourError",
".",
"Msg",
","... | //WriteError returns an error to the client side. If the err is of type
//Error, we decode the fields to produce the correct message and response
//code. Otherwise, we return the string of the error content plus the code
//http.StatusInternalServerError. | [
"WriteError",
"returns",
"an",
"error",
"to",
"the",
"client",
"side",
".",
"If",
"the",
"err",
"is",
"of",
"type",
"Error",
"we",
"decode",
"the",
"fields",
"to",
"produce",
"the",
"correct",
"message",
"and",
"response",
"code",
".",
"Otherwise",
"we",
... | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/err.go#L30-L37 |
154,381 | itchio/httpkit | timeout/monitoring_conn.go | GetBPS | func GetBPS() float64 {
lock.Lock()
defer lock.Unlock()
bucketDuration := time.Since(lastBandwidthUpdate)
if bucketDuration > maxBucketDuration*2 {
// if we don't read anything from the network in a while,
// bps won't update, but it should be 0
return 0.0
}
return bps
} | go | func GetBPS() float64 {
lock.Lock()
defer lock.Unlock()
bucketDuration := time.Since(lastBandwidthUpdate)
if bucketDuration > maxBucketDuration*2 {
// if we don't read anything from the network in a while,
// bps won't update, but it should be 0
return 0.0
}
return bps
} | [
"func",
"GetBPS",
"(",
")",
"float64",
"{",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"lock",
".",
"Unlock",
"(",
")",
"\n\n",
"bucketDuration",
":=",
"time",
".",
"Since",
"(",
"lastBandwidthUpdate",
")",
"\n\n",
"if",
"bucketDuration",
">",
"maxBuc... | // GetBPS returns the last measured number of bytes transferred
// in a 1-second interval as a floating point value. | [
"GetBPS",
"returns",
"the",
"last",
"measured",
"number",
"of",
"bytes",
"transferred",
"in",
"a",
"1",
"-",
"second",
"interval",
"as",
"a",
"floating",
"point",
"value",
"."
] | f7051ef345456d077d49344cf6ec98b4059214f5 | https://github.com/itchio/httpkit/blob/f7051ef345456d077d49344cf6ec98b4059214f5/timeout/monitoring_conn.go#L79-L92 |
154,382 | salsaflow/salsaflow | modules/issue_tracking/pivotaltracker/config.go | LocalConfig | func (spec *configSpec) LocalConfig() loader.ConfigContainer {
spec.local = &LocalConfig{spec: spec}
return spec.local
} | go | func (spec *configSpec) LocalConfig() loader.ConfigContainer {
spec.local = &LocalConfig{spec: spec}
return spec.local
} | [
"func",
"(",
"spec",
"*",
"configSpec",
")",
"LocalConfig",
"(",
")",
"loader",
".",
"ConfigContainer",
"{",
"spec",
".",
"local",
"=",
"&",
"LocalConfig",
"{",
"spec",
":",
"spec",
"}",
"\n",
"return",
"spec",
".",
"local",
"\n",
"}"
] | // LocalConfig is a part of loader.ConfigSpec | [
"LocalConfig",
"is",
"a",
"part",
"of",
"loader",
".",
"ConfigSpec"
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/modules/issue_tracking/pivotaltracker/config.go#L86-L89 |
154,383 | salsaflow/salsaflow | modules/issue_tracking/github/issue_tracker.go | CurrentUser | func (tracker *issueTracker) CurrentUser() (common.User, error) {
task := "Get the GitHub user record for the authenticated user"
client := tracker.newClient()
var (
me *github.User
err error
)
withRequestAllocated(func() {
me, _, err = client.Users.Get("")
})
if err != nil {
return nil, errs.NewError(task, err)
}
return &user{me}, nil
} | go | func (tracker *issueTracker) CurrentUser() (common.User, error) {
task := "Get the GitHub user record for the authenticated user"
client := tracker.newClient()
var (
me *github.User
err error
)
withRequestAllocated(func() {
me, _, err = client.Users.Get("")
})
if err != nil {
return nil, errs.NewError(task, err)
}
return &user{me}, nil
} | [
"func",
"(",
"tracker",
"*",
"issueTracker",
")",
"CurrentUser",
"(",
")",
"(",
"common",
".",
"User",
",",
"error",
")",
"{",
"task",
":=",
"\"",
"\"",
"\n",
"client",
":=",
"tracker",
".",
"newClient",
"(",
")",
"\n\n",
"var",
"(",
"me",
"*",
"gi... | // CurrentUser is a part of common.IssueTracker interface. | [
"CurrentUser",
"is",
"a",
"part",
"of",
"common",
".",
"IssueTracker",
"interface",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/modules/issue_tracking/github/issue_tracker.go#L44-L60 |
154,384 | salsaflow/salsaflow | modules/issue_tracking/github/issue_tracker.go | StartableStories | func (tracker *issueTracker) StartableStories() ([]common.Story, error) {
return tracker.searchIssuesAndWrap(`state:open label:"%v"`, tracker.config.ApprovedLabel)
} | go | func (tracker *issueTracker) StartableStories() ([]common.Story, error) {
return tracker.searchIssuesAndWrap(`state:open label:"%v"`, tracker.config.ApprovedLabel)
} | [
"func",
"(",
"tracker",
"*",
"issueTracker",
")",
"StartableStories",
"(",
")",
"(",
"[",
"]",
"common",
".",
"Story",
",",
"error",
")",
"{",
"return",
"tracker",
".",
"searchIssuesAndWrap",
"(",
"`state:open label:\"%v\"`",
",",
"tracker",
".",
"config",
"... | // StartableStories is a part of common.IssueTracker interface. | [
"StartableStories",
"is",
"a",
"part",
"of",
"common",
".",
"IssueTracker",
"interface",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/modules/issue_tracking/github/issue_tracker.go#L63-L65 |
154,385 | salsaflow/salsaflow | modules/issue_tracking/github/issue_tracker.go | ReviewableStories | func (tracker *issueTracker) ReviewableStories() ([]common.Story, error) {
// Prepare the accumulator for GitHub issues.
var issues []*github.Issue
// Send the search requests concurrently.
ch := make(chan *searchResult, 2)
tracker.goSearchIssues(ch, `state:open label:"%v"`, tracker.config.BeingImplementedLabel)
tracker.goSearchIssues(ch, `state:open label:"%v"`, tracker.config.ImplementedLabel)
// Collect the results.
for i := 0; i < cap(ch); i++ {
res := <-ch
// In case there is an error, return immediately,
// even though there might be some requests still in progress.
if err := res.err; err != nil {
return nil, err
}
// Append the received issues to the accumulator.
issues = append(issues, res.issues...)
}
// Return the results.
return toCommonStories(issues, tracker), nil
} | go | func (tracker *issueTracker) ReviewableStories() ([]common.Story, error) {
// Prepare the accumulator for GitHub issues.
var issues []*github.Issue
// Send the search requests concurrently.
ch := make(chan *searchResult, 2)
tracker.goSearchIssues(ch, `state:open label:"%v"`, tracker.config.BeingImplementedLabel)
tracker.goSearchIssues(ch, `state:open label:"%v"`, tracker.config.ImplementedLabel)
// Collect the results.
for i := 0; i < cap(ch); i++ {
res := <-ch
// In case there is an error, return immediately,
// even though there might be some requests still in progress.
if err := res.err; err != nil {
return nil, err
}
// Append the received issues to the accumulator.
issues = append(issues, res.issues...)
}
// Return the results.
return toCommonStories(issues, tracker), nil
} | [
"func",
"(",
"tracker",
"*",
"issueTracker",
")",
"ReviewableStories",
"(",
")",
"(",
"[",
"]",
"common",
".",
"Story",
",",
"error",
")",
"{",
"// Prepare the accumulator for GitHub issues.",
"var",
"issues",
"[",
"]",
"*",
"github",
".",
"Issue",
"\n\n",
"... | // ReviewableStories is a part of common.IssueTracker interface. | [
"ReviewableStories",
"is",
"a",
"part",
"of",
"common",
".",
"IssueTracker",
"interface",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/modules/issue_tracking/github/issue_tracker.go#L68-L91 |
154,386 | salsaflow/salsaflow | modules/issue_tracking/github/issue_tracker.go | ReviewedStories | func (tracker *issueTracker) ReviewedStories() (stories []common.Story, err error) {
return tracker.searchIssuesAndWrap(`state:open label:"%v"`, tracker.config.ReviewedLabel)
} | go | func (tracker *issueTracker) ReviewedStories() (stories []common.Story, err error) {
return tracker.searchIssuesAndWrap(`state:open label:"%v"`, tracker.config.ReviewedLabel)
} | [
"func",
"(",
"tracker",
"*",
"issueTracker",
")",
"ReviewedStories",
"(",
")",
"(",
"stories",
"[",
"]",
"common",
".",
"Story",
",",
"err",
"error",
")",
"{",
"return",
"tracker",
".",
"searchIssuesAndWrap",
"(",
"`state:open label:\"%v\"`",
",",
"tracker",
... | // ReviewedStories is a part of common.IssueTracker interface. | [
"ReviewedStories",
"is",
"a",
"part",
"of",
"common",
".",
"IssueTracker",
"interface",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/modules/issue_tracking/github/issue_tracker.go#L94-L96 |
154,387 | salsaflow/salsaflow | modules/issue_tracking/github/issue_tracker.go | ListStoriesByTag | func (tracker *issueTracker) ListStoriesByTag(tags []string) ([]common.Story, error) {
// Convert tags to ids.
ids := make([]int, 0, len(tags))
for _, tag := range tags {
readableId, err := tracker.StoryTagToReadableStoryId(tag)
if err != nil {
return nil, err
}
// A readable ID is actually #issueNum, so we split '#' away.
id, err := strconv.Atoi(readableId[1:])
if err != nil {
panic(err)
}
ids = append(ids, id)
}
// Fetch the relevant stories.
issues, err := tracker.issuesByNumberOrdered(ids)
if err != nil {
return nil, err
}
// Convert to []common.Story and return.
return toCommonStories(issues, tracker), nil
} | go | func (tracker *issueTracker) ListStoriesByTag(tags []string) ([]common.Story, error) {
// Convert tags to ids.
ids := make([]int, 0, len(tags))
for _, tag := range tags {
readableId, err := tracker.StoryTagToReadableStoryId(tag)
if err != nil {
return nil, err
}
// A readable ID is actually #issueNum, so we split '#' away.
id, err := strconv.Atoi(readableId[1:])
if err != nil {
panic(err)
}
ids = append(ids, id)
}
// Fetch the relevant stories.
issues, err := tracker.issuesByNumberOrdered(ids)
if err != nil {
return nil, err
}
// Convert to []common.Story and return.
return toCommonStories(issues, tracker), nil
} | [
"func",
"(",
"tracker",
"*",
"issueTracker",
")",
"ListStoriesByTag",
"(",
"tags",
"[",
"]",
"string",
")",
"(",
"[",
"]",
"common",
".",
"Story",
",",
"error",
")",
"{",
"// Convert tags to ids.",
"ids",
":=",
"make",
"(",
"[",
"]",
"int",
",",
"0",
... | // ListStoriesByTag is a part of common.IssueTracker interface. | [
"ListStoriesByTag",
"is",
"a",
"part",
"of",
"common",
".",
"IssueTracker",
"interface",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/modules/issue_tracking/github/issue_tracker.go#L99-L123 |
154,388 | salsaflow/salsaflow | modules/issue_tracking/github/issue_tracker.go | ListStoriesByRelease | func (tracker *issueTracker) ListStoriesByRelease(v *version.Version) ([]common.Story, error) {
issues, err := tracker.issuesByRelease(v)
if err != nil {
return nil, err
}
return toCommonStories(issues, tracker), nil
} | go | func (tracker *issueTracker) ListStoriesByRelease(v *version.Version) ([]common.Story, error) {
issues, err := tracker.issuesByRelease(v)
if err != nil {
return nil, err
}
return toCommonStories(issues, tracker), nil
} | [
"func",
"(",
"tracker",
"*",
"issueTracker",
")",
"ListStoriesByRelease",
"(",
"v",
"*",
"version",
".",
"Version",
")",
"(",
"[",
"]",
"common",
".",
"Story",
",",
"error",
")",
"{",
"issues",
",",
"err",
":=",
"tracker",
".",
"issuesByRelease",
"(",
... | // ListStoriesByRelease is a part of common.IssueTracker interface. | [
"ListStoriesByRelease",
"is",
"a",
"part",
"of",
"common",
".",
"IssueTracker",
"interface",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/modules/issue_tracking/github/issue_tracker.go#L126-L132 |
154,389 | salsaflow/salsaflow | modules/issue_tracking/github/issue_tracker.go | OpenStory | func (tracker *issueTracker) OpenStory(storyId string) error {
u := fmt.Sprintf("https://github.com/%v/%v/issues/%v",
tracker.config.GitHubOwner, tracker.config.GitHubRepository, storyId)
return webbrowser.Open(u)
} | go | func (tracker *issueTracker) OpenStory(storyId string) error {
u := fmt.Sprintf("https://github.com/%v/%v/issues/%v",
tracker.config.GitHubOwner, tracker.config.GitHubRepository, storyId)
return webbrowser.Open(u)
} | [
"func",
"(",
"tracker",
"*",
"issueTracker",
")",
"OpenStory",
"(",
"storyId",
"string",
")",
"error",
"{",
"u",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"tracker",
".",
"config",
".",
"GitHubOwner",
",",
"tracker",
".",
"config",
".",
"GitHu... | // OpenStory is a part of common.IssueTracker interface. | [
"OpenStory",
"is",
"a",
"part",
"of",
"common",
".",
"IssueTracker",
"interface",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/modules/issue_tracking/github/issue_tracker.go#L152-L157 |
154,390 | salsaflow/salsaflow | modules/issue_tracking/github/issue_tracker.go | StoryTagToReadableStoryId | func (tracker *issueTracker) StoryTagToReadableStoryId(tag string) (storyId string, err error) {
// The format is owner/repo#issueNum
re := regexp.MustCompile("^[^/]+/[^#]+(#[0-9]+)$")
match := re.FindStringSubmatch(tag)
if len(match) == 0 {
return "", fmt.Errorf("invalid GitHub issue tag: %v", tag)
}
return match[1], nil
} | go | func (tracker *issueTracker) StoryTagToReadableStoryId(tag string) (storyId string, err error) {
// The format is owner/repo#issueNum
re := regexp.MustCompile("^[^/]+/[^#]+(#[0-9]+)$")
match := re.FindStringSubmatch(tag)
if len(match) == 0 {
return "", fmt.Errorf("invalid GitHub issue tag: %v", tag)
}
return match[1], nil
} | [
"func",
"(",
"tracker",
"*",
"issueTracker",
")",
"StoryTagToReadableStoryId",
"(",
"tag",
"string",
")",
"(",
"storyId",
"string",
",",
"err",
"error",
")",
"{",
"// The format is owner/repo#issueNum",
"re",
":=",
"regexp",
".",
"MustCompile",
"(",
"\"",
"\"",
... | // StoryIdToReadableStoryId is a part of common.IssueTracker interface. | [
"StoryIdToReadableStoryId",
"is",
"a",
"part",
"of",
"common",
".",
"IssueTracker",
"interface",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/modules/issue_tracking/github/issue_tracker.go#L160-L168 |
154,391 | salsaflow/salsaflow | modules/issue_tracking/github/issue_tracker.go | searchIssues | func (tracker *issueTracker) searchIssues(
queryFormat string,
v ...interface{},
) ([]*github.Issue, error) {
logger := log.V(log.Debug)
// Format the query.
query := fmt.Sprintf(queryFormat, v...)
// Since GH API does not allow OR queries, we need to send a concurrent request
// for every item in tracker.config.StoryLabels label list.
ch := make(chan *searchResult, len(tracker.config.StoryLabels))
for _, label := range tracker.config.StoryLabels {
go func(label string) {
// We are only interested in issues for the given repository.
innerQuery := fmt.Sprintf(`%v type:issue repo:%v/%v label:"%v"`,
query, tracker.config.GitHubOwner, tracker.config.GitHubRepository, label)
task := "Search GitHub: " + innerQuery
if logger {
logger.Go(task)
}
searchOpts := &github.SearchOptions{}
searchOpts.Page = 1
searchOpts.PerPage = 50
var (
acc []*github.Issue
searched int
)
client := tracker.newClient()
for {
// Fetch another page.
var (
result *github.IssuesSearchResult
err error
)
withRequestAllocated(func() {
result, _, err = client.Search.Issues(innerQuery, searchOpts)
})
if err != nil {
ch <- &searchResult{nil, errs.NewError(task, err)}
return
}
// Check the issues for exact string match.
for i := range result.Issues {
acc = append(acc, &result.Issues[i])
}
// Check whether we have reached the end or not.
searched += len(result.Issues)
if searched == *result.Total {
ch <- &searchResult{acc, nil}
return
}
// Check the next page in the next iteration.
searchOpts.Page += 1
}
}(label)
}
// Collect the results.
var issues []*github.Issue
for i := 0; i < cap(ch); i++ {
res := <-ch
if err := res.err; err != nil {
return nil, err
}
issues = append(issues, res.issues...)
}
// Make sure there are no duplicates in the list.
return dedupeIssues(issues), nil
} | go | func (tracker *issueTracker) searchIssues(
queryFormat string,
v ...interface{},
) ([]*github.Issue, error) {
logger := log.V(log.Debug)
// Format the query.
query := fmt.Sprintf(queryFormat, v...)
// Since GH API does not allow OR queries, we need to send a concurrent request
// for every item in tracker.config.StoryLabels label list.
ch := make(chan *searchResult, len(tracker.config.StoryLabels))
for _, label := range tracker.config.StoryLabels {
go func(label string) {
// We are only interested in issues for the given repository.
innerQuery := fmt.Sprintf(`%v type:issue repo:%v/%v label:"%v"`,
query, tracker.config.GitHubOwner, tracker.config.GitHubRepository, label)
task := "Search GitHub: " + innerQuery
if logger {
logger.Go(task)
}
searchOpts := &github.SearchOptions{}
searchOpts.Page = 1
searchOpts.PerPage = 50
var (
acc []*github.Issue
searched int
)
client := tracker.newClient()
for {
// Fetch another page.
var (
result *github.IssuesSearchResult
err error
)
withRequestAllocated(func() {
result, _, err = client.Search.Issues(innerQuery, searchOpts)
})
if err != nil {
ch <- &searchResult{nil, errs.NewError(task, err)}
return
}
// Check the issues for exact string match.
for i := range result.Issues {
acc = append(acc, &result.Issues[i])
}
// Check whether we have reached the end or not.
searched += len(result.Issues)
if searched == *result.Total {
ch <- &searchResult{acc, nil}
return
}
// Check the next page in the next iteration.
searchOpts.Page += 1
}
}(label)
}
// Collect the results.
var issues []*github.Issue
for i := 0; i < cap(ch); i++ {
res := <-ch
if err := res.err; err != nil {
return nil, err
}
issues = append(issues, res.issues...)
}
// Make sure there are no duplicates in the list.
return dedupeIssues(issues), nil
} | [
"func",
"(",
"tracker",
"*",
"issueTracker",
")",
"searchIssues",
"(",
"queryFormat",
"string",
",",
"v",
"...",
"interface",
"{",
"}",
",",
")",
"(",
"[",
"]",
"*",
"github",
".",
"Issue",
",",
"error",
")",
"{",
"logger",
":=",
"log",
".",
"V",
"... | // searchIssues can be used to query GitHub for issues matching the given filter.
// It handles pagination internally, it fetches all matching issues automatically. | [
"searchIssues",
"can",
"be",
"used",
"to",
"query",
"GitHub",
"for",
"issues",
"matching",
"the",
"given",
"filter",
".",
"It",
"handles",
"pagination",
"internally",
"it",
"fetches",
"all",
"matching",
"issues",
"automatically",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/modules/issue_tracking/github/issue_tracker.go#L183-L263 |
154,392 | salsaflow/salsaflow | modules/issue_tracking/github/issue_tracker.go | goSearchIssues | func (tracker *issueTracker) goSearchIssues(
ch chan<- *searchResult,
queryFormat string,
v ...interface{},
) {
go func() {
issues, err := tracker.searchIssues(queryFormat, v...)
ch <- &searchResult{issues, err}
}()
} | go | func (tracker *issueTracker) goSearchIssues(
ch chan<- *searchResult,
queryFormat string,
v ...interface{},
) {
go func() {
issues, err := tracker.searchIssues(queryFormat, v...)
ch <- &searchResult{issues, err}
}()
} | [
"func",
"(",
"tracker",
"*",
"issueTracker",
")",
"goSearchIssues",
"(",
"ch",
"chan",
"<-",
"*",
"searchResult",
",",
"queryFormat",
"string",
",",
"v",
"...",
"interface",
"{",
"}",
",",
")",
"{",
"go",
"func",
"(",
")",
"{",
"issues",
",",
"err",
... | // goSearchIssues simply executes searchIssues, but in a background goroutine,
// returning the results on the given channel when available. | [
"goSearchIssues",
"simply",
"executes",
"searchIssues",
"but",
"in",
"a",
"background",
"goroutine",
"returning",
"the",
"results",
"on",
"the",
"given",
"channel",
"when",
"available",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/modules/issue_tracking/github/issue_tracker.go#L267-L276 |
154,393 | salsaflow/salsaflow | modules/issue_tracking/github/issue_tracker.go | searchIssuesAndWrap | func (tracker *issueTracker) searchIssuesAndWrap(
queryFormat string,
v ...interface{},
) ([]common.Story, error) {
issues, err := tracker.searchIssues(queryFormat, v...)
if err != nil {
return nil, err
}
return toCommonStories(issues, tracker), nil
} | go | func (tracker *issueTracker) searchIssuesAndWrap(
queryFormat string,
v ...interface{},
) ([]common.Story, error) {
issues, err := tracker.searchIssues(queryFormat, v...)
if err != nil {
return nil, err
}
return toCommonStories(issues, tracker), nil
} | [
"func",
"(",
"tracker",
"*",
"issueTracker",
")",
"searchIssuesAndWrap",
"(",
"queryFormat",
"string",
",",
"v",
"...",
"interface",
"{",
"}",
",",
")",
"(",
"[",
"]",
"common",
".",
"Story",
",",
"error",
")",
"{",
"issues",
",",
"err",
":=",
"tracker... | // searchIssuesAndWrap combines searchIssues and toCommonStories, that's it. | [
"searchIssuesAndWrap",
"combines",
"searchIssues",
"and",
"toCommonStories",
"that",
"s",
"it",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/modules/issue_tracking/github/issue_tracker.go#L279-L290 |
154,394 | salsaflow/salsaflow | modules/issue_tracking/github/issue_tracker.go | issuesByNumber | func (tracker *issueTracker) issuesByNumber(issueNums []int) ([]*github.Issue, error) {
task := "Get GitHub issues for the given issue numbers"
// Prepare an accumulator.
issues := make([]*github.Issue, 0, len(issueNums))
// Send the requests concurrently.
var (
client = tracker.newClient()
owner = tracker.config.GitHubOwner
repo = tracker.config.GitHubRepository
)
ch := make(chan *getIssueResult, len(issueNums))
for _, num := range issueNums {
go func(issueNum int) {
var (
issue *github.Issue
err error
)
withRequestAllocated(func() {
issue, _, err = client.Issues.Get(owner, repo, issueNum)
})
ch <- &getIssueResult{issue, err}
}(num)
}
// Wait for the results to arrive.
for i := 0; i < cap(ch); i++ {
res := <-ch
if err := res.err; err != nil {
return nil, errs.NewError(task, err)
}
issues = append(issues, res.issue)
}
// Return the result.
return issues, nil
} | go | func (tracker *issueTracker) issuesByNumber(issueNums []int) ([]*github.Issue, error) {
task := "Get GitHub issues for the given issue numbers"
// Prepare an accumulator.
issues := make([]*github.Issue, 0, len(issueNums))
// Send the requests concurrently.
var (
client = tracker.newClient()
owner = tracker.config.GitHubOwner
repo = tracker.config.GitHubRepository
)
ch := make(chan *getIssueResult, len(issueNums))
for _, num := range issueNums {
go func(issueNum int) {
var (
issue *github.Issue
err error
)
withRequestAllocated(func() {
issue, _, err = client.Issues.Get(owner, repo, issueNum)
})
ch <- &getIssueResult{issue, err}
}(num)
}
// Wait for the results to arrive.
for i := 0; i < cap(ch); i++ {
res := <-ch
if err := res.err; err != nil {
return nil, errs.NewError(task, err)
}
issues = append(issues, res.issue)
}
// Return the result.
return issues, nil
} | [
"func",
"(",
"tracker",
"*",
"issueTracker",
")",
"issuesByNumber",
"(",
"issueNums",
"[",
"]",
"int",
")",
"(",
"[",
"]",
"*",
"github",
".",
"Issue",
",",
"error",
")",
"{",
"task",
":=",
"\"",
"\"",
"\n\n",
"// Prepare an accumulator.",
"issues",
":="... | // issuesByNumber fetches the issues matching the given issue numbers.
//
// The issues are fetched concurrently. | [
"issuesByNumber",
"fetches",
"the",
"issues",
"matching",
"the",
"given",
"issue",
"numbers",
".",
"The",
"issues",
"are",
"fetched",
"concurrently",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/modules/issue_tracking/github/issue_tracker.go#L300-L337 |
154,395 | salsaflow/salsaflow | modules/issue_tracking/github/issue_tracker.go | issuesByRelease | func (tracker *issueTracker) issuesByRelease(v *version.Version) ([]*github.Issue, error) {
return tracker.searchIssues(`milestone:"%v"`, v.BaseString())
} | go | func (tracker *issueTracker) issuesByRelease(v *version.Version) ([]*github.Issue, error) {
return tracker.searchIssues(`milestone:"%v"`, v.BaseString())
} | [
"func",
"(",
"tracker",
"*",
"issueTracker",
")",
"issuesByRelease",
"(",
"v",
"*",
"version",
".",
"Version",
")",
"(",
"[",
"]",
"*",
"github",
".",
"Issue",
",",
"error",
")",
"{",
"return",
"tracker",
".",
"searchIssues",
"(",
"`milestone:\"%v\"`",
"... | // issuesByRelease returns the issues assigned to the relevant milestone. | [
"issuesByRelease",
"returns",
"the",
"issues",
"assigned",
"to",
"the",
"relevant",
"milestone",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/modules/issue_tracking/github/issue_tracker.go#L371-L373 |
154,396 | salsaflow/salsaflow | modules/issue_tracking/github/issue_tracker.go | updateIssues | func (tracker *issueTracker) updateIssues(
issues []*github.Issue,
updateFunc issueUpdateFunc,
rollbackFunc issueUpdateFunc,
) ([]*github.Issue, action.Action, error) {
var (
client = tracker.newClient()
owner = tracker.config.GitHubOwner
repo = tracker.config.GitHubRepository
)
return updateIssues(client, owner, repo, issues, updateFunc, rollbackFunc)
} | go | func (tracker *issueTracker) updateIssues(
issues []*github.Issue,
updateFunc issueUpdateFunc,
rollbackFunc issueUpdateFunc,
) ([]*github.Issue, action.Action, error) {
var (
client = tracker.newClient()
owner = tracker.config.GitHubOwner
repo = tracker.config.GitHubRepository
)
return updateIssues(client, owner, repo, issues, updateFunc, rollbackFunc)
} | [
"func",
"(",
"tracker",
"*",
"issueTracker",
")",
"updateIssues",
"(",
"issues",
"[",
"]",
"*",
"github",
".",
"Issue",
",",
"updateFunc",
"issueUpdateFunc",
",",
"rollbackFunc",
"issueUpdateFunc",
",",
")",
"(",
"[",
"]",
"*",
"github",
".",
"Issue",
",",... | // updateIssues just calls updateIssues utility function
// using the client and config as contained in this issueTracker. | [
"updateIssues",
"just",
"calls",
"updateIssues",
"utility",
"function",
"using",
"the",
"client",
"and",
"config",
"as",
"contained",
"in",
"this",
"issueTracker",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/modules/issue_tracking/github/issue_tracker.go#L377-L389 |
154,397 | salsaflow/salsaflow | modules/issue_tracking/github/issue_tracker.go | getOrCreateMilestone | func (tracker *issueTracker) getOrCreateMilestone(
v *version.Version,
) (*github.Milestone, action.Action, error) {
var (
client = tracker.newClient()
owner = tracker.config.GitHubOwner
repo = tracker.config.GitHubRepository
title = v.BaseString()
milestone *github.Milestone
act action.Action
err error
)
withRequestAllocated(func() {
milestone, act, err = ghissues.GetOrCreateMilestoneForTitle(client, owner, repo, title)
})
return milestone, act, err
} | go | func (tracker *issueTracker) getOrCreateMilestone(
v *version.Version,
) (*github.Milestone, action.Action, error) {
var (
client = tracker.newClient()
owner = tracker.config.GitHubOwner
repo = tracker.config.GitHubRepository
title = v.BaseString()
milestone *github.Milestone
act action.Action
err error
)
withRequestAllocated(func() {
milestone, act, err = ghissues.GetOrCreateMilestoneForTitle(client, owner, repo, title)
})
return milestone, act, err
} | [
"func",
"(",
"tracker",
"*",
"issueTracker",
")",
"getOrCreateMilestone",
"(",
"v",
"*",
"version",
".",
"Version",
",",
")",
"(",
"*",
"github",
".",
"Milestone",
",",
"action",
".",
"Action",
",",
"error",
")",
"{",
"var",
"(",
"client",
"=",
"tracke... | // getOrCreateMilestone just calls ghissues.GetOrCreateMilestoneForTitle
// using the client and config as contained in this issueTracker. | [
"getOrCreateMilestone",
"just",
"calls",
"ghissues",
".",
"GetOrCreateMilestoneForTitle",
"using",
"the",
"client",
"and",
"config",
"as",
"contained",
"in",
"this",
"issueTracker",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/modules/issue_tracking/github/issue_tracker.go#L393-L411 |
154,398 | salsaflow/salsaflow | Godeps/_workspace/src/gopkg.in/tchap/gocli.v2/command.go | Usage | func (cmd *Command) Usage() {
cmd.UsageLine = strings.TrimSpace(cmd.UsageLine)
tw := tabwriter.NewWriter(os.Stderr, 0, 8, 2, '\t', 0)
defer tw.Flush()
t := template.Must(template.New("usage").Parse(cmd.helpTemplate))
t.Execute(tw, cmd.helpTemplateData)
} | go | func (cmd *Command) Usage() {
cmd.UsageLine = strings.TrimSpace(cmd.UsageLine)
tw := tabwriter.NewWriter(os.Stderr, 0, 8, 2, '\t', 0)
defer tw.Flush()
t := template.Must(template.New("usage").Parse(cmd.helpTemplate))
t.Execute(tw, cmd.helpTemplateData)
} | [
"func",
"(",
"cmd",
"*",
"Command",
")",
"Usage",
"(",
")",
"{",
"cmd",
".",
"UsageLine",
"=",
"strings",
".",
"TrimSpace",
"(",
"cmd",
".",
"UsageLine",
")",
"\n\n",
"tw",
":=",
"tabwriter",
".",
"NewWriter",
"(",
"os",
".",
"Stderr",
",",
"0",
",... | // Print help and exit. | [
"Print",
"help",
"and",
"exit",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/Godeps/_workspace/src/gopkg.in/tchap/gocli.v2/command.go#L84-L92 |
154,399 | salsaflow/salsaflow | Godeps/_workspace/src/gopkg.in/tchap/gocli.v2/command.go | DefaultFlagsString | func (cmd *Command) DefaultFlagsString() string {
var b bytes.Buffer
cmd.Flags.SetOutput(&b)
cmd.Flags.PrintDefaults()
return b.String()
} | go | func (cmd *Command) DefaultFlagsString() string {
var b bytes.Buffer
cmd.Flags.SetOutput(&b)
cmd.Flags.PrintDefaults()
return b.String()
} | [
"func",
"(",
"cmd",
"*",
"Command",
")",
"DefaultFlagsString",
"(",
")",
"string",
"{",
"var",
"b",
"bytes",
".",
"Buffer",
"\n",
"cmd",
".",
"Flags",
".",
"SetOutput",
"(",
"&",
"b",
")",
"\n",
"cmd",
".",
"Flags",
".",
"PrintDefaults",
"(",
")",
... | // Returns the same as flag.FlagSet.PrintDefaults, but as a string instead
// of printing it directly into the output stream. | [
"Returns",
"the",
"same",
"as",
"flag",
".",
"FlagSet",
".",
"PrintDefaults",
"but",
"as",
"a",
"string",
"instead",
"of",
"printing",
"it",
"directly",
"into",
"the",
"output",
"stream",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/Godeps/_workspace/src/gopkg.in/tchap/gocli.v2/command.go#L96-L101 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.