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,500 | seven5/seven5 | qbs_rest.go | QbsWrapAllUdid | func QbsWrapAllUdid(a QbsRestAllUdid, s *QbsStore) RestAllUdid {
return &qbsWrappedUdid{store: s, index: a, find: a, del: a, put: a, post: a}
} | go | func QbsWrapAllUdid(a QbsRestAllUdid, s *QbsStore) RestAllUdid {
return &qbsWrappedUdid{store: s, index: a, find: a, del: a, put: a, post: a}
} | [
"func",
"QbsWrapAllUdid",
"(",
"a",
"QbsRestAllUdid",
",",
"s",
"*",
"QbsStore",
")",
"RestAllUdid",
"{",
"return",
"&",
"qbsWrappedUdid",
"{",
"store",
":",
"s",
",",
"index",
":",
"a",
",",
"find",
":",
"a",
",",
"del",
":",
"a",
",",
"put",
":",
... | //Given a QbsRestAllUdid return a RestAllUdid | [
"Given",
"a",
"QbsRestAllUdid",
"return",
"a",
"RestAllUdid"
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/qbs_rest.go#L283-L285 |
154,501 | seven5/seven5 | qbs_rest.go | QbsWrapIndex | func QbsWrapIndex(indexer QbsRestIndex, s *QbsStore) RestIndex {
return &qbsWrapped{index: indexer, store: s}
} | go | func QbsWrapIndex(indexer QbsRestIndex, s *QbsStore) RestIndex {
return &qbsWrapped{index: indexer, store: s}
} | [
"func",
"QbsWrapIndex",
"(",
"indexer",
"QbsRestIndex",
",",
"s",
"*",
"QbsStore",
")",
"RestIndex",
"{",
"return",
"&",
"qbsWrapped",
"{",
"index",
":",
"indexer",
",",
"store",
":",
"s",
"}",
"\n",
"}"
] | //Given a QBSRestIndex return a RestIndex | [
"Given",
"a",
"QBSRestIndex",
"return",
"a",
"RestIndex"
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/qbs_rest.go#L288-L290 |
154,502 | seven5/seven5 | qbs_rest.go | QbsWrapFind | func QbsWrapFind(finder QbsRestFind, s *QbsStore) RestFind {
return &qbsWrapped{find: finder, store: s}
} | go | func QbsWrapFind(finder QbsRestFind, s *QbsStore) RestFind {
return &qbsWrapped{find: finder, store: s}
} | [
"func",
"QbsWrapFind",
"(",
"finder",
"QbsRestFind",
",",
"s",
"*",
"QbsStore",
")",
"RestFind",
"{",
"return",
"&",
"qbsWrapped",
"{",
"find",
":",
"finder",
",",
"store",
":",
"s",
"}",
"\n",
"}"
] | //Given a QbsRestFind return a RestFind | [
"Given",
"a",
"QbsRestFind",
"return",
"a",
"RestFind"
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/qbs_rest.go#L293-L295 |
154,503 | seven5/seven5 | qbs_rest.go | QbsWrapFindUdid | func QbsWrapFindUdid(finder QbsRestFindUdid, s *QbsStore) RestFindUdid {
return &qbsWrappedUdid{find: finder, store: s}
} | go | func QbsWrapFindUdid(finder QbsRestFindUdid, s *QbsStore) RestFindUdid {
return &qbsWrappedUdid{find: finder, store: s}
} | [
"func",
"QbsWrapFindUdid",
"(",
"finder",
"QbsRestFindUdid",
",",
"s",
"*",
"QbsStore",
")",
"RestFindUdid",
"{",
"return",
"&",
"qbsWrappedUdid",
"{",
"find",
":",
"finder",
",",
"store",
":",
"s",
"}",
"\n",
"}"
] | //Given a QbsRestFindUdid return a RestFindUdid | [
"Given",
"a",
"QbsRestFindUdid",
"return",
"a",
"RestFindUdid"
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/qbs_rest.go#L298-L300 |
154,504 | seven5/seven5 | qbs_rest.go | QbsWrapDelete | func QbsWrapDelete(deler QbsRestDelete, s *QbsStore) RestDelete {
return &qbsWrapped{del: deler, store: s}
} | go | func QbsWrapDelete(deler QbsRestDelete, s *QbsStore) RestDelete {
return &qbsWrapped{del: deler, store: s}
} | [
"func",
"QbsWrapDelete",
"(",
"deler",
"QbsRestDelete",
",",
"s",
"*",
"QbsStore",
")",
"RestDelete",
"{",
"return",
"&",
"qbsWrapped",
"{",
"del",
":",
"deler",
",",
"store",
":",
"s",
"}",
"\n",
"}"
] | //Given a QbsRestDelete return a RestDelete | [
"Given",
"a",
"QbsRestDelete",
"return",
"a",
"RestDelete"
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/qbs_rest.go#L303-L305 |
154,505 | seven5/seven5 | qbs_rest.go | QbsWrapDeleteUdid | func QbsWrapDeleteUdid(deler QbsRestDeleteUdid, s *QbsStore) RestDeleteUdid {
return &qbsWrappedUdid{del: deler, store: s}
} | go | func QbsWrapDeleteUdid(deler QbsRestDeleteUdid, s *QbsStore) RestDeleteUdid {
return &qbsWrappedUdid{del: deler, store: s}
} | [
"func",
"QbsWrapDeleteUdid",
"(",
"deler",
"QbsRestDeleteUdid",
",",
"s",
"*",
"QbsStore",
")",
"RestDeleteUdid",
"{",
"return",
"&",
"qbsWrappedUdid",
"{",
"del",
":",
"deler",
",",
"store",
":",
"s",
"}",
"\n",
"}"
] | //Given a QbsRestDeleteUdid return a RestDeleteUdid | [
"Given",
"a",
"QbsRestDeleteUdid",
"return",
"a",
"RestDeleteUdid"
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/qbs_rest.go#L308-L310 |
154,506 | seven5/seven5 | qbs_rest.go | QbsWrapPost | func QbsWrapPost(poster QbsRestPost, s *QbsStore) RestPost {
return &qbsWrapped{post: poster, store: s}
} | go | func QbsWrapPost(poster QbsRestPost, s *QbsStore) RestPost {
return &qbsWrapped{post: poster, store: s}
} | [
"func",
"QbsWrapPost",
"(",
"poster",
"QbsRestPost",
",",
"s",
"*",
"QbsStore",
")",
"RestPost",
"{",
"return",
"&",
"qbsWrapped",
"{",
"post",
":",
"poster",
",",
"store",
":",
"s",
"}",
"\n",
"}"
] | //Given a QbsRestPost return a RestPost | [
"Given",
"a",
"QbsRestPost",
"return",
"a",
"RestPost"
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/qbs_rest.go#L323-L325 |
154,507 | timehop/gos2 | s2/cap.go | CapFromCenterHeight | func CapFromCenterHeight(center Point, height float64) Cap {
return Cap{
center: Point{center.Normalize()},
height: height,
}
} | go | func CapFromCenterHeight(center Point, height float64) Cap {
return Cap{
center: Point{center.Normalize()},
height: height,
}
} | [
"func",
"CapFromCenterHeight",
"(",
"center",
"Point",
",",
"height",
"float64",
")",
"Cap",
"{",
"return",
"Cap",
"{",
"center",
":",
"Point",
"{",
"center",
".",
"Normalize",
"(",
")",
"}",
",",
"height",
":",
"height",
",",
"}",
"\n",
"}"
] | // CapFromCenterHeight constructs a cap with the given center and height. A
// negative height yields an empty cap; a height of 2 or more yields a full cap. | [
"CapFromCenterHeight",
"constructs",
"a",
"cap",
"with",
"the",
"given",
"center",
"and",
"height",
".",
"A",
"negative",
"height",
"yields",
"an",
"empty",
"cap",
";",
"a",
"height",
"of",
"2",
"or",
"more",
"yields",
"a",
"full",
"cap",
"."
] | 004cde1d85c2ef02a66c6c769d44b293d28879f5 | https://github.com/timehop/gos2/blob/004cde1d85c2ef02a66c6c769d44b293d28879f5/s2/cap.go#L62-L67 |
154,508 | timehop/gos2 | s2/cap.go | IsValid | func (c Cap) IsValid() bool {
return c.center.Vector.IsUnit() && c.height <= fullHeight
} | go | func (c Cap) IsValid() bool {
return c.center.Vector.IsUnit() && c.height <= fullHeight
} | [
"func",
"(",
"c",
"Cap",
")",
"IsValid",
"(",
")",
"bool",
"{",
"return",
"c",
".",
"center",
".",
"Vector",
".",
"IsUnit",
"(",
")",
"&&",
"c",
".",
"height",
"<=",
"fullHeight",
"\n",
"}"
] | // IsValid reports whether the Cap is considered valid.
// Heights are normalized so that they do not exceed 2. | [
"IsValid",
"reports",
"whether",
"the",
"Cap",
"is",
"considered",
"valid",
".",
"Heights",
"are",
"normalized",
"so",
"that",
"they",
"do",
"not",
"exceed",
"2",
"."
] | 004cde1d85c2ef02a66c6c769d44b293d28879f5 | https://github.com/timehop/gos2/blob/004cde1d85c2ef02a66c6c769d44b293d28879f5/s2/cap.go#L89-L91 |
154,509 | timehop/gos2 | s2/cap.go | Radius | func (c Cap) Radius() s1.Angle {
if c.IsEmpty() {
return s1.Angle(emptyHeight)
}
// This could also be computed as acos(1 - height_), but the following
// formula is much more accurate when the cap height is small. It
// follows from the relationship h = 1 - cos(r) = 2 sin^2(r/2).
return s1.Angle(2 * math.Asin(math.Sqrt(0.5*c.height)))
} | go | func (c Cap) Radius() s1.Angle {
if c.IsEmpty() {
return s1.Angle(emptyHeight)
}
// This could also be computed as acos(1 - height_), but the following
// formula is much more accurate when the cap height is small. It
// follows from the relationship h = 1 - cos(r) = 2 sin^2(r/2).
return s1.Angle(2 * math.Asin(math.Sqrt(0.5*c.height)))
} | [
"func",
"(",
"c",
"Cap",
")",
"Radius",
"(",
")",
"s1",
".",
"Angle",
"{",
"if",
"c",
".",
"IsEmpty",
"(",
")",
"{",
"return",
"s1",
".",
"Angle",
"(",
"emptyHeight",
")",
"\n",
"}",
"\n\n",
"// This could also be computed as acos(1 - height_), but the follo... | // Radius returns the cap's radius. | [
"Radius",
"returns",
"the",
"cap",
"s",
"radius",
"."
] | 004cde1d85c2ef02a66c6c769d44b293d28879f5 | https://github.com/timehop/gos2/blob/004cde1d85c2ef02a66c6c769d44b293d28879f5/s2/cap.go#L104-L113 |
154,510 | timehop/gos2 | s2/cap.go | InteriorIntersects | func (c Cap) InteriorIntersects(other Cap) bool {
// Make sure this cap has an interior and the other cap is non-empty.
if c.height <= zeroHeight || other.IsEmpty() {
return false
}
return c.Radius()+other.Radius() > c.center.Distance(other.center)
} | go | func (c Cap) InteriorIntersects(other Cap) bool {
// Make sure this cap has an interior and the other cap is non-empty.
if c.height <= zeroHeight || other.IsEmpty() {
return false
}
return c.Radius()+other.Radius() > c.center.Distance(other.center)
} | [
"func",
"(",
"c",
"Cap",
")",
"InteriorIntersects",
"(",
"other",
"Cap",
")",
"bool",
"{",
"// Make sure this cap has an interior and the other cap is non-empty.",
"if",
"c",
".",
"height",
"<=",
"zeroHeight",
"||",
"other",
".",
"IsEmpty",
"(",
")",
"{",
"return"... | // InteriorIntersects reports whether this caps interior intersects the other cap. | [
"InteriorIntersects",
"reports",
"whether",
"this",
"caps",
"interior",
"intersects",
"the",
"other",
"cap",
"."
] | 004cde1d85c2ef02a66c6c769d44b293d28879f5 | https://github.com/timehop/gos2/blob/004cde1d85c2ef02a66c6c769d44b293d28879f5/s2/cap.go#L140-L147 |
154,511 | timehop/gos2 | s2/cap.go | RectBound | func (c Cap) RectBound() Rect {
if c.IsEmpty() {
return EmptyRect()
}
capAngle := c.Radius().Radians()
allLongitudes := false
lat := r1.Interval{
Lo: latitude(c.center).Radians() - capAngle,
Hi: latitude(c.center).Radians() + capAngle,
}
lng := s1.FullInterval()
// Check whether cap includes the south pole.
if lat.Lo <= -math.Pi/2 {
lat.Lo = -math.Pi / 2
allLongitudes = true
}
// Check whether cap includes the north pole.
if lat.Hi >= math.Pi/2 {
lat.Hi = math.Pi / 2
allLongitudes = true
}
if !allLongitudes {
// Compute the range of longitudes covered by the cap. We use the law
// of sines for spherical triangles. Consider the triangle ABC where
// A is the north pole, B is the center of the cap, and C is the point
// of tangency between the cap boundary and a line of longitude. Then
// C is a right angle, and letting a,b,c denote the sides opposite A,B,C,
// we have sin(a)/sin(A) = sin(c)/sin(C), or sin(A) = sin(a)/sin(c).
// Here "a" is the cap angle, and "c" is the colatitude (90 degrees
// minus the latitude). This formula also works for negative latitudes.
//
// The formula for sin(a) follows from the relationship h = 1 - cos(a).
sinA := math.Sqrt(c.height * (2 - c.height))
sinC := math.Cos(latitude(c.center).Radians())
if sinA <= sinC {
angleA := math.Asin(sinA / sinC)
lng.Lo = math.Remainder(longitude(c.center).Radians()-angleA, math.Pi*2)
lng.Hi = math.Remainder(longitude(c.center).Radians()+angleA, math.Pi*2)
}
}
return Rect{lat, lng}
} | go | func (c Cap) RectBound() Rect {
if c.IsEmpty() {
return EmptyRect()
}
capAngle := c.Radius().Radians()
allLongitudes := false
lat := r1.Interval{
Lo: latitude(c.center).Radians() - capAngle,
Hi: latitude(c.center).Radians() + capAngle,
}
lng := s1.FullInterval()
// Check whether cap includes the south pole.
if lat.Lo <= -math.Pi/2 {
lat.Lo = -math.Pi / 2
allLongitudes = true
}
// Check whether cap includes the north pole.
if lat.Hi >= math.Pi/2 {
lat.Hi = math.Pi / 2
allLongitudes = true
}
if !allLongitudes {
// Compute the range of longitudes covered by the cap. We use the law
// of sines for spherical triangles. Consider the triangle ABC where
// A is the north pole, B is the center of the cap, and C is the point
// of tangency between the cap boundary and a line of longitude. Then
// C is a right angle, and letting a,b,c denote the sides opposite A,B,C,
// we have sin(a)/sin(A) = sin(c)/sin(C), or sin(A) = sin(a)/sin(c).
// Here "a" is the cap angle, and "c" is the colatitude (90 degrees
// minus the latitude). This formula also works for negative latitudes.
//
// The formula for sin(a) follows from the relationship h = 1 - cos(a).
sinA := math.Sqrt(c.height * (2 - c.height))
sinC := math.Cos(latitude(c.center).Radians())
if sinA <= sinC {
angleA := math.Asin(sinA / sinC)
lng.Lo = math.Remainder(longitude(c.center).Radians()-angleA, math.Pi*2)
lng.Hi = math.Remainder(longitude(c.center).Radians()+angleA, math.Pi*2)
}
}
return Rect{lat, lng}
} | [
"func",
"(",
"c",
"Cap",
")",
"RectBound",
"(",
")",
"Rect",
"{",
"if",
"c",
".",
"IsEmpty",
"(",
")",
"{",
"return",
"EmptyRect",
"(",
")",
"\n",
"}",
"\n\n",
"capAngle",
":=",
"c",
".",
"Radius",
"(",
")",
".",
"Radians",
"(",
")",
"\n",
"all... | // RectBound returns a bounding latitude-longitude rectangle.
// The bounds are not guaranteed to be tight. | [
"RectBound",
"returns",
"a",
"bounding",
"latitude",
"-",
"longitude",
"rectangle",
".",
"The",
"bounds",
"are",
"not",
"guaranteed",
"to",
"be",
"tight",
"."
] | 004cde1d85c2ef02a66c6c769d44b293d28879f5 | https://github.com/timehop/gos2/blob/004cde1d85c2ef02a66c6c769d44b293d28879f5/s2/cap.go#L179-L224 |
154,512 | timehop/gos2 | s2/cap.go | ApproxEqual | func (c Cap) ApproxEqual(other Cap) bool {
const epsilon = 1e-14
return c.center.ApproxEqual(other.center) &&
math.Abs(c.height-other.height) <= epsilon ||
c.IsEmpty() && other.height <= epsilon ||
other.IsEmpty() && c.height <= epsilon ||
c.IsFull() && other.height >= 2-epsilon ||
other.IsFull() && c.height >= 2-epsilon
} | go | func (c Cap) ApproxEqual(other Cap) bool {
const epsilon = 1e-14
return c.center.ApproxEqual(other.center) &&
math.Abs(c.height-other.height) <= epsilon ||
c.IsEmpty() && other.height <= epsilon ||
other.IsEmpty() && c.height <= epsilon ||
c.IsFull() && other.height >= 2-epsilon ||
other.IsFull() && c.height >= 2-epsilon
} | [
"func",
"(",
"c",
"Cap",
")",
"ApproxEqual",
"(",
"other",
"Cap",
")",
"bool",
"{",
"const",
"epsilon",
"=",
"1e-14",
"\n",
"return",
"c",
".",
"center",
".",
"ApproxEqual",
"(",
"other",
".",
"center",
")",
"&&",
"math",
".",
"Abs",
"(",
"c",
".",... | // ApproxEqual reports if this caps' center and height are within
// a reasonable epsilon from the other cap. | [
"ApproxEqual",
"reports",
"if",
"this",
"caps",
"center",
"and",
"height",
"are",
"within",
"a",
"reasonable",
"epsilon",
"from",
"the",
"other",
"cap",
"."
] | 004cde1d85c2ef02a66c6c769d44b293d28879f5 | https://github.com/timehop/gos2/blob/004cde1d85c2ef02a66c6c769d44b293d28879f5/s2/cap.go#L228-L236 |
154,513 | salsaflow/salsaflow | github/issues/commit_list.go | AddCommit | func (list *CommitList) AddCommit(reviewed bool, commitSHA, commitTitle string) bool {
for _, item := range list.items {
if item.CommitSHA == commitSHA {
return false
}
}
list.items = append(list.items, &CommitItem{
Reviewed: reviewed,
CommitSHA: commitSHA,
CommitTitle: commitTitle,
})
return true
} | go | func (list *CommitList) AddCommit(reviewed bool, commitSHA, commitTitle string) bool {
for _, item := range list.items {
if item.CommitSHA == commitSHA {
return false
}
}
list.items = append(list.items, &CommitItem{
Reviewed: reviewed,
CommitSHA: commitSHA,
CommitTitle: commitTitle,
})
return true
} | [
"func",
"(",
"list",
"*",
"CommitList",
")",
"AddCommit",
"(",
"reviewed",
"bool",
",",
"commitSHA",
",",
"commitTitle",
"string",
")",
"bool",
"{",
"for",
"_",
",",
"item",
":=",
"range",
"list",
".",
"items",
"{",
"if",
"item",
".",
"CommitSHA",
"=="... | // AddCommit adds the commit to the list unless the commit is already there. | [
"AddCommit",
"adds",
"the",
"commit",
"to",
"the",
"list",
"unless",
"the",
"commit",
"is",
"already",
"there",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/github/issues/commit_list.go#L24-L37 |
154,514 | seven5/seven5 | client/net.go | AjaxIndex | func AjaxIndex(ptrToSliceOfPtrToStruct interface{}, path string) (chan interface{}, chan AjaxError) {
isPointerToSliceOfPointerToStructOrPanic(ptrToSliceOfPtrToStruct)
contentCh := make(chan interface{})
errCh := make(chan AjaxError)
AjaxRawChannels(ptrToSliceOfPtrToStruct, "", contentCh, errCh, "GET", path, nil)
return contentCh, errCh
} | go | func AjaxIndex(ptrToSliceOfPtrToStruct interface{}, path string) (chan interface{}, chan AjaxError) {
isPointerToSliceOfPointerToStructOrPanic(ptrToSliceOfPtrToStruct)
contentCh := make(chan interface{})
errCh := make(chan AjaxError)
AjaxRawChannels(ptrToSliceOfPtrToStruct, "", contentCh, errCh, "GET", path, nil)
return contentCh, errCh
} | [
"func",
"AjaxIndex",
"(",
"ptrToSliceOfPtrToStruct",
"interface",
"{",
"}",
",",
"path",
"string",
")",
"(",
"chan",
"interface",
"{",
"}",
",",
"chan",
"AjaxError",
")",
"{",
"isPointerToSliceOfPointerToStructOrPanic",
"(",
"ptrToSliceOfPtrToStruct",
")",
"\n",
"... | //AjaxIndex retreives a collection of wire types from the server.
//If the first argument is not a pointer to a slice of pointer to struct,
//it will panic. The first element should be a slice of wire types.
//The returned values are a content channel and an error channel. The content
//channel will receive the same type as your first argument if anything. The error
//channel is used for non-200 http responses and the special error code 418
//is used to indicate that the received json from the server could not be successfully
//parsed as the type of the first argument. | [
"AjaxIndex",
"retreives",
"a",
"collection",
"of",
"wire",
"types",
"from",
"the",
"server",
".",
"If",
"the",
"first",
"argument",
"is",
"not",
"a",
"pointer",
"to",
"a",
"slice",
"of",
"pointer",
"to",
"struct",
"it",
"will",
"panic",
".",
"The",
"firs... | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/client/net.go#L53-L59 |
154,515 | seven5/seven5 | client/net.go | AjaxGet | func AjaxGet(ptrToStruct interface{}, path string) (chan interface{}, chan AjaxError) {
isPointerToStructOrPanic(ptrToStruct)
contentCh := make(chan interface{})
errCh := make(chan AjaxError)
AjaxRawChannels(ptrToStruct, "", contentCh, errCh, "GET", path, nil)
return contentCh, errCh
} | go | func AjaxGet(ptrToStruct interface{}, path string) (chan interface{}, chan AjaxError) {
isPointerToStructOrPanic(ptrToStruct)
contentCh := make(chan interface{})
errCh := make(chan AjaxError)
AjaxRawChannels(ptrToStruct, "", contentCh, errCh, "GET", path, nil)
return contentCh, errCh
} | [
"func",
"AjaxGet",
"(",
"ptrToStruct",
"interface",
"{",
"}",
",",
"path",
"string",
")",
"(",
"chan",
"interface",
"{",
"}",
",",
"chan",
"AjaxError",
")",
"{",
"isPointerToStructOrPanic",
"(",
"ptrToStruct",
")",
"\n",
"contentCh",
":=",
"make",
"(",
"ch... | //AjaxGet retreives an instance of a wire type from the server and decodes the result as
//Json. If the first argument is not a pointer to a struct, it will panic.
//The first argument should be a wire type that you expect to receive in the success
//case. The returned values are a content channel and an error channel. The content
//channel will receive the same type as your first argument if anything. The error
//channel is used for non-200 http responses and the special error code 418
//is used to indicate that the received json from the server could not be successfully
//parsed as the type of the first argument. The error code 0 indicates that the
//server could not be contacted at all. | [
"AjaxGet",
"retreives",
"an",
"instance",
"of",
"a",
"wire",
"type",
"from",
"the",
"server",
"and",
"decodes",
"the",
"result",
"as",
"Json",
".",
"If",
"the",
"first",
"argument",
"is",
"not",
"a",
"pointer",
"to",
"a",
"struct",
"it",
"will",
"panic",... | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/client/net.go#L70-L76 |
154,516 | seven5/seven5 | client/net.go | AjaxRawChannels | func AjaxRawChannels(output interface{}, body string, contentChan chan interface{}, errChan chan AjaxError,
method string, path string, extraHeaders map[string]interface{}) error {
m := map[string]interface{}{
"contentType": "application/json",
"dataType": "text",
"type": method,
"url": path,
"cache": false,
}
if body != "" {
m["data"] = body
}
if extraHeaders != nil {
m["headers"] = extraHeaders
}
jquery.Ajax(m).
Then(func(valueCreated *js.Object) {
rd := strings.NewReader(valueCreated.String())
dec := json.NewDecoder(rd)
if err := dec.Decode(output); err != nil {
go func() {
errChan <- AjaxError{418, err.Error()}
}()
return
}
go func() {
contentChan <- output
}()
}).
Fail(func(p1 *js.Object) {
go func() {
ajaxerr := AjaxError{p1.Get("status").Int(), p1.Get("responseText").String()}
if p1.Get("status").Int() == 0 {
ajaxerr.StatusCode = 0
ajaxerr.Message = "Server not reachable"
}
errChan <- ajaxerr
}()
})
return nil
} | go | func AjaxRawChannels(output interface{}, body string, contentChan chan interface{}, errChan chan AjaxError,
method string, path string, extraHeaders map[string]interface{}) error {
m := map[string]interface{}{
"contentType": "application/json",
"dataType": "text",
"type": method,
"url": path,
"cache": false,
}
if body != "" {
m["data"] = body
}
if extraHeaders != nil {
m["headers"] = extraHeaders
}
jquery.Ajax(m).
Then(func(valueCreated *js.Object) {
rd := strings.NewReader(valueCreated.String())
dec := json.NewDecoder(rd)
if err := dec.Decode(output); err != nil {
go func() {
errChan <- AjaxError{418, err.Error()}
}()
return
}
go func() {
contentChan <- output
}()
}).
Fail(func(p1 *js.Object) {
go func() {
ajaxerr := AjaxError{p1.Get("status").Int(), p1.Get("responseText").String()}
if p1.Get("status").Int() == 0 {
ajaxerr.StatusCode = 0
ajaxerr.Message = "Server not reachable"
}
errChan <- ajaxerr
}()
})
return nil
} | [
"func",
"AjaxRawChannels",
"(",
"output",
"interface",
"{",
"}",
",",
"body",
"string",
",",
"contentChan",
"chan",
"interface",
"{",
"}",
",",
"errChan",
"chan",
"AjaxError",
",",
"method",
"string",
",",
"path",
"string",
",",
"extraHeaders",
"map",
"[",
... | //AjaxRawChannels is the lower level interface to the "raw" Ajax call. Most users
//should use AjaxGet, AjaxPost, AjaxIndex or AjaxPut. | [
"AjaxRawChannels",
"is",
"the",
"lower",
"level",
"interface",
"to",
"the",
"raw",
"Ajax",
"call",
".",
"Most",
"users",
"should",
"use",
"AjaxGet",
"AjaxPost",
"AjaxIndex",
"or",
"AjaxPut",
"."
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/client/net.go#L80-L123 |
154,517 | seven5/seven5 | rest.go | IsUDID | func IsUDID(s string) bool {
if len(s) != 36 {
return false
}
parts := strings.Split(s, "-")
if len(parts) != 5 {
return false
}
for k, v := range map[int]int{0: 8, 1: 4, 2: 4, 3: 4, 4: 12} {
if len(parts[k]) != v {
return false
}
}
for _, r := range s {
switch r {
case 'a', 'b', 'c', 'd', 'e', 'f', '-', 'A', 'B', 'C', 'D', 'E', 'F', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
default:
return false
}
}
return true
} | go | func IsUDID(s string) bool {
if len(s) != 36 {
return false
}
parts := strings.Split(s, "-")
if len(parts) != 5 {
return false
}
for k, v := range map[int]int{0: 8, 1: 4, 2: 4, 3: 4, 4: 12} {
if len(parts[k]) != v {
return false
}
}
for _, r := range s {
switch r {
case 'a', 'b', 'c', 'd', 'e', 'f', '-', 'A', 'B', 'C', 'D', 'E', 'F', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
default:
return false
}
}
return true
} | [
"func",
"IsUDID",
"(",
"s",
"string",
")",
"bool",
"{",
"if",
"len",
"(",
"s",
")",
"!=",
"36",
"{",
"return",
"false",
"\n",
"}",
"\n",
"parts",
":=",
"strings",
".",
"Split",
"(",
"s",
",",
"\"",
"\"",
")",
"\n",
"if",
"len",
"(",
"parts",
... | //
// IsUDID takes in a string and returns true if it is formatted as a standard
// UDID, for example de305d54-75b4-431b-adb2-eb6b9e546013. This code expects
// the length to be exactly 36 characters, with five groups of hex characters
// separated by dashes. The five groups are of length 8, 4, 4, 4, and 12
// characters. | [
"IsUDID",
"takes",
"in",
"a",
"string",
"and",
"returns",
"true",
"if",
"it",
"is",
"formatted",
"as",
"a",
"standard",
"UDID",
"for",
"example",
"de305d54",
"-",
"75b4",
"-",
"431b",
"-",
"adb2",
"-",
"eb6b9e546013",
".",
"This",
"code",
"expects",
"the... | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/rest.go#L80-L101 |
154,518 | salsaflow/salsaflow | config/loader/dialog.go | RunModuleBootstrapDialog | func RunModuleBootstrapDialog(sections ...*ModuleDialogSection) error {
// Try to read the local configuration file.
localConfig, err := config.ReadLocalConfig()
if err != nil {
if !os.IsNotExist(errs.RootCause(err)) {
return err
}
}
for _, section := range sections {
modules := section.AvailableModules
// In case there are no modules available, skip the section.
if len(modules) == 0 {
continue
}
// Find the module for the given module kind.
// Either use the one that is already configured
// or prompt the user to select one.
module := tryToFindActiveModule(localConfig, modules)
if module == nil {
var err error
module, err = promptUserToSelectModule(section.AvailableModules, section.Optional)
if err != nil {
return err
}
}
// Run the configuration dialog for the selected module.
// The module can be unset in case it is optional.
if module != nil {
if err := BootstrapConfig(module.ConfigSpec()); err != nil {
return err
}
}
}
return nil
} | go | func RunModuleBootstrapDialog(sections ...*ModuleDialogSection) error {
// Try to read the local configuration file.
localConfig, err := config.ReadLocalConfig()
if err != nil {
if !os.IsNotExist(errs.RootCause(err)) {
return err
}
}
for _, section := range sections {
modules := section.AvailableModules
// In case there are no modules available, skip the section.
if len(modules) == 0 {
continue
}
// Find the module for the given module kind.
// Either use the one that is already configured
// or prompt the user to select one.
module := tryToFindActiveModule(localConfig, modules)
if module == nil {
var err error
module, err = promptUserToSelectModule(section.AvailableModules, section.Optional)
if err != nil {
return err
}
}
// Run the configuration dialog for the selected module.
// The module can be unset in case it is optional.
if module != nil {
if err := BootstrapConfig(module.ConfigSpec()); err != nil {
return err
}
}
}
return nil
} | [
"func",
"RunModuleBootstrapDialog",
"(",
"sections",
"...",
"*",
"ModuleDialogSection",
")",
"error",
"{",
"// Try to read the local configuration file.",
"localConfig",
",",
"err",
":=",
"config",
".",
"ReadLocalConfig",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{... | // RunModuleBootstrapDialog runs the module bootstrapping dialog for every
// section specification passed into the function. | [
"RunModuleBootstrapDialog",
"runs",
"the",
"module",
"bootstrapping",
"dialog",
"for",
"every",
"section",
"specification",
"passed",
"into",
"the",
"function",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/config/loader/dialog.go#L38-L77 |
154,519 | seven5/seven5 | client/constraint.go | NewSelectableAttribute | func NewSelectableAttribute(chooser BooleanAttribute, unselectedValue Equaler,
attr Attribute) *SelectableAttribute {
cattr := chooser
if cattr == nil {
cattr = NewBooleanSimple(false)
}
result := &SelectableAttribute{
chooser: cattr,
unselectedValue: unselectedValue,
attr: attr,
}
result.AttributeImpl = NewAttribute(NORMAL, nil, nil)
result.cons = NewSimpleConstraint(result.value, cattr, attr)
result.AttributeImpl.Attach(result.cons)
return result
} | go | func NewSelectableAttribute(chooser BooleanAttribute, unselectedValue Equaler,
attr Attribute) *SelectableAttribute {
cattr := chooser
if cattr == nil {
cattr = NewBooleanSimple(false)
}
result := &SelectableAttribute{
chooser: cattr,
unselectedValue: unselectedValue,
attr: attr,
}
result.AttributeImpl = NewAttribute(NORMAL, nil, nil)
result.cons = NewSimpleConstraint(result.value, cattr, attr)
result.AttributeImpl.Attach(result.cons)
return result
} | [
"func",
"NewSelectableAttribute",
"(",
"chooser",
"BooleanAttribute",
",",
"unselectedValue",
"Equaler",
",",
"attr",
"Attribute",
")",
"*",
"SelectableAttribute",
"{",
"cattr",
":=",
"chooser",
"\n",
"if",
"cattr",
"==",
"nil",
"{",
"cattr",
"=",
"NewBooleanSimpl... | //NewSelectableAttribute creates a new SelectableAttribute with a given chooser
//a boolean attribute, a constant to be used when the chooser is false, and
//attribute to used when the chooser is true. If you pass nil as the chooser
//this call will create a new boolean attribute to use as the chooser and
//it's initial value will be false. The attribute provided must not be nil. | [
"NewSelectableAttribute",
"creates",
"a",
"new",
"SelectableAttribute",
"with",
"a",
"given",
"chooser",
"a",
"boolean",
"attribute",
"a",
"constant",
"to",
"be",
"used",
"when",
"the",
"chooser",
"is",
"false",
"and",
"attribute",
"to",
"used",
"when",
"the",
... | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/client/constraint.go#L92-L108 |
154,520 | seven5/seven5 | client/constraint.go | value | func (s *SelectableAttribute) value(v []Equaler) Equaler {
chooserVal := v[0].(BoolEqualer).B
attrVal := v[1]
if chooserVal {
return attrVal
}
return s.unselectedValue
} | go | func (s *SelectableAttribute) value(v []Equaler) Equaler {
chooserVal := v[0].(BoolEqualer).B
attrVal := v[1]
if chooserVal {
return attrVal
}
return s.unselectedValue
} | [
"func",
"(",
"s",
"*",
"SelectableAttribute",
")",
"value",
"(",
"v",
"[",
"]",
"Equaler",
")",
"Equaler",
"{",
"chooserVal",
":=",
"v",
"[",
"0",
"]",
".",
"(",
"BoolEqualer",
")",
".",
"B",
"\n",
"attrVal",
":=",
"v",
"[",
"1",
"]",
"\n\n",
"if... | //value is the function that takes in the values of the two dependent attributes
//and figures out the value of this attribute, embodied in wrapped. | [
"value",
"is",
"the",
"function",
"that",
"takes",
"in",
"the",
"values",
"of",
"the",
"two",
"dependent",
"attributes",
"and",
"figures",
"out",
"the",
"value",
"of",
"this",
"attribute",
"embodied",
"in",
"wrapped",
"."
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/client/constraint.go#L125-L133 |
154,521 | seven5/seven5 | client/constraint.go | SetEqualer | func (s *SelectableAttribute) SetEqualer(e Equaler) {
if s.chooser.Demand().(BoolEqualer).B {
s.attr.SetEqualer(e)
}
} | go | func (s *SelectableAttribute) SetEqualer(e Equaler) {
if s.chooser.Demand().(BoolEqualer).B {
s.attr.SetEqualer(e)
}
} | [
"func",
"(",
"s",
"*",
"SelectableAttribute",
")",
"SetEqualer",
"(",
"e",
"Equaler",
")",
"{",
"if",
"s",
".",
"chooser",
".",
"Demand",
"(",
")",
".",
"(",
"BoolEqualer",
")",
".",
"B",
"{",
"s",
".",
"attr",
".",
"SetEqualer",
"(",
"e",
")",
"... | //SetEqualer assigns the value provided to the underlying attribute of this
//type, only if the chooser of this SelectableAttribute is true. If the chooser
//is false, this call is ignored. | [
"SetEqualer",
"assigns",
"the",
"value",
"provided",
"to",
"the",
"underlying",
"attribute",
"of",
"this",
"type",
"only",
"if",
"the",
"chooser",
"of",
"this",
"SelectableAttribute",
"is",
"true",
".",
"If",
"the",
"chooser",
"is",
"false",
"this",
"call",
... | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/client/constraint.go#L150-L154 |
154,522 | seven5/seven5 | client/constraint.go | SetDebugName | func (s *SelectableAttribute) SetDebugName(n string) {
s.AttributeImpl.SetDebugName(n)
s.chooser.SetDebugName(fmt.Sprintf("%s-chooser", n))
s.attr.SetDebugName(fmt.Sprintf("%s-attr", n))
} | go | func (s *SelectableAttribute) SetDebugName(n string) {
s.AttributeImpl.SetDebugName(n)
s.chooser.SetDebugName(fmt.Sprintf("%s-chooser", n))
s.attr.SetDebugName(fmt.Sprintf("%s-attr", n))
} | [
"func",
"(",
"s",
"*",
"SelectableAttribute",
")",
"SetDebugName",
"(",
"n",
"string",
")",
"{",
"s",
".",
"AttributeImpl",
".",
"SetDebugName",
"(",
"n",
")",
"\n",
"s",
".",
"chooser",
".",
"SetDebugName",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",... | //SetDebugName is useful when examining debug messages from seven5 itself. | [
"SetDebugName",
"is",
"useful",
"when",
"examining",
"debug",
"messages",
"from",
"seven5",
"itself",
"."
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/client/constraint.go#L157-L161 |
154,523 | seven5/seven5 | client/constraint.go | SetSelected | func (s *SelectableAttribute) SetSelected(b bool) {
s.chooser.SetEqualer(BoolEqualer{B: b})
} | go | func (s *SelectableAttribute) SetSelected(b bool) {
s.chooser.SetEqualer(BoolEqualer{B: b})
} | [
"func",
"(",
"s",
"*",
"SelectableAttribute",
")",
"SetSelected",
"(",
"b",
"bool",
")",
"{",
"s",
".",
"chooser",
".",
"SetEqualer",
"(",
"BoolEqualer",
"{",
"B",
":",
"b",
"}",
")",
"\n",
"}"
] | //SetSelected sets the selected state of this attribute to the value provided. | [
"SetSelected",
"sets",
"the",
"selected",
"state",
"of",
"this",
"attribute",
"to",
"the",
"value",
"provided",
"."
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/client/constraint.go#L164-L166 |
154,524 | salsaflow/salsaflow | modules/issue_tracking/github/release_next.go | Start | func (release *nextRelease) Start() (act action.Action, err error) {
// In case there are no additional issues, we are done.
if len(release.additionalIssues) == 0 {
return action.Noop, nil
}
// Set milestone for the additional issues.
task := fmt.Sprintf(
"Set milestone to '%v' for the issues added automatically",
release.trunkVersion.BaseString())
log.Run(task)
// Get the milestone corresponding to the release branch version string.
chain := action.NewActionChain()
defer chain.RollbackOnError(&err)
milestone, act, err := release.tracker.getOrCreateMilestone(release.trunkVersion)
if err != nil {
return nil, errs.NewError(task, err)
}
chain.Push(act)
// Update the issues.
issues, act, err := release.tracker.updateIssues(
release.additionalIssues, setMilestone(milestone), unsetMilestone())
if err != nil {
return nil, errs.NewError(task, err)
}
chain.Push(act)
release.additionalIssues = issues
return chain, nil
} | go | func (release *nextRelease) Start() (act action.Action, err error) {
// In case there are no additional issues, we are done.
if len(release.additionalIssues) == 0 {
return action.Noop, nil
}
// Set milestone for the additional issues.
task := fmt.Sprintf(
"Set milestone to '%v' for the issues added automatically",
release.trunkVersion.BaseString())
log.Run(task)
// Get the milestone corresponding to the release branch version string.
chain := action.NewActionChain()
defer chain.RollbackOnError(&err)
milestone, act, err := release.tracker.getOrCreateMilestone(release.trunkVersion)
if err != nil {
return nil, errs.NewError(task, err)
}
chain.Push(act)
// Update the issues.
issues, act, err := release.tracker.updateIssues(
release.additionalIssues, setMilestone(milestone), unsetMilestone())
if err != nil {
return nil, errs.NewError(task, err)
}
chain.Push(act)
release.additionalIssues = issues
return chain, nil
} | [
"func",
"(",
"release",
"*",
"nextRelease",
")",
"Start",
"(",
")",
"(",
"act",
"action",
".",
"Action",
",",
"err",
"error",
")",
"{",
"// In case there are no additional issues, we are done.",
"if",
"len",
"(",
"release",
".",
"additionalIssues",
")",
"==",
... | // Start is a part of common.NextRelease interface. | [
"Start",
"is",
"a",
"part",
"of",
"common",
".",
"NextRelease",
"interface",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/modules/issue_tracking/github/release_next.go#L154-L186 |
154,525 | itchio/httpkit | uploader/resumable.go | NewResumableUpload | func NewResumableUpload(uploadURL string, opts ...Option) ResumableUpload {
s := defaultSettings()
for _, o := range opts {
o.Apply(s)
}
id := seed
seed++
chunkUploader := &chunkUploader{
uploadURL: uploadURL,
httpClient: timeout.NewClient(resumableConnectTimeout, resumableIdleTimeout),
id: id,
}
ru := &resumableUpload{
maxChunkGroup: s.MaxChunkGroup,
err: nil,
pushedErr: make(chan struct{}, 0),
splitBuf: new(bytes.Buffer),
blocks: make(chan *rblock),
done: make(chan struct{}, 0),
chunkUploader: chunkUploader,
id: id,
}
ru.splitBuf.Grow(rblockSize)
go ru.work()
return ru
} | go | func NewResumableUpload(uploadURL string, opts ...Option) ResumableUpload {
s := defaultSettings()
for _, o := range opts {
o.Apply(s)
}
id := seed
seed++
chunkUploader := &chunkUploader{
uploadURL: uploadURL,
httpClient: timeout.NewClient(resumableConnectTimeout, resumableIdleTimeout),
id: id,
}
ru := &resumableUpload{
maxChunkGroup: s.MaxChunkGroup,
err: nil,
pushedErr: make(chan struct{}, 0),
splitBuf: new(bytes.Buffer),
blocks: make(chan *rblock),
done: make(chan struct{}, 0),
chunkUploader: chunkUploader,
id: id,
}
ru.splitBuf.Grow(rblockSize)
go ru.work()
return ru
} | [
"func",
"NewResumableUpload",
"(",
"uploadURL",
"string",
",",
"opts",
"...",
"Option",
")",
"ResumableUpload",
"{",
"s",
":=",
"defaultSettings",
"(",
")",
"\n",
"for",
"_",
",",
"o",
":=",
"range",
"opts",
"{",
"o",
".",
"Apply",
"(",
"s",
")",
"\n",... | // NewResumableUpload starts a new resumable upload session
// targeting the specified Google Cloud Storage uploadURL. | [
"NewResumableUpload",
"starts",
"a",
"new",
"resumable",
"upload",
"session",
"targeting",
"the",
"specified",
"Google",
"Cloud",
"Storage",
"uploadURL",
"."
] | f7051ef345456d077d49344cf6ec98b4059214f5 | https://github.com/itchio/httpkit/blob/f7051ef345456d077d49344cf6ec98b4059214f5/uploader/resumable.go#L52-L82 |
154,526 | alicebob/alac | decode.go | readbits | func (alac *Alac) readbits(bits int) uint32 {
var result int32 = 0
if bits > 16 {
bits -= 16
result = int32(alac.readbits_16(16) << uint(bits))
}
result |= int32(alac.readbits_16(bits))
return uint32(result)
} | go | func (alac *Alac) readbits(bits int) uint32 {
var result int32 = 0
if bits > 16 {
bits -= 16
result = int32(alac.readbits_16(16) << uint(bits))
}
result |= int32(alac.readbits_16(bits))
return uint32(result)
} | [
"func",
"(",
"alac",
"*",
"Alac",
")",
"readbits",
"(",
"bits",
"int",
")",
"uint32",
"{",
"var",
"result",
"int32",
"=",
"0",
"\n\n",
"if",
"bits",
">",
"16",
"{",
"bits",
"-=",
"16",
"\n",
"result",
"=",
"int32",
"(",
"alac",
".",
"readbits_16",
... | // supports reading 1 to 32 bits, in big endian format | [
"supports",
"reading",
"1",
"to",
"32",
"bits",
"in",
"big",
"endian",
"format"
] | 838a288e23c9bc47b04112f3bb68a5537ce0c092 | https://github.com/alicebob/alac/blob/838a288e23c9bc47b04112f3bb68a5537ce0c092/decode.go#L197-L208 |
154,527 | salsaflow/salsaflow | config/loader/config_utils.go | ActiveModule | func ActiveModule(local *config.LocalConfig, moduleKind ModuleKind) string {
var (
modulesValue = reflect.ValueOf(local).Elem().FieldByName("Modules")
modulesType = modulesValue.Type()
numField = modulesType.NumField()
kind = string(moduleKind)
)
for i := 0; i < numField; i++ {
var (
fieldValue = modulesValue.Field(i)
fieldType = modulesType.Field(i)
)
if fieldType.Tag.Get("json") == kind {
return fieldValue.Interface().(string)
}
}
return ""
} | go | func ActiveModule(local *config.LocalConfig, moduleKind ModuleKind) string {
var (
modulesValue = reflect.ValueOf(local).Elem().FieldByName("Modules")
modulesType = modulesValue.Type()
numField = modulesType.NumField()
kind = string(moduleKind)
)
for i := 0; i < numField; i++ {
var (
fieldValue = modulesValue.Field(i)
fieldType = modulesType.Field(i)
)
if fieldType.Tag.Get("json") == kind {
return fieldValue.Interface().(string)
}
}
return ""
} | [
"func",
"ActiveModule",
"(",
"local",
"*",
"config",
".",
"LocalConfig",
",",
"moduleKind",
"ModuleKind",
")",
"string",
"{",
"var",
"(",
"modulesValue",
"=",
"reflect",
".",
"ValueOf",
"(",
"local",
")",
".",
"Elem",
"(",
")",
".",
"FieldByName",
"(",
"... | // ActiveModule returns the active module ID for the given module kind
// as stored in the given local configuration file. | [
"ActiveModule",
"returns",
"the",
"active",
"module",
"ID",
"for",
"the",
"given",
"module",
"kind",
"as",
"stored",
"in",
"the",
"given",
"local",
"configuration",
"file",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/config/loader/config_utils.go#L14-L32 |
154,528 | salsaflow/salsaflow | config/loader/config_utils.go | SetActiveModule | func SetActiveModule(
local *config.LocalConfig,
moduleKind ModuleKind,
moduleId string,
) (modified bool, err error) {
var (
modulesValue = reflect.ValueOf(local).Elem().FieldByName("Modules")
modulesType = modulesValue.Type()
numField = modulesType.NumField()
kind = string(moduleKind)
)
for i := 0; i < numField; i++ {
var (
fieldValue = modulesValue.Field(i)
fieldType = modulesType.Field(i)
)
if fieldType.Tag.Get("json") != kind {
continue
}
if fieldValue.Interface().(string) == moduleId {
return false, nil
}
fieldValue.SetString(moduleId)
return true, nil
}
return false, errors.New("unknown module kind: " + kind)
} | go | func SetActiveModule(
local *config.LocalConfig,
moduleKind ModuleKind,
moduleId string,
) (modified bool, err error) {
var (
modulesValue = reflect.ValueOf(local).Elem().FieldByName("Modules")
modulesType = modulesValue.Type()
numField = modulesType.NumField()
kind = string(moduleKind)
)
for i := 0; i < numField; i++ {
var (
fieldValue = modulesValue.Field(i)
fieldType = modulesType.Field(i)
)
if fieldType.Tag.Get("json") != kind {
continue
}
if fieldValue.Interface().(string) == moduleId {
return false, nil
}
fieldValue.SetString(moduleId)
return true, nil
}
return false, errors.New("unknown module kind: " + kind)
} | [
"func",
"SetActiveModule",
"(",
"local",
"*",
"config",
".",
"LocalConfig",
",",
"moduleKind",
"ModuleKind",
",",
"moduleId",
"string",
",",
")",
"(",
"modified",
"bool",
",",
"err",
"error",
")",
"{",
"var",
"(",
"modulesValue",
"=",
"reflect",
".",
"Valu... | // SetActiveModule can be used to set the active module ID for the given module kind. | [
"SetActiveModule",
"can",
"be",
"used",
"to",
"set",
"the",
"active",
"module",
"ID",
"for",
"the",
"given",
"module",
"kind",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/config/loader/config_utils.go#L35-L65 |
154,529 | salsaflow/salsaflow | action/rollback.go | RollbackTaskOnError | func RollbackTaskOnError(err *error, task string, action Action) {
chain := NewActionChain()
chain.PushTask(task, action)
chain.RollbackOnError(err)
} | go | func RollbackTaskOnError(err *error, task string, action Action) {
chain := NewActionChain()
chain.PushTask(task, action)
chain.RollbackOnError(err)
} | [
"func",
"RollbackTaskOnError",
"(",
"err",
"*",
"error",
",",
"task",
"string",
",",
"action",
"Action",
")",
"{",
"chain",
":=",
"NewActionChain",
"(",
")",
"\n",
"chain",
".",
"PushTask",
"(",
"task",
",",
"action",
")",
"\n",
"chain",
".",
"RollbackOn... | // RollbackTaskOnError wraps an ActionChain to perform a rollback on error. | [
"RollbackTaskOnError",
"wraps",
"an",
"ActionChain",
"to",
"perform",
"a",
"rollback",
"on",
"error",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/action/rollback.go#L21-L25 |
154,530 | seven5/seven5 | client/boolean.go | Equal | func (self BoolEqualer) Equal(e Equaler) bool {
return self.B == e.(BoolEqualer).B
} | go | func (self BoolEqualer) Equal(e Equaler) bool {
return self.B == e.(BoolEqualer).B
} | [
"func",
"(",
"self",
"BoolEqualer",
")",
"Equal",
"(",
"e",
"Equaler",
")",
"bool",
"{",
"return",
"self",
".",
"B",
"==",
"e",
".",
"(",
"BoolEqualer",
")",
".",
"B",
"\n",
"}"
] | //Equal compares two values, must be BoolEqualers, to see if they
//are the same. | [
"Equal",
"compares",
"two",
"values",
"must",
"be",
"BoolEqualers",
"to",
"see",
"if",
"they",
"are",
"the",
"same",
"."
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/client/boolean.go#L29-L31 |
154,531 | seven5/seven5 | client/boolean.go | NewBooleanSimple | func NewBooleanSimple(b bool) BooleanAttribute {
result := &BooleanSimple{NewAttribute(NORMAL, nil, nil)}
result.Set(b)
return result
} | go | func NewBooleanSimple(b bool) BooleanAttribute {
result := &BooleanSimple{NewAttribute(NORMAL, nil, nil)}
result.Set(b)
return result
} | [
"func",
"NewBooleanSimple",
"(",
"b",
"bool",
")",
"BooleanAttribute",
"{",
"result",
":=",
"&",
"BooleanSimple",
"{",
"NewAttribute",
"(",
"NORMAL",
",",
"nil",
",",
"nil",
")",
"}",
"\n",
"result",
".",
"Set",
"(",
"b",
")",
"\n",
"return",
"result",
... | //NewBooleanSimple creates a new BooleanAttribute with a simple
//boolean initial value. | [
"NewBooleanSimple",
"creates",
"a",
"new",
"BooleanAttribute",
"with",
"a",
"simple",
"boolean",
"initial",
"value",
"."
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/client/boolean.go#L48-L52 |
154,532 | salsaflow/salsaflow | commands/repo/bootstrap/skeleton.go | pourSkeleton | func pourSkeleton(skeletonName string, localConfigDir string) (err error) {
// Get the skeleton src path.
cacheDir, err := cacheDirectoryAbsolutePath()
if err != nil {
return err
}
skeletonDir := filepath.Join(cacheDir, "github.com", skeletonName)
// Make sure src is a directory, just to be sure.
skeletonInfo, err := os.Stat(skeletonDir)
if err != nil {
return err
}
if !skeletonInfo.IsDir() {
return fmt.Errorf("skeleton source path not a directory: %v", skeletonDir)
}
// Get the list of script files.
srcScriptsDir := filepath.Join(skeletonDir, "scripts")
scripts, err := filepath.Glob(srcScriptsDir + "/*")
if err != nil {
return err
}
if len(scripts) == 0 {
log.Warn("No script files found in the skeleton repository")
return nil
}
// Create the destination directory.
dstScriptsDir := filepath.Join(localConfigDir, "scripts")
if err := os.MkdirAll(dstScriptsDir, 0755); err != nil {
return err
}
// Delete the directory on error.
defer action.RollbackOnError(&err, action.ActionFunc(func() error {
log.Rollback("Create the local scripts directory")
if err := os.RemoveAll(dstScriptsDir); err != nil {
return errs.NewError("Remove the local scripts directory", err)
}
return nil
}))
for _, script := range scripts {
err := func(script string) error {
// Skip directories.
scriptInfo, err := os.Stat(script)
if err != nil {
return err
}
if scriptInfo.IsDir() {
return nil
}
// Copy the file.
filename := script[len(srcScriptsDir)+1:]
fmt.Println("---> Copy", filepath.Join("scripts", filename))
srcFd, err := os.Open(script)
if err != nil {
return err
}
defer srcFd.Close()
dstPath := filepath.Join(dstScriptsDir, filename)
dstFd, err := os.OpenFile(
dstPath, os.O_CREATE|os.O_EXCL|os.O_WRONLY, scriptInfo.Mode())
if err != nil {
return err
}
defer dstFd.Close()
_, err = io.Copy(dstFd, srcFd)
return err
}(script)
if err != nil {
return err
}
}
return nil
} | go | func pourSkeleton(skeletonName string, localConfigDir string) (err error) {
// Get the skeleton src path.
cacheDir, err := cacheDirectoryAbsolutePath()
if err != nil {
return err
}
skeletonDir := filepath.Join(cacheDir, "github.com", skeletonName)
// Make sure src is a directory, just to be sure.
skeletonInfo, err := os.Stat(skeletonDir)
if err != nil {
return err
}
if !skeletonInfo.IsDir() {
return fmt.Errorf("skeleton source path not a directory: %v", skeletonDir)
}
// Get the list of script files.
srcScriptsDir := filepath.Join(skeletonDir, "scripts")
scripts, err := filepath.Glob(srcScriptsDir + "/*")
if err != nil {
return err
}
if len(scripts) == 0 {
log.Warn("No script files found in the skeleton repository")
return nil
}
// Create the destination directory.
dstScriptsDir := filepath.Join(localConfigDir, "scripts")
if err := os.MkdirAll(dstScriptsDir, 0755); err != nil {
return err
}
// Delete the directory on error.
defer action.RollbackOnError(&err, action.ActionFunc(func() error {
log.Rollback("Create the local scripts directory")
if err := os.RemoveAll(dstScriptsDir); err != nil {
return errs.NewError("Remove the local scripts directory", err)
}
return nil
}))
for _, script := range scripts {
err := func(script string) error {
// Skip directories.
scriptInfo, err := os.Stat(script)
if err != nil {
return err
}
if scriptInfo.IsDir() {
return nil
}
// Copy the file.
filename := script[len(srcScriptsDir)+1:]
fmt.Println("---> Copy", filepath.Join("scripts", filename))
srcFd, err := os.Open(script)
if err != nil {
return err
}
defer srcFd.Close()
dstPath := filepath.Join(dstScriptsDir, filename)
dstFd, err := os.OpenFile(
dstPath, os.O_CREATE|os.O_EXCL|os.O_WRONLY, scriptInfo.Mode())
if err != nil {
return err
}
defer dstFd.Close()
_, err = io.Copy(dstFd, srcFd)
return err
}(script)
if err != nil {
return err
}
}
return nil
} | [
"func",
"pourSkeleton",
"(",
"skeletonName",
"string",
",",
"localConfigDir",
"string",
")",
"(",
"err",
"error",
")",
"{",
"// Get the skeleton src path.",
"cacheDir",
",",
"err",
":=",
"cacheDirectoryAbsolutePath",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{"... | // pourSkeleton counts on the fact that skeleton is a valid skeleton
// that is available in the local cache directory. | [
"pourSkeleton",
"counts",
"on",
"the",
"fact",
"that",
"skeleton",
"is",
"a",
"valid",
"skeleton",
"that",
"is",
"available",
"in",
"the",
"local",
"cache",
"directory",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/commands/repo/bootstrap/skeleton.go#L82-L163 |
154,533 | salsaflow/salsaflow | config/loader/loader.go | BootstrapConfig | func BootstrapConfig(spec ConfigSpec) error {
if spec == nil {
return errs.NewErrorWithHint(
"Bootstrap configuration according to the specification",
errors.New("nil configuration specification provided"),
`
Nil configuration specification provided,
please contact the module author to have it fixed.
`,
)
}
if err := bootstrapGlobalConfig(spec); err != nil {
return err
}
return bootstrapLocalConfig(spec)
} | go | func BootstrapConfig(spec ConfigSpec) error {
if spec == nil {
return errs.NewErrorWithHint(
"Bootstrap configuration according to the specification",
errors.New("nil configuration specification provided"),
`
Nil configuration specification provided,
please contact the module author to have it fixed.
`,
)
}
if err := bootstrapGlobalConfig(spec); err != nil {
return err
}
return bootstrapLocalConfig(spec)
} | [
"func",
"BootstrapConfig",
"(",
"spec",
"ConfigSpec",
")",
"error",
"{",
"if",
"spec",
"==",
"nil",
"{",
"return",
"errs",
".",
"NewErrorWithHint",
"(",
"\"",
"\"",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
",",
"`\nNil configuration specification pro... | // BootstrapConfig can be used to bootstrap SalsaFlow configuration
// according to the given configuration specification. | [
"BootstrapConfig",
"can",
"be",
"used",
"to",
"bootstrap",
"SalsaFlow",
"configuration",
"according",
"to",
"the",
"given",
"configuration",
"specification",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/config/loader/loader.go#L22-L39 |
154,534 | salsaflow/salsaflow | config/loader/loader.go | LoadConfig | func LoadConfig(spec ConfigSpec) (err error) {
if spec == nil {
return errs.NewErrorWithHint(
"Load configuration according to the specification",
errors.New("nil configuration specification provided"),
`
Nil configuration specification provided,
please contact the module author to have it fixed.
`,
)
}
if err := bootstrapGlobalConfig(spec); err != nil {
return err
}
return loadLocalConfig(spec)
} | go | func LoadConfig(spec ConfigSpec) (err error) {
if spec == nil {
return errs.NewErrorWithHint(
"Load configuration according to the specification",
errors.New("nil configuration specification provided"),
`
Nil configuration specification provided,
please contact the module author to have it fixed.
`,
)
}
if err := bootstrapGlobalConfig(spec); err != nil {
return err
}
return loadLocalConfig(spec)
} | [
"func",
"LoadConfig",
"(",
"spec",
"ConfigSpec",
")",
"(",
"err",
"error",
")",
"{",
"if",
"spec",
"==",
"nil",
"{",
"return",
"errs",
".",
"NewErrorWithHint",
"(",
"\"",
"\"",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
",",
"`\nNil configuration... | // LoadConfig can be used to load SalsaFlow configuration
// according to the given configuration specification.
//
// The main difference between BootstrapConfig and LoadConfig is that
// LoadConfig returns an error when the local configuration is not valid.
// While `repo bootstrap` is using BootstrapConfig, all other modules
// and commands should be using LoadConfig. The local configuration file
// is only supposed to be generated once during `repo bootstrap`. | [
"LoadConfig",
"can",
"be",
"used",
"to",
"load",
"SalsaFlow",
"configuration",
"according",
"to",
"the",
"given",
"configuration",
"specification",
".",
"The",
"main",
"difference",
"between",
"BootstrapConfig",
"and",
"LoadConfig",
"is",
"that",
"LoadConfig",
"retu... | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/config/loader/loader.go#L49-L66 |
154,535 | salsaflow/salsaflow | config/loader/loader.go | unmarshal | func unmarshal(data []byte, container ConfigContainer) error {
unmarshalFunc := func(v interface{}) error {
return config.Unmarshal(data, v)
}
var err error
unmarshaller, ok := container.(Unmarshaller)
if ok {
err = unmarshaller.Unmarshal(unmarshalFunc)
} else {
err = unmarshalFunc(container)
}
return err
} | go | func unmarshal(data []byte, container ConfigContainer) error {
unmarshalFunc := func(v interface{}) error {
return config.Unmarshal(data, v)
}
var err error
unmarshaller, ok := container.(Unmarshaller)
if ok {
err = unmarshaller.Unmarshal(unmarshalFunc)
} else {
err = unmarshalFunc(container)
}
return err
} | [
"func",
"unmarshal",
"(",
"data",
"[",
"]",
"byte",
",",
"container",
"ConfigContainer",
")",
"error",
"{",
"unmarshalFunc",
":=",
"func",
"(",
"v",
"interface",
"{",
"}",
")",
"error",
"{",
"return",
"config",
".",
"Unmarshal",
"(",
"data",
",",
"v",
... | // unmarshal unmarshals data into container.
//
// In case the container implements Unmarshaller interface,
// the custom unmarshalling function is used. Otherwise data
// is simply unmarshalled into container. | [
"unmarshal",
"unmarshals",
"data",
"into",
"container",
".",
"In",
"case",
"the",
"container",
"implements",
"Unmarshaller",
"interface",
"the",
"custom",
"unmarshalling",
"function",
"is",
"used",
".",
"Otherwise",
"data",
"is",
"simply",
"unmarshalled",
"into",
... | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/config/loader/loader.go#L337-L350 |
154,536 | salsaflow/salsaflow | config/loader/loader.go | marshal | func marshal(container ConfigContainer) ([]byte, error) {
var (
v interface{}
err error
)
marshaller, ok := container.(Marshaller)
if ok {
v, err = marshaller.Marshal()
} else {
v = container
}
if err != nil {
return nil, err
}
return config.Marshal(v)
} | go | func marshal(container ConfigContainer) ([]byte, error) {
var (
v interface{}
err error
)
marshaller, ok := container.(Marshaller)
if ok {
v, err = marshaller.Marshal()
} else {
v = container
}
if err != nil {
return nil, err
}
return config.Marshal(v)
} | [
"func",
"marshal",
"(",
"container",
"ConfigContainer",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"var",
"(",
"v",
"interface",
"{",
"}",
"\n",
"err",
"error",
"\n",
")",
"\n",
"marshaller",
",",
"ok",
":=",
"container",
".",
"(",
"Marshall... | // marshal marshals container and returns the raw data.
//
// In case the container implements Marshaller interface,
// the custom marshalling function is used. Otherwise
// the container itself is simply marshalled directly. | [
"marshal",
"marshals",
"container",
"and",
"returns",
"the",
"raw",
"data",
".",
"In",
"case",
"the",
"container",
"implements",
"Marshaller",
"interface",
"the",
"custom",
"marshalling",
"function",
"is",
"used",
".",
"Otherwise",
"the",
"container",
"itself",
... | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/config/loader/loader.go#L357-L373 |
154,537 | salsaflow/salsaflow | config/loader/loader.go | validate | func validate(container ConfigContainer, sectionPath string) error {
var err error
validator, ok := container.(Validator)
if ok {
err = validator.Validate(sectionPath)
} else {
err = config.EnsureValueFilled(container, sectionPath)
}
return err
} | go | func validate(container ConfigContainer, sectionPath string) error {
var err error
validator, ok := container.(Validator)
if ok {
err = validator.Validate(sectionPath)
} else {
err = config.EnsureValueFilled(container, sectionPath)
}
return err
} | [
"func",
"validate",
"(",
"container",
"ConfigContainer",
",",
"sectionPath",
"string",
")",
"error",
"{",
"var",
"err",
"error",
"\n",
"validator",
",",
"ok",
":=",
"container",
".",
"(",
"Validator",
")",
"\n",
"if",
"ok",
"{",
"err",
"=",
"validator",
... | // validate validates the configuration stored in the container.
//
// In case the container implements Validator interface,
// the custom validation function is used. Otherwise config.EnsureValueFilled
// is used, which means that all exported fields must be set for the config
// to be treated as valid. | [
"validate",
"validates",
"the",
"configuration",
"stored",
"in",
"the",
"container",
".",
"In",
"case",
"the",
"container",
"implements",
"Validator",
"interface",
"the",
"custom",
"validation",
"function",
"is",
"used",
".",
"Otherwise",
"config",
".",
"EnsureVal... | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/config/loader/loader.go#L381-L390 |
154,538 | seven5/seven5 | component.go | AddComponents | func (c *SimpleComponentMatcher) AddComponents(sc ...StaticComponent) {
c.comp = append(c.comp, sc...)
} | go | func (c *SimpleComponentMatcher) AddComponents(sc ...StaticComponent) {
c.comp = append(c.comp, sc...)
} | [
"func",
"(",
"c",
"*",
"SimpleComponentMatcher",
")",
"AddComponents",
"(",
"sc",
"...",
"StaticComponent",
")",
"{",
"c",
".",
"comp",
"=",
"append",
"(",
"c",
".",
"comp",
",",
"sc",
"...",
")",
"\n",
"}"
] | //AddComponent adds any number of StaticComponents to this matcher. | [
"AddComponent",
"adds",
"any",
"number",
"of",
"StaticComponents",
"to",
"this",
"matcher",
"."
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/component.go#L332-L334 |
154,539 | seven5/seven5 | component.go | isKnownLang | func (c *SimpleComponentMatcher) isKnownLang(l string) bool {
return l == "en" || l == "fr" || l == "zh" || l == "fixed"
} | go | func (c *SimpleComponentMatcher) isKnownLang(l string) bool {
return l == "en" || l == "fr" || l == "zh" || l == "fixed"
} | [
"func",
"(",
"c",
"*",
"SimpleComponentMatcher",
")",
"isKnownLang",
"(",
"l",
"string",
")",
"bool",
"{",
"return",
"l",
"==",
"\"",
"\"",
"||",
"l",
"==",
"\"",
"\"",
"||",
"l",
"==",
"\"",
"\"",
"||",
"l",
"==",
"\"",
"\"",
"\n",
"}"
] | //XXX fix me | [
"XXX",
"fix",
"me"
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/component.go#L354-L356 |
154,540 | salsaflow/salsaflow | releases/notes/encoder_internal.go | toInternalRepresentation | func toInternalRepresentation(notes *common.ReleaseNotes) *releaseNotes {
// Sort the sections.
// The sections are most probably already sorted, but just to be sure.
sortedSections := make([]*common.ReleaseNotesSection, len(notes.Sections))
copy(sortedSections, notes.Sections)
sort.Sort(common.ReleaseNotesSections(sortedSections))
// Generate sections.
var sections []*releaseNotesSection
for _, section := range sortedSections {
// Sort stories. What this means is specified to each issue tracker.
sort.Sort(common.Stories(section.Stories))
// Generate the story section.
var stories []*story
for _, s := range section.Stories {
stories = append(stories, &story{
Id: s.ReadableId(),
Title: s.Title(),
URL: s.URL(),
})
}
sections = append(sections, &releaseNotesSection{
StoryType: strings.Title(section.StoryType),
Stories: stories,
})
}
// Return the new internal representation.
return &releaseNotes{
Version: notes.Version.BaseString(),
Sections: sections,
}
} | go | func toInternalRepresentation(notes *common.ReleaseNotes) *releaseNotes {
// Sort the sections.
// The sections are most probably already sorted, but just to be sure.
sortedSections := make([]*common.ReleaseNotesSection, len(notes.Sections))
copy(sortedSections, notes.Sections)
sort.Sort(common.ReleaseNotesSections(sortedSections))
// Generate sections.
var sections []*releaseNotesSection
for _, section := range sortedSections {
// Sort stories. What this means is specified to each issue tracker.
sort.Sort(common.Stories(section.Stories))
// Generate the story section.
var stories []*story
for _, s := range section.Stories {
stories = append(stories, &story{
Id: s.ReadableId(),
Title: s.Title(),
URL: s.URL(),
})
}
sections = append(sections, &releaseNotesSection{
StoryType: strings.Title(section.StoryType),
Stories: stories,
})
}
// Return the new internal representation.
return &releaseNotes{
Version: notes.Version.BaseString(),
Sections: sections,
}
} | [
"func",
"toInternalRepresentation",
"(",
"notes",
"*",
"common",
".",
"ReleaseNotes",
")",
"*",
"releaseNotes",
"{",
"// Sort the sections.",
"// The sections are most probably already sorted, but just to be sure.",
"sortedSections",
":=",
"make",
"(",
"[",
"]",
"*",
"commo... | // toInternalRepresentation converts the given release notes to an internal
// representation that is easily serializable any typical encoder. | [
"toInternalRepresentation",
"converts",
"the",
"given",
"release",
"notes",
"to",
"an",
"internal",
"representation",
"that",
"is",
"easily",
"serializable",
"any",
"typical",
"encoder",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/releases/notes/encoder_internal.go#L35-L68 |
154,541 | salsaflow/salsaflow | hooks/check.go | CheckAndUpsert | func CheckAndUpsert(hookType HookType, force bool) error {
// Declade some variables so that we can use goto.
var confirmed bool
// Ping the git hook with our secret argument.
repoRoot, err := gitutil.RepositoryRootAbsolutePath()
if err != nil {
return err
}
hookDestPath := filepath.Join(repoRoot, ".git", "hooks", string(hookType))
// Try to get the hook version.
stdout, _, _ := shell.Run(hookDestPath, "-"+versionFlag)
// In case the versions match, we are done here (unless force).
installedVersion, err := version.Parse(strings.TrimSpace(stdout.String()))
if !force && installedVersion != nil && installedVersion.String() == metadata.Version {
return nil
}
// Get the hook executable absolute path. It's supposed to be installed
// in the same directory as the salsaflow executable itself.
task := "Get the executable folder absolute path"
binDir, err := osext.ExecutableFolder()
if err != nil {
return errs.NewError(task, err)
}
hookExecutable := filepath.Join(binDir, getHookFileName(hookType))
// Check whether there is a hook already present in the repository.
// If there is no hook or there is a SalsaFlow hook returning a different version string,
// we don't have to ask the user, we can just install the hook.
task = fmt.Sprintf("Check whether there is a git %v hook already installed", hookType)
if _, err := os.Stat(hookDestPath); err != nil {
if os.IsNotExist(err) {
return copyHook(hookType, hookExecutable, hookDestPath)
}
return errs.NewError(task, err)
}
if installedVersion != nil || force {
return copyHook(hookType, hookExecutable, hookDestPath)
}
// Prompt the user to confirm the SalsaFlow git commit-task hook.
task = fmt.Sprintf("Prompt the user to confirm the %v hook", hookType)
confirmed, err = prompt.Confirm(`
I need my own git `+string(hookType)+` hook to be placed in the repository.
Shall I create or replace your current `+string(hookType)+` hook?`, true)
fmt.Println()
if err != nil {
return errs.NewError(task, err)
}
if !confirmed {
// User stubbornly refuses to let us overwrite their webhook.
// Inform the init has failed and let them do their thing.
fmt.Printf(`I need the hook in order to do my job!
Please make sure the executable located at
%v
runs as your `+string(hookType)+` hook and run me again!
`, hookExecutable)
return errs.NewError(task, fmt.Errorf("SalsaFlow git %v hook not detected", hookType))
}
return copyHook(hookType, hookExecutable, hookDestPath)
} | go | func CheckAndUpsert(hookType HookType, force bool) error {
// Declade some variables so that we can use goto.
var confirmed bool
// Ping the git hook with our secret argument.
repoRoot, err := gitutil.RepositoryRootAbsolutePath()
if err != nil {
return err
}
hookDestPath := filepath.Join(repoRoot, ".git", "hooks", string(hookType))
// Try to get the hook version.
stdout, _, _ := shell.Run(hookDestPath, "-"+versionFlag)
// In case the versions match, we are done here (unless force).
installedVersion, err := version.Parse(strings.TrimSpace(stdout.String()))
if !force && installedVersion != nil && installedVersion.String() == metadata.Version {
return nil
}
// Get the hook executable absolute path. It's supposed to be installed
// in the same directory as the salsaflow executable itself.
task := "Get the executable folder absolute path"
binDir, err := osext.ExecutableFolder()
if err != nil {
return errs.NewError(task, err)
}
hookExecutable := filepath.Join(binDir, getHookFileName(hookType))
// Check whether there is a hook already present in the repository.
// If there is no hook or there is a SalsaFlow hook returning a different version string,
// we don't have to ask the user, we can just install the hook.
task = fmt.Sprintf("Check whether there is a git %v hook already installed", hookType)
if _, err := os.Stat(hookDestPath); err != nil {
if os.IsNotExist(err) {
return copyHook(hookType, hookExecutable, hookDestPath)
}
return errs.NewError(task, err)
}
if installedVersion != nil || force {
return copyHook(hookType, hookExecutable, hookDestPath)
}
// Prompt the user to confirm the SalsaFlow git commit-task hook.
task = fmt.Sprintf("Prompt the user to confirm the %v hook", hookType)
confirmed, err = prompt.Confirm(`
I need my own git `+string(hookType)+` hook to be placed in the repository.
Shall I create or replace your current `+string(hookType)+` hook?`, true)
fmt.Println()
if err != nil {
return errs.NewError(task, err)
}
if !confirmed {
// User stubbornly refuses to let us overwrite their webhook.
// Inform the init has failed and let them do their thing.
fmt.Printf(`I need the hook in order to do my job!
Please make sure the executable located at
%v
runs as your `+string(hookType)+` hook and run me again!
`, hookExecutable)
return errs.NewError(task, fmt.Errorf("SalsaFlow git %v hook not detected", hookType))
}
return copyHook(hookType, hookExecutable, hookDestPath)
} | [
"func",
"CheckAndUpsert",
"(",
"hookType",
"HookType",
",",
"force",
"bool",
")",
"error",
"{",
"// Declade some variables so that we can use goto.",
"var",
"confirmed",
"bool",
"\n\n",
"// Ping the git hook with our secret argument.",
"repoRoot",
",",
"err",
":=",
"gitutil... | // Check whether SalsaFlow git hook is used. Prompts user to install our hook if it isn't.
//
// When the force argument is set to true, the hook is replaced when though the version matches. | [
"Check",
"whether",
"SalsaFlow",
"git",
"hook",
"is",
"used",
".",
"Prompts",
"user",
"to",
"install",
"our",
"hook",
"if",
"it",
"isn",
"t",
".",
"When",
"the",
"force",
"argument",
"is",
"set",
"to",
"true",
"the",
"hook",
"is",
"replaced",
"when",
"... | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/hooks/check.go#L52-L121 |
154,542 | salsaflow/salsaflow | hooks/check.go | copyHook | func copyHook(hookType HookType, hookExecutable, hookDestPath string) error {
task := fmt.Sprintf("Install the SalsaFlow git %v hook", hookType)
if err := fileutil.CopyFile(hookExecutable, hookDestPath); err != nil {
return errs.NewError(task, err)
}
if err := os.Chmod(hookDestPath, 0750); err != nil {
return errs.NewError(task, err)
}
log.Log(fmt.Sprintf("SalsaFlow git %v hook installed", hookType))
return nil
} | go | func copyHook(hookType HookType, hookExecutable, hookDestPath string) error {
task := fmt.Sprintf("Install the SalsaFlow git %v hook", hookType)
if err := fileutil.CopyFile(hookExecutable, hookDestPath); err != nil {
return errs.NewError(task, err)
}
if err := os.Chmod(hookDestPath, 0750); err != nil {
return errs.NewError(task, err)
}
log.Log(fmt.Sprintf("SalsaFlow git %v hook installed", hookType))
return nil
} | [
"func",
"copyHook",
"(",
"hookType",
"HookType",
",",
"hookExecutable",
",",
"hookDestPath",
"string",
")",
"error",
"{",
"task",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"hookType",
")",
"\n",
"if",
"err",
":=",
"fileutil",
".",
"CopyFile",
"(... | // copyHook installs the SalsaFlow git hook by copying the hook executable
// from the expected absolute path to the git config hook directory. | [
"copyHook",
"installs",
"the",
"SalsaFlow",
"git",
"hook",
"by",
"copying",
"the",
"hook",
"executable",
"from",
"the",
"expected",
"absolute",
"path",
"to",
"the",
"git",
"config",
"hook",
"directory",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/hooks/check.go#L125-L135 |
154,543 | seven5/seven5 | encode.go | SendJson | func SendJson(w http.ResponseWriter, i interface{}) error {
var buf bytes.Buffer
enc := json.NewEncoder(&buf)
if err := enc.Encode(i); err != nil {
http.Error(w, fmt.Sprintf("unable to encode: %v", err), http.StatusInternalServerError)
log.Printf("[SENDJSON] unable to encode json output in SendUserDetails: %v", err)
return err
}
count := 0
for count < buf.Len() {
w, err := w.Write(buf.Bytes()[count:])
if err != nil {
log.Printf("[SENDJSON] failed to write: %v", err)
return err
}
count += w
}
return nil
} | go | func SendJson(w http.ResponseWriter, i interface{}) error {
var buf bytes.Buffer
enc := json.NewEncoder(&buf)
if err := enc.Encode(i); err != nil {
http.Error(w, fmt.Sprintf("unable to encode: %v", err), http.StatusInternalServerError)
log.Printf("[SENDJSON] unable to encode json output in SendUserDetails: %v", err)
return err
}
count := 0
for count < buf.Len() {
w, err := w.Write(buf.Bytes()[count:])
if err != nil {
log.Printf("[SENDJSON] failed to write: %v", err)
return err
}
count += w
}
return nil
} | [
"func",
"SendJson",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"i",
"interface",
"{",
"}",
")",
"error",
"{",
"var",
"buf",
"bytes",
".",
"Buffer",
"\n",
"enc",
":=",
"json",
".",
"NewEncoder",
"(",
"&",
"buf",
")",
"\n",
"if",
"err",
":=",
"enc... | //Utility routine to send a json blob to the client side. Encoding errors
//are logged to the terminal and the client will recv a 500 error. | [
"Utility",
"routine",
"to",
"send",
"a",
"json",
"blob",
"to",
"the",
"client",
"side",
".",
"Encoding",
"errors",
"are",
"logged",
"to",
"the",
"terminal",
"and",
"the",
"client",
"will",
"recv",
"a",
"500",
"error",
"."
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/encode.go#L51-L69 |
154,544 | salsaflow/salsaflow | config/check.go | EnsureValueFilled | func EnsureValueFilled(value interface{}, path string) error {
logger := log.V(log.Debug)
// Turn the interface into reflect.Value.
var (
v = reflect.ValueOf(value)
t = v.Type()
)
logger.Log(fmt.Sprintf(`config.EnsureValueFilled: Checking "%v" ... `, path))
// Handle pointers in a special way.
if kind := v.Kind(); kind == reflect.Ptr || kind == reflect.Slice {
if v.IsNil() {
logger.NewLine(" ---> Nil")
return &ErrKeyNotSet{path}
}
}
// Decide what to do depending on the value kind.
iv := reflect.Indirect(v)
switch iv.Kind() {
case reflect.Struct:
return ensureStructFilled(iv, path)
case reflect.Slice:
return ensureSliceFilled(iv, path)
}
// In case the value is not valid, return an error.
if !v.IsValid() {
logger.NewLine(" ---> Invalid")
return &ErrKeyNotSet{path}
}
// In case the field is set to the zero value of the given type,
// we return an error since the field is not set.
if reflect.DeepEqual(v.Interface(), reflect.Zero(t).Interface()) {
logger.NewLine(" ---> Unset")
return &ErrKeyNotSet{path}
}
if logger {
logger.NewLine(fmt.Sprintf(" ---> OK (set to '%v')", v.Interface()))
}
return nil
} | go | func EnsureValueFilled(value interface{}, path string) error {
logger := log.V(log.Debug)
// Turn the interface into reflect.Value.
var (
v = reflect.ValueOf(value)
t = v.Type()
)
logger.Log(fmt.Sprintf(`config.EnsureValueFilled: Checking "%v" ... `, path))
// Handle pointers in a special way.
if kind := v.Kind(); kind == reflect.Ptr || kind == reflect.Slice {
if v.IsNil() {
logger.NewLine(" ---> Nil")
return &ErrKeyNotSet{path}
}
}
// Decide what to do depending on the value kind.
iv := reflect.Indirect(v)
switch iv.Kind() {
case reflect.Struct:
return ensureStructFilled(iv, path)
case reflect.Slice:
return ensureSliceFilled(iv, path)
}
// In case the value is not valid, return an error.
if !v.IsValid() {
logger.NewLine(" ---> Invalid")
return &ErrKeyNotSet{path}
}
// In case the field is set to the zero value of the given type,
// we return an error since the field is not set.
if reflect.DeepEqual(v.Interface(), reflect.Zero(t).Interface()) {
logger.NewLine(" ---> Unset")
return &ErrKeyNotSet{path}
}
if logger {
logger.NewLine(fmt.Sprintf(" ---> OK (set to '%v')", v.Interface()))
}
return nil
} | [
"func",
"EnsureValueFilled",
"(",
"value",
"interface",
"{",
"}",
",",
"path",
"string",
")",
"error",
"{",
"logger",
":=",
"log",
".",
"V",
"(",
"log",
".",
"Debug",
")",
"\n\n",
"// Turn the interface into reflect.Value.",
"var",
"(",
"v",
"=",
"reflect",
... | // EnsureValueFilled returns an error in case the value passed in is not set.
//
// The function checks structs and slices recursively. | [
"EnsureValueFilled",
"returns",
"an",
"error",
"in",
"case",
"the",
"value",
"passed",
"in",
"is",
"not",
"set",
".",
"The",
"function",
"checks",
"structs",
"and",
"slices",
"recursively",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/config/check.go#L15-L60 |
154,545 | seven5/seven5 | session.go | NewSimpleSession | func NewSimpleSession(userData interface{}, sid string) *SimpleSession {
var s = sid
if sid == "" {
s = UDID()
}
return &SimpleSession{s, userData}
} | go | func NewSimpleSession(userData interface{}, sid string) *SimpleSession {
var s = sid
if sid == "" {
s = UDID()
}
return &SimpleSession{s, userData}
} | [
"func",
"NewSimpleSession",
"(",
"userData",
"interface",
"{",
"}",
",",
"sid",
"string",
")",
"*",
"SimpleSession",
"{",
"var",
"s",
"=",
"sid",
"\n",
"if",
"sid",
"==",
"\"",
"\"",
"{",
"s",
"=",
"UDID",
"(",
")",
"\n",
"}",
"\n",
"return",
"&",
... | //NewSimpleSession returns a new simple session with its SessionId initialized.
//If the sid is "", a new UDID is generated as the session ID, but most applications
//will want to control this so that sessions are stable across runs. | [
"NewSimpleSession",
"returns",
"a",
"new",
"simple",
"session",
"with",
"its",
"SessionId",
"initialized",
".",
"If",
"the",
"sid",
"is",
"a",
"new",
"UDID",
"is",
"generated",
"as",
"the",
"session",
"ID",
"but",
"most",
"applications",
"will",
"want",
"to"... | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/session.go#L80-L86 |
154,546 | seven5/seven5 | session.go | NewDumbSessionManager | func NewDumbSessionManager() *SimpleSessionManager {
result := &SimpleSessionManager{
out: make(chan *sessionPacket),
generator: nil,
}
go handleSessionChecks(result.out, []byte{})
return result
} | go | func NewDumbSessionManager() *SimpleSessionManager {
result := &SimpleSessionManager{
out: make(chan *sessionPacket),
generator: nil,
}
go handleSessionChecks(result.out, []byte{})
return result
} | [
"func",
"NewDumbSessionManager",
"(",
")",
"*",
"SimpleSessionManager",
"{",
"result",
":=",
"&",
"SimpleSessionManager",
"{",
"out",
":",
"make",
"(",
"chan",
"*",
"sessionPacket",
")",
",",
"generator",
":",
"nil",
",",
"}",
"\n",
"go",
"handleSessionChecks"... | //NewDumbSessionManager returns a session manager that makes no attempt
//to conceal the client session id from the client, so this is probably only
//useful for tests. | [
"NewDumbSessionManager",
"returns",
"a",
"session",
"manager",
"that",
"makes",
"no",
"attempt",
"to",
"conceal",
"the",
"client",
"session",
"id",
"from",
"the",
"client",
"so",
"this",
"is",
"probably",
"only",
"useful",
"for",
"tests",
"."
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/session.go#L132-L139 |
154,547 | seven5/seven5 | session.go | handleSessionChecks | func handleSessionChecks(ch chan *sessionPacket, key []byte) {
hash := make(map[string]Session)
var err error
var block cipher.Block
if len(key) != 0 {
block, err = aes.NewCipher(key)
if err != nil {
log.Fatalf("unable to get AES cipher: %v", err)
}
}
var result *SessionReturn
for {
pkt := <-ch
packetsProcessed++
result = nil //safety
switch pkt.op {
case _SESSION_OP_DEL:
_, ok := hash[pkt.sessionId]
if ok {
delete(hash, pkt.sessionId)
}
result = nil
case _SESSION_OP_CREATE:
var sid string
if block == nil {
sid = pkt.uniqueInfo
} else {
sessionId := computeRawSessionId(pkt.uniqueInfo, pkt.expires)
sid = encryptSessionId(sessionId, block)
}
s := NewSimpleSession(pkt.userData, sid)
hash[sid] = s
result = &SessionReturn{Session: s}
case _SESSION_OP_UPDATE:
_, ok := hash[pkt.sessionId]
if !ok {
result = nil
} else {
s := NewSimpleSession(pkt.userData, pkt.sessionId)
result = &SessionReturn{Session: s}
}
case _SESSION_OP_FIND:
s, ok := hash[pkt.sessionId]
if !ok {
if block == nil {
//this is the dodgy bit
result = &SessionReturn{UniqueId: pkt.sessionId}
break
}
uniq, ok := decryptSessionId(pkt.sessionId, block)
if !ok {
result = nil
break
}
result = &SessionReturn{UniqueId: uniq}
} else {
if block == nil {
result = &SessionReturn{Session: s}
break
}
//expired?
_, ok := decryptSessionId(pkt.sessionId, block)
if !ok {
delete(hash, pkt.sessionId)
result = nil
} else {
result = &SessionReturn{Session: s}
}
}
}
pkt.ret <- result
}
} | go | func handleSessionChecks(ch chan *sessionPacket, key []byte) {
hash := make(map[string]Session)
var err error
var block cipher.Block
if len(key) != 0 {
block, err = aes.NewCipher(key)
if err != nil {
log.Fatalf("unable to get AES cipher: %v", err)
}
}
var result *SessionReturn
for {
pkt := <-ch
packetsProcessed++
result = nil //safety
switch pkt.op {
case _SESSION_OP_DEL:
_, ok := hash[pkt.sessionId]
if ok {
delete(hash, pkt.sessionId)
}
result = nil
case _SESSION_OP_CREATE:
var sid string
if block == nil {
sid = pkt.uniqueInfo
} else {
sessionId := computeRawSessionId(pkt.uniqueInfo, pkt.expires)
sid = encryptSessionId(sessionId, block)
}
s := NewSimpleSession(pkt.userData, sid)
hash[sid] = s
result = &SessionReturn{Session: s}
case _SESSION_OP_UPDATE:
_, ok := hash[pkt.sessionId]
if !ok {
result = nil
} else {
s := NewSimpleSession(pkt.userData, pkt.sessionId)
result = &SessionReturn{Session: s}
}
case _SESSION_OP_FIND:
s, ok := hash[pkt.sessionId]
if !ok {
if block == nil {
//this is the dodgy bit
result = &SessionReturn{UniqueId: pkt.sessionId}
break
}
uniq, ok := decryptSessionId(pkt.sessionId, block)
if !ok {
result = nil
break
}
result = &SessionReturn{UniqueId: uniq}
} else {
if block == nil {
result = &SessionReturn{Session: s}
break
}
//expired?
_, ok := decryptSessionId(pkt.sessionId, block)
if !ok {
delete(hash, pkt.sessionId)
result = nil
} else {
result = &SessionReturn{Session: s}
}
}
}
pkt.ret <- result
}
} | [
"func",
"handleSessionChecks",
"(",
"ch",
"chan",
"*",
"sessionPacket",
",",
"key",
"[",
"]",
"byte",
")",
"{",
"hash",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"Session",
")",
"\n\n",
"var",
"err",
"error",
"\n",
"var",
"block",
"cipher",
".",
... | //handleSessionChecks is the goroutine that reads session manager requests and responds based on its
//map. Each operation has a sessionPacket and that has on op to tell us how to
//process each one. | [
"handleSessionChecks",
"is",
"the",
"goroutine",
"that",
"reads",
"session",
"manager",
"requests",
"and",
"responds",
"based",
"on",
"its",
"map",
".",
"Each",
"operation",
"has",
"a",
"sessionPacket",
"and",
"that",
"has",
"on",
"op",
"to",
"tell",
"us",
"... | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/session.go#L178-L256 |
154,548 | seven5/seven5 | session.go | Assign | func (self *SimpleSessionManager) Assign(uniqueInfo string, userData interface{}, expires time.Time) (Session, error) {
ch := make(chan *SessionReturn)
if expires.IsZero() {
expires = time.Now().Add(24 * time.Hour)
}
pkt := &sessionPacket{
op: _SESSION_OP_CREATE,
uniqueInfo: uniqueInfo,
userData: userData,
expires: expires,
ret: ch,
}
self.out <- pkt
sr := <-ch
close(ch)
//this the now initialized session
return sr.Session, nil
} | go | func (self *SimpleSessionManager) Assign(uniqueInfo string, userData interface{}, expires time.Time) (Session, error) {
ch := make(chan *SessionReturn)
if expires.IsZero() {
expires = time.Now().Add(24 * time.Hour)
}
pkt := &sessionPacket{
op: _SESSION_OP_CREATE,
uniqueInfo: uniqueInfo,
userData: userData,
expires: expires,
ret: ch,
}
self.out <- pkt
sr := <-ch
close(ch)
//this the now initialized session
return sr.Session, nil
} | [
"func",
"(",
"self",
"*",
"SimpleSessionManager",
")",
"Assign",
"(",
"uniqueInfo",
"string",
",",
"userData",
"interface",
"{",
"}",
",",
"expires",
"time",
".",
"Time",
")",
"(",
"Session",
",",
"error",
")",
"{",
"ch",
":=",
"make",
"(",
"chan",
"*"... | //Assign is responsible for connecting the unique key for the user to a session.
//The unique key should not contain colon or comma, email address or primary key from
//the database are good choices. The userData will be initially assigned to the
//new session. Note that you can't change the uniqueInfo later without some
//work, so making it the email address can be trying. The expiration time
//can be in the past, that is useful for testing. If the expiration time is
//the time zero value, the expiration time of one day from now will be used. | [
"Assign",
"is",
"responsible",
"for",
"connecting",
"the",
"unique",
"key",
"for",
"the",
"user",
"to",
"a",
"session",
".",
"The",
"unique",
"key",
"should",
"not",
"contain",
"colon",
"or",
"comma",
"email",
"address",
"or",
"primary",
"key",
"from",
"th... | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/session.go#L265-L286 |
154,549 | seven5/seven5 | session.go | Update | func (self *SimpleSessionManager) Update(session Session, i interface{}) (Session, error) {
ch := make(chan *SessionReturn)
pkt := &sessionPacket{
op: _SESSION_OP_UPDATE,
userData: i,
sessionId: session.SessionId(),
ret: ch,
}
self.out <- pkt
sr := <-ch
close(ch)
//this the now initialized session
return sr.Session, nil
} | go | func (self *SimpleSessionManager) Update(session Session, i interface{}) (Session, error) {
ch := make(chan *SessionReturn)
pkt := &sessionPacket{
op: _SESSION_OP_UPDATE,
userData: i,
sessionId: session.SessionId(),
ret: ch,
}
self.out <- pkt
sr := <-ch
close(ch)
//this the now initialized session
return sr.Session, nil
} | [
"func",
"(",
"self",
"*",
"SimpleSessionManager",
")",
"Update",
"(",
"session",
"Session",
",",
"i",
"interface",
"{",
"}",
")",
"(",
"Session",
",",
"error",
")",
"{",
"ch",
":=",
"make",
"(",
"chan",
"*",
"SessionReturn",
")",
"\n\n",
"pkt",
":=",
... | //Update is called from the actual response handlers in the web app to inform
//us that the session's user data needs to change. Note that a different
//Session will be returned here and this is the new session for that id.
//The returned session should not be cached but should be looked up with
//Find each time. Note that you may not change the value of the unique id
//via this method or everything will go very badly wrong. | [
"Update",
"is",
"called",
"from",
"the",
"actual",
"response",
"handlers",
"in",
"the",
"web",
"app",
"to",
"inform",
"us",
"that",
"the",
"session",
"s",
"user",
"data",
"needs",
"to",
"change",
".",
"Note",
"that",
"a",
"different",
"Session",
"will",
... | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/session.go#L294-L309 |
154,550 | seven5/seven5 | session.go | Destroy | func (self *SimpleSessionManager) Destroy(id string) error {
ch := make(chan *SessionReturn)
pkt := &sessionPacket{
op: _SESSION_OP_DEL,
sessionId: id,
ret: ch,
}
self.out <- pkt
_ = <-ch
close(ch)
return nil
} | go | func (self *SimpleSessionManager) Destroy(id string) error {
ch := make(chan *SessionReturn)
pkt := &sessionPacket{
op: _SESSION_OP_DEL,
sessionId: id,
ret: ch,
}
self.out <- pkt
_ = <-ch
close(ch)
return nil
} | [
"func",
"(",
"self",
"*",
"SimpleSessionManager",
")",
"Destroy",
"(",
"id",
"string",
")",
"error",
"{",
"ch",
":=",
"make",
"(",
"chan",
"*",
"SessionReturn",
")",
"\n\n",
"pkt",
":=",
"&",
"sessionPacket",
"{",
"op",
":",
"_SESSION_OP_DEL",
",",
"sess... | //Destroy is called when a user requests to logout. The value provided should be
//the session id, not the unique user info. | [
"Destroy",
"is",
"called",
"when",
"a",
"user",
"requests",
"to",
"logout",
".",
"The",
"value",
"provided",
"should",
"be",
"the",
"session",
"id",
"not",
"the",
"unique",
"user",
"info",
"."
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/session.go#L313-L326 |
154,551 | seven5/seven5 | session.go | encryptSessionId | func encryptSessionId(cleartext string, block cipher.Block) string {
ciphertext := make([]byte, len(cleartext)+aes.BlockSize)
iv := ciphertext[:aes.BlockSize]
if _, err := io.ReadFull(rand.Reader, iv); err != nil {
log.Panicf("failed to read the random stream: %v", err)
}
stream := cipher.NewCTR(block, iv)
stream.XORKeyStream(ciphertext[aes.BlockSize:], []byte(cleartext))
output := make([]byte, len(ciphertext)*2)
hex.Encode(output, ciphertext)
return string(output)
} | go | func encryptSessionId(cleartext string, block cipher.Block) string {
ciphertext := make([]byte, len(cleartext)+aes.BlockSize)
iv := ciphertext[:aes.BlockSize]
if _, err := io.ReadFull(rand.Reader, iv); err != nil {
log.Panicf("failed to read the random stream: %v", err)
}
stream := cipher.NewCTR(block, iv)
stream.XORKeyStream(ciphertext[aes.BlockSize:], []byte(cleartext))
output := make([]byte, len(ciphertext)*2)
hex.Encode(output, ciphertext)
return string(output)
} | [
"func",
"encryptSessionId",
"(",
"cleartext",
"string",
",",
"block",
"cipher",
".",
"Block",
")",
"string",
"{",
"ciphertext",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"len",
"(",
"cleartext",
")",
"+",
"aes",
".",
"BlockSize",
")",
"\n",
"iv",
":=",... | //given a blob of text to encode, returns a hex-encoded string with
//the provided block cipher's ouptut. note that a random initialization
//vector is used and placed at the front of the cleartext. this iv
//does not need to be secure, but does need to be random. | [
"given",
"a",
"blob",
"of",
"text",
"to",
"encode",
"returns",
"a",
"hex",
"-",
"encoded",
"string",
"with",
"the",
"provided",
"block",
"cipher",
"s",
"ouptut",
".",
"note",
"that",
"a",
"random",
"initialization",
"vector",
"is",
"used",
"and",
"placed",... | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/session.go#L364-L375 |
154,552 | seven5/seven5 | session.go | decryptSessionId | func decryptSessionId(encryptedHex string, block cipher.Block) (string, bool) {
ciphertext := make([]byte, len(encryptedHex)/2)
l, err := hex.Decode(ciphertext, []byte(encryptedHex))
if err != nil {
log.Printf("unable to decode the hex bytes of session id (%s,%d): %v", encryptedHex, len(encryptedHex), err)
return "", false
}
iv := ciphertext[:aes.BlockSize]
stream := cipher.NewCTR(block, iv)
cleartext := make([]byte, l-len(iv))
stream.XORKeyStream(cleartext, ciphertext[aes.BlockSize:])
s := string(cleartext)
if !strings.HasPrefix(s, s5CookiePrefix) {
log.Printf("No cookie prefix found, probably keys changed")
return "", false
}
s = strings.TrimPrefix(s, s5CookiePrefix+":")
parts := strings.Split(s, ",")
if len(parts) != 2 {
log.Printf("Failed to understand parts of session id: %s", s)
return "", false
}
t, err := strconv.ParseInt(parts[1], 10, 64)
if err != nil {
log.Printf("Could not understand expiration time in session id: %s", s)
return "", false
}
expires := time.Unix(t, 0)
if expires.Before(time.Now()) {
return "", false
}
return parts[0], true
} | go | func decryptSessionId(encryptedHex string, block cipher.Block) (string, bool) {
ciphertext := make([]byte, len(encryptedHex)/2)
l, err := hex.Decode(ciphertext, []byte(encryptedHex))
if err != nil {
log.Printf("unable to decode the hex bytes of session id (%s,%d): %v", encryptedHex, len(encryptedHex), err)
return "", false
}
iv := ciphertext[:aes.BlockSize]
stream := cipher.NewCTR(block, iv)
cleartext := make([]byte, l-len(iv))
stream.XORKeyStream(cleartext, ciphertext[aes.BlockSize:])
s := string(cleartext)
if !strings.HasPrefix(s, s5CookiePrefix) {
log.Printf("No cookie prefix found, probably keys changed")
return "", false
}
s = strings.TrimPrefix(s, s5CookiePrefix+":")
parts := strings.Split(s, ",")
if len(parts) != 2 {
log.Printf("Failed to understand parts of session id: %s", s)
return "", false
}
t, err := strconv.ParseInt(parts[1], 10, 64)
if err != nil {
log.Printf("Could not understand expiration time in session id: %s", s)
return "", false
}
expires := time.Unix(t, 0)
if expires.Before(time.Now()) {
return "", false
}
return parts[0], true
} | [
"func",
"decryptSessionId",
"(",
"encryptedHex",
"string",
",",
"block",
"cipher",
".",
"Block",
")",
"(",
"string",
",",
"bool",
")",
"{",
"ciphertext",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"len",
"(",
"encryptedHex",
")",
"/",
"2",
")",
"\n",
... | //given a blob of text to decode, checks a few things and returns either
//the originally given unique id and true or "" and false. | [
"given",
"a",
"blob",
"of",
"text",
"to",
"decode",
"checks",
"a",
"few",
"things",
"and",
"returns",
"either",
"the",
"originally",
"given",
"unique",
"id",
"and",
"true",
"or",
"and",
"false",
"."
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/session.go#L379-L412 |
154,553 | seven5/seven5 | session.go | Generate | func (self *SimpleSessionManager) Generate(uniq string) (interface{}, error) {
if self.generator == nil {
return nil, nil
}
return self.generator.Generate(uniq)
} | go | func (self *SimpleSessionManager) Generate(uniq string) (interface{}, error) {
if self.generator == nil {
return nil, nil
}
return self.generator.Generate(uniq)
} | [
"func",
"(",
"self",
"*",
"SimpleSessionManager",
")",
"Generate",
"(",
"uniq",
"string",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"if",
"self",
".",
"generator",
"==",
"nil",
"{",
"return",
"nil",
",",
"nil",
"\n",
"}",
"\n",
"return... | //
// Generate returns nil,nil if no Generator was provided at the time of this
// object's creation. If a Generator was provided is it invoked to create
// the user data from this session.
// | [
"Generate",
"returns",
"nil",
"nil",
"if",
"no",
"Generator",
"was",
"provided",
"at",
"the",
"time",
"of",
"this",
"object",
"s",
"creation",
".",
"If",
"a",
"Generator",
"was",
"provided",
"is",
"it",
"invoked",
"to",
"create",
"the",
"user",
"data",
"... | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/session.go#L419-L424 |
154,554 | salsaflow/salsaflow | git/branches.go | IsUpToDate | func (branch *GitBranch) IsUpToDate() (bool, error) {
var (
localRef = branch.LocalRef()
remoteRef = branch.RemoteRef()
)
// Return true in case this is a purely local or remote branch.
if len(localRef) == 0 || len(remoteRef) == 0 {
return true, nil
}
// Compare the hashes the branches are pointing to.
localHexsha, err := Hexsha(branch.LocalRef())
if err != nil {
return false, err
}
remoteHexsha, err := Hexsha(branch.RemoteRef())
if err != nil {
return false, err
}
return localHexsha == remoteHexsha, nil
} | go | func (branch *GitBranch) IsUpToDate() (bool, error) {
var (
localRef = branch.LocalRef()
remoteRef = branch.RemoteRef()
)
// Return true in case this is a purely local or remote branch.
if len(localRef) == 0 || len(remoteRef) == 0 {
return true, nil
}
// Compare the hashes the branches are pointing to.
localHexsha, err := Hexsha(branch.LocalRef())
if err != nil {
return false, err
}
remoteHexsha, err := Hexsha(branch.RemoteRef())
if err != nil {
return false, err
}
return localHexsha == remoteHexsha, nil
} | [
"func",
"(",
"branch",
"*",
"GitBranch",
")",
"IsUpToDate",
"(",
")",
"(",
"bool",
",",
"error",
")",
"{",
"var",
"(",
"localRef",
"=",
"branch",
".",
"LocalRef",
"(",
")",
"\n",
"remoteRef",
"=",
"branch",
".",
"RemoteRef",
"(",
")",
"\n",
")",
"\... | // IsUpToDate returns true when the local and remote references
// point to the same commit. | [
"IsUpToDate",
"returns",
"true",
"when",
"the",
"local",
"and",
"remote",
"references",
"point",
"to",
"the",
"same",
"commit",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/git/branches.go#L62-L83 |
154,555 | seven5/seven5 | pbundle.go | ReturnHeaders | func (self *simplePBundle) ReturnHeaders() []string {
result := []string{}
for k, _ := range self.out {
result = append(result, k)
}
return result
} | go | func (self *simplePBundle) ReturnHeaders() []string {
result := []string{}
for k, _ := range self.out {
result = append(result, k)
}
return result
} | [
"func",
"(",
"self",
"*",
"simplePBundle",
")",
"ReturnHeaders",
"(",
")",
"[",
"]",
"string",
"{",
"result",
":=",
"[",
"]",
"string",
"{",
"}",
"\n",
"for",
"k",
",",
"_",
":=",
"range",
"self",
".",
"out",
"{",
"result",
"=",
"append",
"(",
"r... | //ReturnHeaders gets all the header _keys_ that should be returned the client. | [
"ReturnHeaders",
"gets",
"all",
"the",
"header",
"_keys_",
"that",
"should",
"be",
"returned",
"the",
"client",
"."
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/pbundle.go#L34-L40 |
154,556 | seven5/seven5 | pbundle.go | SetReturnHeader | func (self *simplePBundle) SetReturnHeader(k string, v string) {
self.out[k] = v
} | go | func (self *simplePBundle) SetReturnHeader(k string, v string) {
self.out[k] = v
} | [
"func",
"(",
"self",
"*",
"simplePBundle",
")",
"SetReturnHeader",
"(",
"k",
"string",
",",
"v",
"string",
")",
"{",
"self",
".",
"out",
"[",
"k",
"]",
"=",
"v",
"\n",
"}"
] | //SetReturnHeader associates the value v with the header k in the result returned
//to the client. This method does not allow setting multiple values for a single
//key because that's silly. | [
"SetReturnHeader",
"associates",
"the",
"value",
"v",
"with",
"the",
"header",
"k",
"in",
"the",
"result",
"returned",
"to",
"the",
"client",
".",
"This",
"method",
"does",
"not",
"allow",
"setting",
"multiple",
"values",
"for",
"a",
"single",
"key",
"becaus... | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/pbundle.go#L45-L47 |
154,557 | seven5/seven5 | pbundle.go | Header | func (self *simplePBundle) Header(s string) (string, bool) {
v, ok := self.h[strings.ToLower(s)]
return v, ok
} | go | func (self *simplePBundle) Header(s string) (string, bool) {
v, ok := self.h[strings.ToLower(s)]
return v, ok
} | [
"func",
"(",
"self",
"*",
"simplePBundle",
")",
"Header",
"(",
"s",
"string",
")",
"(",
"string",
",",
"bool",
")",
"{",
"v",
",",
"ok",
":=",
"self",
".",
"h",
"[",
"strings",
".",
"ToLower",
"(",
"s",
")",
"]",
"\n",
"return",
"v",
",",
"ok",... | //Header returns the header sent from the client named s. If there is no such
//header, false will be returned in the second argument. | [
"Header",
"returns",
"the",
"header",
"sent",
"from",
"the",
"client",
"named",
"s",
".",
"If",
"there",
"is",
"no",
"such",
"header",
"false",
"will",
"be",
"returned",
"in",
"the",
"second",
"argument",
"."
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/pbundle.go#L58-L61 |
154,558 | seven5/seven5 | pbundle.go | DestroySession | func (self *simplePBundle) DestroySession() error {
if self.Session() == nil {
return nil
}
return self.mgr.Destroy(self.s.SessionId())
} | go | func (self *simplePBundle) DestroySession() error {
if self.Session() == nil {
return nil
}
return self.mgr.Destroy(self.s.SessionId())
} | [
"func",
"(",
"self",
"*",
"simplePBundle",
")",
"DestroySession",
"(",
")",
"error",
"{",
"if",
"self",
".",
"Session",
"(",
")",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"self",
".",
"mgr",
".",
"Destroy",
"(",
"self",
".",
"s... | //DestroySession removes the session associated with this Pbundle from the
//associated SessionManager. Note that this wil blow up if you have either
//no session manager but is ignored if there is no session. | [
"DestroySession",
"removes",
"the",
"session",
"associated",
"with",
"this",
"Pbundle",
"from",
"the",
"associated",
"SessionManager",
".",
"Note",
"that",
"this",
"wil",
"blow",
"up",
"if",
"you",
"have",
"either",
"no",
"session",
"manager",
"but",
"is",
"ig... | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/pbundle.go#L82-L87 |
154,559 | seven5/seven5 | pbundle.go | SetParentValue | func (self *simplePBundle) SetParentValue(t reflect.Type, value interface{}) {
self.parent[t] = value
} | go | func (self *simplePBundle) SetParentValue(t reflect.Type, value interface{}) {
self.parent[t] = value
} | [
"func",
"(",
"self",
"*",
"simplePBundle",
")",
"SetParentValue",
"(",
"t",
"reflect",
".",
"Type",
",",
"value",
"interface",
"{",
"}",
")",
"{",
"self",
".",
"parent",
"[",
"t",
"]",
"=",
"value",
"\n",
"}"
] | //SetParentValue associates a particular parent value with the given wire type.
//Clients typically don't need this method, because it is called via the dispatch
//mechanism as the URL is being processed. Because it's primarily for internal
//use, the call takes the _type_ of the client wire type, not an example of it. | [
"SetParentValue",
"associates",
"a",
"particular",
"parent",
"value",
"with",
"the",
"given",
"wire",
"type",
".",
"Clients",
"typically",
"don",
"t",
"need",
"this",
"method",
"because",
"it",
"is",
"called",
"via",
"the",
"dispatch",
"mechanism",
"as",
"the"... | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/pbundle.go#L102-L104 |
154,560 | seven5/seven5 | pbundle.go | IntQueryParameter | func (self *simplePBundle) IntQueryParameter(name string, def int64) int64 {
raw, ok := self.Query(name)
if !ok {
return def
}
i, err := strconv.ParseInt(raw, 10, 64)
if err != nil {
return def
}
return i
} | go | func (self *simplePBundle) IntQueryParameter(name string, def int64) int64 {
raw, ok := self.Query(name)
if !ok {
return def
}
i, err := strconv.ParseInt(raw, 10, 64)
if err != nil {
return def
}
return i
} | [
"func",
"(",
"self",
"*",
"simplePBundle",
")",
"IntQueryParameter",
"(",
"name",
"string",
",",
"def",
"int64",
")",
"int64",
"{",
"raw",
",",
"ok",
":=",
"self",
".",
"Query",
"(",
"name",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"def",
"\n",
"... | //IntQueryParameter returns the value of the query parameter name with a
//default value of def. The default value is used if either the parameter
//is not present, or cannot be parsed as an int. | [
"IntQueryParameter",
"returns",
"the",
"value",
"of",
"the",
"query",
"parameter",
"name",
"with",
"a",
"default",
"value",
"of",
"def",
".",
"The",
"default",
"value",
"is",
"used",
"if",
"either",
"the",
"parameter",
"is",
"not",
"present",
"or",
"cannot",... | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/pbundle.go#L109-L119 |
154,561 | seven5/seven5 | pbundle.go | NewSimplePBundle | func NewSimplePBundle(r *http.Request, s Session, mgr SessionManager) (PBundle, error) {
if err := r.ParseForm(); err != nil {
return nil, err
}
return &simplePBundle{
h: ToSimpleMap(r.Header),
q: ToSimpleMap(map[string][]string(r.Form)),
s: s,
mgr: mgr,
out: make(map[string]string),
parent: make(map[reflect.Type]interface{}),
}, nil
} | go | func NewSimplePBundle(r *http.Request, s Session, mgr SessionManager) (PBundle, error) {
if err := r.ParseForm(); err != nil {
return nil, err
}
return &simplePBundle{
h: ToSimpleMap(r.Header),
q: ToSimpleMap(map[string][]string(r.Form)),
s: s,
mgr: mgr,
out: make(map[string]string),
parent: make(map[reflect.Type]interface{}),
}, nil
} | [
"func",
"NewSimplePBundle",
"(",
"r",
"*",
"http",
".",
"Request",
",",
"s",
"Session",
",",
"mgr",
"SessionManager",
")",
"(",
"PBundle",
",",
"error",
")",
"{",
"if",
"err",
":=",
"r",
".",
"ParseForm",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"re... | //NewSimplePBundle needs to hold a reference to the session manager as well
//as the session because it must be able to update the information stored
//about a particular sesison. | [
"NewSimplePBundle",
"needs",
"to",
"hold",
"a",
"reference",
"to",
"the",
"session",
"manager",
"as",
"well",
"as",
"the",
"session",
"because",
"it",
"must",
"be",
"able",
"to",
"update",
"the",
"information",
"stored",
"about",
"a",
"particular",
"sesison",
... | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/pbundle.go#L124-L137 |
154,562 | jrick/bitset | bitset.go | Get | func (p Pointers) Get(i int) bool {
return p[uint(i)>>ptrShift]&(1<<(uint(i)&ptrModMask)) != 0
} | go | func (p Pointers) Get(i int) bool {
return p[uint(i)>>ptrShift]&(1<<(uint(i)&ptrModMask)) != 0
} | [
"func",
"(",
"p",
"Pointers",
")",
"Get",
"(",
"i",
"int",
")",
"bool",
"{",
"return",
"p",
"[",
"uint",
"(",
"i",
")",
">>",
"ptrShift",
"]",
"&",
"(",
"1",
"<<",
"(",
"uint",
"(",
"i",
")",
"&",
"ptrModMask",
")",
")",
"!=",
"0",
"\n",
"}... | // Get returns whether the bit at index i is set or not. This method will
// panic if the index results in a pointer index that exceeds the number of
// pointers held by the bitset. | [
"Get",
"returns",
"whether",
"the",
"bit",
"at",
"index",
"i",
"is",
"set",
"or",
"not",
".",
"This",
"method",
"will",
"panic",
"if",
"the",
"index",
"results",
"in",
"a",
"pointer",
"index",
"that",
"exceeds",
"the",
"number",
"of",
"pointers",
"held",... | 06eae37cdf93c699c0503c23f998167ce841974c | https://github.com/jrick/bitset/blob/06eae37cdf93c699c0503c23f998167ce841974c/bitset.go#L88-L90 |
154,563 | jrick/bitset | bitset.go | Set | func (p Pointers) Set(i int) {
p[uint(i)>>ptrShift] |= 1 << (uint(i) & ptrModMask)
} | go | func (p Pointers) Set(i int) {
p[uint(i)>>ptrShift] |= 1 << (uint(i) & ptrModMask)
} | [
"func",
"(",
"p",
"Pointers",
")",
"Set",
"(",
"i",
"int",
")",
"{",
"p",
"[",
"uint",
"(",
"i",
")",
">>",
"ptrShift",
"]",
"|=",
"1",
"<<",
"(",
"uint",
"(",
"i",
")",
"&",
"ptrModMask",
")",
"\n",
"}"
] | // Set sets the bit at index i. This method will panic if the index results
// in a pointer index that exceeds the number of pointers held by the bitset. | [
"Set",
"sets",
"the",
"bit",
"at",
"index",
"i",
".",
"This",
"method",
"will",
"panic",
"if",
"the",
"index",
"results",
"in",
"a",
"pointer",
"index",
"that",
"exceeds",
"the",
"number",
"of",
"pointers",
"held",
"by",
"the",
"bitset",
"."
] | 06eae37cdf93c699c0503c23f998167ce841974c | https://github.com/jrick/bitset/blob/06eae37cdf93c699c0503c23f998167ce841974c/bitset.go#L94-L96 |
154,564 | jrick/bitset | bitset.go | Unset | func (p Pointers) Unset(i int) {
p[uint(i)>>ptrShift] &^= 1 << (uint(i) & ptrModMask)
} | go | func (p Pointers) Unset(i int) {
p[uint(i)>>ptrShift] &^= 1 << (uint(i) & ptrModMask)
} | [
"func",
"(",
"p",
"Pointers",
")",
"Unset",
"(",
"i",
"int",
")",
"{",
"p",
"[",
"uint",
"(",
"i",
")",
">>",
"ptrShift",
"]",
"&^=",
"1",
"<<",
"(",
"uint",
"(",
"i",
")",
"&",
"ptrModMask",
")",
"\n",
"}"
] | // Unset unsets the bit at index i. This method will panic if the index
// results in a pointer index that exceeds the number of pointers held by the
// bitset. | [
"Unset",
"unsets",
"the",
"bit",
"at",
"index",
"i",
".",
"This",
"method",
"will",
"panic",
"if",
"the",
"index",
"results",
"in",
"a",
"pointer",
"index",
"that",
"exceeds",
"the",
"number",
"of",
"pointers",
"held",
"by",
"the",
"bitset",
"."
] | 06eae37cdf93c699c0503c23f998167ce841974c | https://github.com/jrick/bitset/blob/06eae37cdf93c699c0503c23f998167ce841974c/bitset.go#L101-L103 |
154,565 | jrick/bitset | bitset.go | SetBool | func (p Pointers) SetBool(i int, b bool) {
if b {
p.Set(i)
return
}
p.Unset(i)
} | go | func (p Pointers) SetBool(i int, b bool) {
if b {
p.Set(i)
return
}
p.Unset(i)
} | [
"func",
"(",
"p",
"Pointers",
")",
"SetBool",
"(",
"i",
"int",
",",
"b",
"bool",
")",
"{",
"if",
"b",
"{",
"p",
".",
"Set",
"(",
"i",
")",
"\n",
"return",
"\n",
"}",
"\n",
"p",
".",
"Unset",
"(",
"i",
")",
"\n",
"}"
] | // SetBool sets or unsets the bit at index i depending on the value of b.
// This method will panic if the index results in a pointer index that exceeds
// the number of pointers held by the bitset. | [
"SetBool",
"sets",
"or",
"unsets",
"the",
"bit",
"at",
"index",
"i",
"depending",
"on",
"the",
"value",
"of",
"b",
".",
"This",
"method",
"will",
"panic",
"if",
"the",
"index",
"results",
"in",
"a",
"pointer",
"index",
"that",
"exceeds",
"the",
"number",... | 06eae37cdf93c699c0503c23f998167ce841974c | https://github.com/jrick/bitset/blob/06eae37cdf93c699c0503c23f998167ce841974c/bitset.go#L108-L114 |
154,566 | jrick/bitset | bitset.go | Get | func (s Bytes) Get(i int) bool {
return s[uint(i)>>byteShift]&(1<<(uint(i)&byteModMask)) != 0
} | go | func (s Bytes) Get(i int) bool {
return s[uint(i)>>byteShift]&(1<<(uint(i)&byteModMask)) != 0
} | [
"func",
"(",
"s",
"Bytes",
")",
"Get",
"(",
"i",
"int",
")",
"bool",
"{",
"return",
"s",
"[",
"uint",
"(",
"i",
")",
">>",
"byteShift",
"]",
"&",
"(",
"1",
"<<",
"(",
"uint",
"(",
"i",
")",
"&",
"byteModMask",
")",
")",
"!=",
"0",
"\n",
"}"... | // Get returns whether the bit at index i is set or not. This method will
// panic if the index results in a byte index that exceeds the number of
// bytes held by the bitset. | [
"Get",
"returns",
"whether",
"the",
"bit",
"at",
"index",
"i",
"is",
"set",
"or",
"not",
".",
"This",
"method",
"will",
"panic",
"if",
"the",
"index",
"results",
"in",
"a",
"byte",
"index",
"that",
"exceeds",
"the",
"number",
"of",
"bytes",
"held",
"by... | 06eae37cdf93c699c0503c23f998167ce841974c | https://github.com/jrick/bitset/blob/06eae37cdf93c699c0503c23f998167ce841974c/bitset.go#L151-L153 |
154,567 | jrick/bitset | bitset.go | Set | func (s Bytes) Set(i int) {
s[uint(i)>>byteShift] |= 1 << (uint(i) & byteModMask)
} | go | func (s Bytes) Set(i int) {
s[uint(i)>>byteShift] |= 1 << (uint(i) & byteModMask)
} | [
"func",
"(",
"s",
"Bytes",
")",
"Set",
"(",
"i",
"int",
")",
"{",
"s",
"[",
"uint",
"(",
"i",
")",
">>",
"byteShift",
"]",
"|=",
"1",
"<<",
"(",
"uint",
"(",
"i",
")",
"&",
"byteModMask",
")",
"\n",
"}"
] | // Set sets the bit at index i. This method will panic if the index results
// in a byte index that exceeds the number of a bytes held by the bitset. | [
"Set",
"sets",
"the",
"bit",
"at",
"index",
"i",
".",
"This",
"method",
"will",
"panic",
"if",
"the",
"index",
"results",
"in",
"a",
"byte",
"index",
"that",
"exceeds",
"the",
"number",
"of",
"a",
"bytes",
"held",
"by",
"the",
"bitset",
"."
] | 06eae37cdf93c699c0503c23f998167ce841974c | https://github.com/jrick/bitset/blob/06eae37cdf93c699c0503c23f998167ce841974c/bitset.go#L157-L159 |
154,568 | jrick/bitset | bitset.go | Unset | func (s Bytes) Unset(i int) {
s[uint(i)>>byteShift] &^= 1 << (uint(i) & byteModMask)
} | go | func (s Bytes) Unset(i int) {
s[uint(i)>>byteShift] &^= 1 << (uint(i) & byteModMask)
} | [
"func",
"(",
"s",
"Bytes",
")",
"Unset",
"(",
"i",
"int",
")",
"{",
"s",
"[",
"uint",
"(",
"i",
")",
">>",
"byteShift",
"]",
"&^=",
"1",
"<<",
"(",
"uint",
"(",
"i",
")",
"&",
"byteModMask",
")",
"\n",
"}"
] | // Unset unsets the bit at index i. This method will panc if the index
// results in a byte index that exceeds the number of bytes held by the
// bitset. | [
"Unset",
"unsets",
"the",
"bit",
"at",
"index",
"i",
".",
"This",
"method",
"will",
"panc",
"if",
"the",
"index",
"results",
"in",
"a",
"byte",
"index",
"that",
"exceeds",
"the",
"number",
"of",
"bytes",
"held",
"by",
"the",
"bitset",
"."
] | 06eae37cdf93c699c0503c23f998167ce841974c | https://github.com/jrick/bitset/blob/06eae37cdf93c699c0503c23f998167ce841974c/bitset.go#L164-L166 |
154,569 | jrick/bitset | bitset.go | Get | func (s Sparse) Get(i int) bool {
return s[int(uint(i)>>ptrShift)]&(1<<(uint(i)&ptrModMask)) != 0
} | go | func (s Sparse) Get(i int) bool {
return s[int(uint(i)>>ptrShift)]&(1<<(uint(i)&ptrModMask)) != 0
} | [
"func",
"(",
"s",
"Sparse",
")",
"Get",
"(",
"i",
"int",
")",
"bool",
"{",
"return",
"s",
"[",
"int",
"(",
"uint",
"(",
"i",
")",
">>",
"ptrShift",
")",
"]",
"&",
"(",
"1",
"<<",
"(",
"uint",
"(",
"i",
")",
"&",
"ptrModMask",
")",
")",
"!="... | // Get returns whether the bit at index i is set or not. | [
"Get",
"returns",
"whether",
"the",
"bit",
"at",
"index",
"i",
"is",
"set",
"or",
"not",
"."
] | 06eae37cdf93c699c0503c23f998167ce841974c | https://github.com/jrick/bitset/blob/06eae37cdf93c699c0503c23f998167ce841974c/bitset.go#L213-L215 |
154,570 | jrick/bitset | bitset.go | Set | func (s Sparse) Set(i int) {
s[int(uint(i)>>ptrShift)] |= 1 << (uint(i) & ptrModMask)
} | go | func (s Sparse) Set(i int) {
s[int(uint(i)>>ptrShift)] |= 1 << (uint(i) & ptrModMask)
} | [
"func",
"(",
"s",
"Sparse",
")",
"Set",
"(",
"i",
"int",
")",
"{",
"s",
"[",
"int",
"(",
"uint",
"(",
"i",
")",
">>",
"ptrShift",
")",
"]",
"|=",
"1",
"<<",
"(",
"uint",
"(",
"i",
")",
"&",
"ptrModMask",
")",
"\n",
"}"
] | // Set sets the bit at index i. A map insert is performed if if no bits
// of the associated pointer have been previously set. | [
"Set",
"sets",
"the",
"bit",
"at",
"index",
"i",
".",
"A",
"map",
"insert",
"is",
"performed",
"if",
"if",
"no",
"bits",
"of",
"the",
"associated",
"pointer",
"have",
"been",
"previously",
"set",
"."
] | 06eae37cdf93c699c0503c23f998167ce841974c | https://github.com/jrick/bitset/blob/06eae37cdf93c699c0503c23f998167ce841974c/bitset.go#L219-L221 |
154,571 | jrick/bitset | bitset.go | Unset | func (s Sparse) Unset(i int) {
ptrKey := int(uint(i) >> ptrShift)
ptr, ok := s[ptrKey]
if !ok {
return
}
ptr &^= 1 << (uint(i) & ptrModMask)
if ptr == 0 {
delete(s, ptrKey)
} else {
s[ptrKey] = ptr
}
} | go | func (s Sparse) Unset(i int) {
ptrKey := int(uint(i) >> ptrShift)
ptr, ok := s[ptrKey]
if !ok {
return
}
ptr &^= 1 << (uint(i) & ptrModMask)
if ptr == 0 {
delete(s, ptrKey)
} else {
s[ptrKey] = ptr
}
} | [
"func",
"(",
"s",
"Sparse",
")",
"Unset",
"(",
"i",
"int",
")",
"{",
"ptrKey",
":=",
"int",
"(",
"uint",
"(",
"i",
")",
">>",
"ptrShift",
")",
"\n",
"ptr",
",",
"ok",
":=",
"s",
"[",
"ptrKey",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"\n",
... | // Unset unsets the bit at index i. If all bits for a given pointer have are
// unset, the pointer is removed from the map, and future calls to Get will
// return false for all bits from this pointer. | [
"Unset",
"unsets",
"the",
"bit",
"at",
"index",
"i",
".",
"If",
"all",
"bits",
"for",
"a",
"given",
"pointer",
"have",
"are",
"unset",
"the",
"pointer",
"is",
"removed",
"from",
"the",
"map",
"and",
"future",
"calls",
"to",
"Get",
"will",
"return",
"fa... | 06eae37cdf93c699c0503c23f998167ce841974c | https://github.com/jrick/bitset/blob/06eae37cdf93c699c0503c23f998167ce841974c/bitset.go#L226-L238 |
154,572 | jrick/bitset | bitset.go | SetBool | func (s Sparse) SetBool(i int, b bool) {
if b {
s.Set(i)
return
}
s.Unset(i)
} | go | func (s Sparse) SetBool(i int, b bool) {
if b {
s.Set(i)
return
}
s.Unset(i)
} | [
"func",
"(",
"s",
"Sparse",
")",
"SetBool",
"(",
"i",
"int",
",",
"b",
"bool",
")",
"{",
"if",
"b",
"{",
"s",
".",
"Set",
"(",
"i",
")",
"\n",
"return",
"\n",
"}",
"\n",
"s",
".",
"Unset",
"(",
"i",
")",
"\n",
"}"
] | // SetBool sets the bit at index i if b is true, otherwise the bit is unset.
// see the comments for the get and set methods for the memory allocation
// rules that are followed when getting or setting bits in a Sparse bitset. | [
"SetBool",
"sets",
"the",
"bit",
"at",
"index",
"i",
"if",
"b",
"is",
"true",
"otherwise",
"the",
"bit",
"is",
"unset",
".",
"see",
"the",
"comments",
"for",
"the",
"get",
"and",
"set",
"methods",
"for",
"the",
"memory",
"allocation",
"rules",
"that",
... | 06eae37cdf93c699c0503c23f998167ce841974c | https://github.com/jrick/bitset/blob/06eae37cdf93c699c0503c23f998167ce841974c/bitset.go#L243-L249 |
154,573 | timehop/gos2 | s2/cellid.go | AllNeighbors | func (ci CellID) AllNeighbors() [8]CellID {
level := ci.Level()
size := sizeIJ(level)
f, i, j, _ := ci.faceIJOrientation()
return [8]CellID{
cellIDFromFaceIJWrap(f, i, j-size).Parent(level),
cellIDFromFaceIJWrap(f, i+size, j-size).Parent(level),
cellIDFromFaceIJWrap(f, i+size, j).Parent(level),
cellIDFromFaceIJWrap(f, i+size, j+size).Parent(level),
cellIDFromFaceIJWrap(f, i, j+size).Parent(level),
cellIDFromFaceIJWrap(f, i-size, j+size).Parent(level),
cellIDFromFaceIJWrap(f, i-size, j).Parent(level),
cellIDFromFaceIJWrap(f, i-size, j-size).Parent(level),
}
} | go | func (ci CellID) AllNeighbors() [8]CellID {
level := ci.Level()
size := sizeIJ(level)
f, i, j, _ := ci.faceIJOrientation()
return [8]CellID{
cellIDFromFaceIJWrap(f, i, j-size).Parent(level),
cellIDFromFaceIJWrap(f, i+size, j-size).Parent(level),
cellIDFromFaceIJWrap(f, i+size, j).Parent(level),
cellIDFromFaceIJWrap(f, i+size, j+size).Parent(level),
cellIDFromFaceIJWrap(f, i, j+size).Parent(level),
cellIDFromFaceIJWrap(f, i-size, j+size).Parent(level),
cellIDFromFaceIJWrap(f, i-size, j).Parent(level),
cellIDFromFaceIJWrap(f, i-size, j-size).Parent(level),
}
} | [
"func",
"(",
"ci",
"CellID",
")",
"AllNeighbors",
"(",
")",
"[",
"8",
"]",
"CellID",
"{",
"level",
":=",
"ci",
".",
"Level",
"(",
")",
"\n",
"size",
":=",
"sizeIJ",
"(",
"level",
")",
"\n",
"f",
",",
"i",
",",
"j",
",",
"_",
":=",
"ci",
".",
... | // AllNeighbors returns the eights cells that are adjacent across and diagonal from
// the cell's four edges. Edges 0, 1, 2, 3, 4, 5, 6, 7 are in the down, down-right,
// right, right-up, up, up-left, left, down-left directions.
// All neighbors are guaranteed to be distinct. | [
"AllNeighbors",
"returns",
"the",
"eights",
"cells",
"that",
"are",
"adjacent",
"across",
"and",
"diagonal",
"from",
"the",
"cell",
"s",
"four",
"edges",
".",
"Edges",
"0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"are",
"in",
"the",
"down",
"down",
"-",
"... | 004cde1d85c2ef02a66c6c769d44b293d28879f5 | https://github.com/timehop/gos2/blob/004cde1d85c2ef02a66c6c769d44b293d28879f5/s2/cellid.go#L188-L202 |
154,574 | seven5/seven5 | client/narrowdom.go | Prepend | func (self jqueryWrapper) Prepend(childrennd ...NarrowDom) {
for i := len(childrennd) - 1; i >= 0; i-- {
nd := childrennd[i]
wrapper := nd.(jqueryWrapper)
self.jq.Prepend(wrapper.jq)
}
} | go | func (self jqueryWrapper) Prepend(childrennd ...NarrowDom) {
for i := len(childrennd) - 1; i >= 0; i-- {
nd := childrennd[i]
wrapper := nd.(jqueryWrapper)
self.jq.Prepend(wrapper.jq)
}
} | [
"func",
"(",
"self",
"jqueryWrapper",
")",
"Prepend",
"(",
"childrennd",
"...",
"NarrowDom",
")",
"{",
"for",
"i",
":=",
"len",
"(",
"childrennd",
")",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
"{",
"nd",
":=",
"childrennd",
"[",
"i",
"]",
"... | //we have to walk the children provided in reverse order so their order is
//preserved on repeated calls to prepend | [
"we",
"have",
"to",
"walk",
"the",
"children",
"provided",
"in",
"reverse",
"order",
"so",
"their",
"order",
"is",
"preserved",
"on",
"repeated",
"calls",
"to",
"prepend"
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/client/narrowdom.go#L317-L323 |
154,575 | salsaflow/salsaflow | github/upstream.go | ParseUpstreamURL | func ParseUpstreamURL() (owner, repo string, err error) {
// Load the Git config.
gitConfig, err := git.LoadConfig()
if err != nil {
return "", "", err
}
remoteName := gitConfig.RemoteName
// Get the upstream URL.
task := fmt.Sprintf("Get URL for git remote '%v'", remoteName)
remoteURL, err := git.GetConfigString(fmt.Sprintf("remote.%v.url", remoteName))
if err != nil {
return "", "", errs.NewError(task, err)
}
// Parse it and return the result.
return parseUpstreamURL(remoteURL)
} | go | func ParseUpstreamURL() (owner, repo string, err error) {
// Load the Git config.
gitConfig, err := git.LoadConfig()
if err != nil {
return "", "", err
}
remoteName := gitConfig.RemoteName
// Get the upstream URL.
task := fmt.Sprintf("Get URL for git remote '%v'", remoteName)
remoteURL, err := git.GetConfigString(fmt.Sprintf("remote.%v.url", remoteName))
if err != nil {
return "", "", errs.NewError(task, err)
}
// Parse it and return the result.
return parseUpstreamURL(remoteURL)
} | [
"func",
"ParseUpstreamURL",
"(",
")",
"(",
"owner",
",",
"repo",
"string",
",",
"err",
"error",
")",
"{",
"// Load the Git config.",
"gitConfig",
",",
"err",
":=",
"git",
".",
"LoadConfig",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
... | // ParseUpstreamURL parses the URL of the git upstream being used by SalsaFlow
// and returns the given GitHub owner and repository. | [
"ParseUpstreamURL",
"parses",
"the",
"URL",
"of",
"the",
"git",
"upstream",
"being",
"used",
"by",
"SalsaFlow",
"and",
"returns",
"the",
"given",
"GitHub",
"owner",
"and",
"repository",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/github/upstream.go#L17-L34 |
154,576 | seven5/seven5 | client/dom.go | verifyConstraint | func (self *domAttr) verifyConstraint(b bool) {
s := self.getData()
if b {
if s == "" {
panic(fmt.Sprintf("expected to have constraint on %s but did not!", self.id))
}
if s != CONSTRAINT_MARKER {
panic(fmt.Sprintf("expected to find constraint marker but found %s", s))
}
} else {
if s != "" {
panic(fmt.Sprintf("did not expect to have constraint on %s but found one: %s", self.id, s))
}
}
} | go | func (self *domAttr) verifyConstraint(b bool) {
s := self.getData()
if b {
if s == "" {
panic(fmt.Sprintf("expected to have constraint on %s but did not!", self.id))
}
if s != CONSTRAINT_MARKER {
panic(fmt.Sprintf("expected to find constraint marker but found %s", s))
}
} else {
if s != "" {
panic(fmt.Sprintf("did not expect to have constraint on %s but found one: %s", self.id, s))
}
}
} | [
"func",
"(",
"self",
"*",
"domAttr",
")",
"verifyConstraint",
"(",
"b",
"bool",
")",
"{",
"s",
":=",
"self",
".",
"getData",
"(",
")",
"\n",
"if",
"b",
"{",
"if",
"s",
"==",
"\"",
"\"",
"{",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",... | //verifyConstraint tests to see if there is already a constraint or not
//on this dom object. Pass false to verify that there is not a current
//constraint. | [
"verifyConstraint",
"tests",
"to",
"see",
"if",
"there",
"is",
"already",
"a",
"constraint",
"or",
"not",
"on",
"this",
"dom",
"object",
".",
"Pass",
"false",
"to",
"verify",
"that",
"there",
"is",
"not",
"a",
"current",
"constraint",
"."
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/client/dom.go#L65-L79 |
154,577 | salsaflow/salsaflow | git/commit_utils.go | ShowCommits | func ShowCommits(revisions ...string) ([]*Commit, error) {
args := make([]string, 5, 5+len(revisions))
args[0] = "show"
args[1] = "--source"
args[2] = "--abbrev-commit"
args[3] = "--pretty=fuller"
args[4] = "--no-patch"
args = append(args, revisions...)
stdout, err := Run(args...)
if err != nil {
return nil, err
}
return ParseCommits(stdout.Bytes())
} | go | func ShowCommits(revisions ...string) ([]*Commit, error) {
args := make([]string, 5, 5+len(revisions))
args[0] = "show"
args[1] = "--source"
args[2] = "--abbrev-commit"
args[3] = "--pretty=fuller"
args[4] = "--no-patch"
args = append(args, revisions...)
stdout, err := Run(args...)
if err != nil {
return nil, err
}
return ParseCommits(stdout.Bytes())
} | [
"func",
"ShowCommits",
"(",
"revisions",
"...",
"string",
")",
"(",
"[",
"]",
"*",
"Commit",
",",
"error",
")",
"{",
"args",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"5",
",",
"5",
"+",
"len",
"(",
"revisions",
")",
")",
"\n",
"args",
"[",
"... | // ShowCommits returns the commit objects specified by the given revisions.
//
// Revision ranges can be used as well, the revision list is simply passed
// to git show, so check the associated docs. | [
"ShowCommits",
"returns",
"the",
"commit",
"objects",
"specified",
"by",
"the",
"given",
"revisions",
".",
"Revision",
"ranges",
"can",
"be",
"used",
"as",
"well",
"the",
"revision",
"list",
"is",
"simply",
"passed",
"to",
"git",
"show",
"so",
"check",
"the"... | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/git/commit_utils.go#L31-L46 |
154,578 | salsaflow/salsaflow | git/commit_utils.go | ShowCommitRange | func ShowCommitRange(revisionRange string) ([]*Commit, error) {
args := []string{
"log",
"--source",
"--abbrev-commit",
"--pretty=fuller",
revisionRange,
}
stdout, err := Run(args...)
if err != nil {
return nil, err
}
return ParseCommits(stdout.Bytes())
} | go | func ShowCommitRange(revisionRange string) ([]*Commit, error) {
args := []string{
"log",
"--source",
"--abbrev-commit",
"--pretty=fuller",
revisionRange,
}
stdout, err := Run(args...)
if err != nil {
return nil, err
}
return ParseCommits(stdout.Bytes())
} | [
"func",
"ShowCommitRange",
"(",
"revisionRange",
"string",
")",
"(",
"[",
"]",
"*",
"Commit",
",",
"error",
")",
"{",
"args",
":=",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"revisionRange",
",",
... | // ShowCommitRange returns the list of commits specified by the given Git revision range. | [
"ShowCommitRange",
"returns",
"the",
"list",
"of",
"commits",
"specified",
"by",
"the",
"given",
"Git",
"revision",
"range",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/git/commit_utils.go#L49-L63 |
154,579 | salsaflow/salsaflow | git/commit_utils.go | FilterCommits | func FilterCommits(commits []*Commit, filterFunc CommitFilterFunc) []*Commit {
cs := make([]*Commit, 0, len(commits))
for _, commit := range commits {
if filterFunc(commit) {
cs = append(cs, commit)
}
}
return cs
} | go | func FilterCommits(commits []*Commit, filterFunc CommitFilterFunc) []*Commit {
cs := make([]*Commit, 0, len(commits))
for _, commit := range commits {
if filterFunc(commit) {
cs = append(cs, commit)
}
}
return cs
} | [
"func",
"FilterCommits",
"(",
"commits",
"[",
"]",
"*",
"Commit",
",",
"filterFunc",
"CommitFilterFunc",
")",
"[",
"]",
"*",
"Commit",
"{",
"cs",
":=",
"make",
"(",
"[",
"]",
"*",
"Commit",
",",
"0",
",",
"len",
"(",
"commits",
")",
")",
"\n",
"for... | // FilterCommits can be used to filter commits by the given filter function. | [
"FilterCommits",
"can",
"be",
"used",
"to",
"filter",
"commits",
"by",
"the",
"given",
"filter",
"function",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/git/commit_utils.go#L68-L76 |
154,580 | salsaflow/salsaflow | version/config.go | LoadConfig | func LoadConfig() (*Config, error) {
task := "Load versioning-related configuration"
spec := newConfigSpec()
if err := loader.LoadConfig(spec); err != nil {
return nil, errs.NewError(task, err)
}
return spec.local.parse()
} | go | func LoadConfig() (*Config, error) {
task := "Load versioning-related configuration"
spec := newConfigSpec()
if err := loader.LoadConfig(spec); err != nil {
return nil, errs.NewError(task, err)
}
return spec.local.parse()
} | [
"func",
"LoadConfig",
"(",
")",
"(",
"*",
"Config",
",",
"error",
")",
"{",
"task",
":=",
"\"",
"\"",
"\n",
"spec",
":=",
"newConfigSpec",
"(",
")",
"\n",
"if",
"err",
":=",
"loader",
".",
"LoadConfig",
"(",
"spec",
")",
";",
"err",
"!=",
"nil",
... | // LoadConfig can be used to load versioning-related configuration for SalsaFlow. | [
"LoadConfig",
"can",
"be",
"used",
"to",
"load",
"versioning",
"-",
"related",
"configuration",
"for",
"SalsaFlow",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/version/config.go#L32-L39 |
154,581 | itchio/httpkit | progress/format.go | FormatBytes | func FormatBytes(i int64) (result string) {
switch {
case i > (1024 * 1024 * 1024 * 1024):
result = fmt.Sprintf("%.02f TiB", float64(i)/1024/1024/1024/1024)
case i > (1024 * 1024 * 1024):
result = fmt.Sprintf("%.02f GiB", float64(i)/1024/1024/1024)
case i > (1024 * 1024):
result = fmt.Sprintf("%.02f MiB", float64(i)/1024/1024)
case i > 1024:
result = fmt.Sprintf("%.02f KiB", float64(i)/1024)
default:
result = fmt.Sprintf("%d B", i)
}
result = strings.Trim(result, " ")
return
} | go | func FormatBytes(i int64) (result string) {
switch {
case i > (1024 * 1024 * 1024 * 1024):
result = fmt.Sprintf("%.02f TiB", float64(i)/1024/1024/1024/1024)
case i > (1024 * 1024 * 1024):
result = fmt.Sprintf("%.02f GiB", float64(i)/1024/1024/1024)
case i > (1024 * 1024):
result = fmt.Sprintf("%.02f MiB", float64(i)/1024/1024)
case i > 1024:
result = fmt.Sprintf("%.02f KiB", float64(i)/1024)
default:
result = fmt.Sprintf("%d B", i)
}
result = strings.Trim(result, " ")
return
} | [
"func",
"FormatBytes",
"(",
"i",
"int64",
")",
"(",
"result",
"string",
")",
"{",
"switch",
"{",
"case",
"i",
">",
"(",
"1024",
"*",
"1024",
"*",
"1024",
"*",
"1024",
")",
":",
"result",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"float64"... | // Convert bytes to human readable string. Like a 2 MiB, 64.2 KiB, 52 B | [
"Convert",
"bytes",
"to",
"human",
"readable",
"string",
".",
"Like",
"a",
"2",
"MiB",
"64",
".",
"2",
"KiB",
"52",
"B"
] | f7051ef345456d077d49344cf6ec98b4059214f5 | https://github.com/itchio/httpkit/blob/f7051ef345456d077d49344cf6ec98b4059214f5/progress/format.go#L30-L45 |
154,582 | seven5/seven5 | client/string.go | Equal | func (self StringEqualer) Equal(e Equaler) bool {
return self.S == e.(StringEqualer).S
} | go | func (self StringEqualer) Equal(e Equaler) bool {
return self.S == e.(StringEqualer).S
} | [
"func",
"(",
"self",
"StringEqualer",
")",
"Equal",
"(",
"e",
"Equaler",
")",
"bool",
"{",
"return",
"self",
".",
"S",
"==",
"e",
".",
"(",
"StringEqualer",
")",
".",
"S",
"\n",
"}"
] | //Equal compares two values, must be StringEqualers, to see if they
//are the same. | [
"Equal",
"compares",
"two",
"values",
"must",
"be",
"StringEqualers",
"to",
"see",
"if",
"they",
"are",
"the",
"same",
"."
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/client/string.go#L28-L30 |
154,583 | seven5/seven5 | client/string.go | NewStringSimple | func NewStringSimple(s string) StringAttribute {
result := &StringSimple{
NewAttribute(NORMAL, nil, nil),
}
result.Set(s)
return result
} | go | func NewStringSimple(s string) StringAttribute {
result := &StringSimple{
NewAttribute(NORMAL, nil, nil),
}
result.Set(s)
return result
} | [
"func",
"NewStringSimple",
"(",
"s",
"string",
")",
"StringAttribute",
"{",
"result",
":=",
"&",
"StringSimple",
"{",
"NewAttribute",
"(",
"NORMAL",
",",
"nil",
",",
"nil",
")",
",",
"}",
"\n",
"result",
".",
"Set",
"(",
"s",
")",
"\n",
"return",
"resu... | //NewStringSimple creates a new StringAttribute with a simple
//int initial value. | [
"NewStringSimple",
"creates",
"a",
"new",
"StringAttribute",
"with",
"a",
"simple",
"int",
"initial",
"value",
"."
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/client/string.go#L47-L53 |
154,584 | seven5/seven5 | static_files.go | GopathSearch | func GopathSearch(desired string) string {
gopathSegments := strings.Split(os.Getenv("GOPATH"), ":")
for _, gopath := range gopathSegments {
_, err := os.Stat(filepath.Join(gopath, "src", desired))
if err != nil {
continue
}
return filepath.Join(gopath, "src", desired)
}
return ""
} | go | func GopathSearch(desired string) string {
gopathSegments := strings.Split(os.Getenv("GOPATH"), ":")
for _, gopath := range gopathSegments {
_, err := os.Stat(filepath.Join(gopath, "src", desired))
if err != nil {
continue
}
return filepath.Join(gopath, "src", desired)
}
return ""
} | [
"func",
"GopathSearch",
"(",
"desired",
"string",
")",
"string",
"{",
"gopathSegments",
":=",
"strings",
".",
"Split",
"(",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
",",
"\"",
"\"",
")",
"\n",
"for",
"_",
",",
"gopath",
":=",
"range",
"gopathSegments... | //Return the path to the file that has the desired content, or return "" if
//the file cannot be found. | [
"Return",
"the",
"path",
"to",
"the",
"file",
"that",
"has",
"the",
"desired",
"content",
"or",
"return",
"if",
"the",
"file",
"cannot",
"be",
"found",
"."
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/static_files.go#L76-L86 |
154,585 | GeoNet/map180 | bbox.go | newBbox | func newBbox(boundingBox string) (b bbox, err error) {
// If it's a named bbox return that
b, ok := namedMapBounds[boundingBox]
if ok {
return
}
s := strings.Split(boundingBox, ",")
b.llx, err = strconv.ParseFloat(s[0], 64)
if err != nil {
err = fmt.Errorf("Invalid boundingBox: %s", boundingBox)
return
}
b.lly, err = strconv.ParseFloat(s[1], 64)
if err != nil {
err = fmt.Errorf("Invalid boundingBox: %s", boundingBox)
return
}
b.urx, err = strconv.ParseFloat(s[2], 64)
if err != nil {
err = fmt.Errorf("Invalid boundingBox: %s", boundingBox)
return
}
b.ury, err = strconv.ParseFloat(s[3], 64)
if err != nil {
err = fmt.Errorf("Invalid boundingBox: %s", boundingBox)
return
}
if b.lly < -85.0 {
err = fmt.Errorf("bbox out of bounds %s", boundingBox)
return
}
if b.ury > 85.0 {
err = fmt.Errorf("bbox out of bounds %s", boundingBox)
return
}
b.setCrosses180()
err = b.setRegion()
return
} | go | func newBbox(boundingBox string) (b bbox, err error) {
// If it's a named bbox return that
b, ok := namedMapBounds[boundingBox]
if ok {
return
}
s := strings.Split(boundingBox, ",")
b.llx, err = strconv.ParseFloat(s[0], 64)
if err != nil {
err = fmt.Errorf("Invalid boundingBox: %s", boundingBox)
return
}
b.lly, err = strconv.ParseFloat(s[1], 64)
if err != nil {
err = fmt.Errorf("Invalid boundingBox: %s", boundingBox)
return
}
b.urx, err = strconv.ParseFloat(s[2], 64)
if err != nil {
err = fmt.Errorf("Invalid boundingBox: %s", boundingBox)
return
}
b.ury, err = strconv.ParseFloat(s[3], 64)
if err != nil {
err = fmt.Errorf("Invalid boundingBox: %s", boundingBox)
return
}
if b.lly < -85.0 {
err = fmt.Errorf("bbox out of bounds %s", boundingBox)
return
}
if b.ury > 85.0 {
err = fmt.Errorf("bbox out of bounds %s", boundingBox)
return
}
b.setCrosses180()
err = b.setRegion()
return
} | [
"func",
"newBbox",
"(",
"boundingBox",
"string",
")",
"(",
"b",
"bbox",
",",
"err",
"error",
")",
"{",
"// If it's a named bbox return that",
"b",
",",
"ok",
":=",
"namedMapBounds",
"[",
"boundingBox",
"]",
"\n",
"if",
"ok",
"{",
"return",
"\n",
"}",
"\n\n... | // parses boundingBox and returns a bbox | [
"parses",
"boundingBox",
"and",
"returns",
"a",
"bbox"
] | 9dfd58c339375915a35c96438b0db973c4ece9d4 | https://github.com/GeoNet/map180/blob/9dfd58c339375915a35c96438b0db973c4ece9d4/bbox.go#L57-L105 |
154,586 | GeoNet/map180 | bbox.go | newBboxFromMarkers | func newBboxFromMarkers(m []Marker) (bbox, error) {
var geom string
switch len(m) {
case 0:
return bbox{}, fmt.Errorf("zero length markers, can't determine map bounds")
case 1:
geom = fmt.Sprintf("POINT(%f %f)", m[0].longitude, m[0].latitude)
default:
geom = "LINESTRING("
for _, mr := range m {
geom = geom + fmt.Sprintf("%f %f,", mr.longitude, mr.latitude)
}
geom = strings.TrimSuffix(geom, ",")
geom = geom + ")"
}
for _, b := range mapBounds {
var in bool
err := db.QueryRow(`select ST_Within(ST_Shift_Longitude(st_setsrid(ST_GeomFromText($1), 4326)),
ST_Shift_Longitude(ST_MakeEnvelope($2,$3,$4,$5, 4326)))`, geom, b.llx, b.lly, b.urx, b.ury).Scan(&in)
if err != nil {
return bbox{}, err
}
if in {
return b, nil
}
}
return world, nil
} | go | func newBboxFromMarkers(m []Marker) (bbox, error) {
var geom string
switch len(m) {
case 0:
return bbox{}, fmt.Errorf("zero length markers, can't determine map bounds")
case 1:
geom = fmt.Sprintf("POINT(%f %f)", m[0].longitude, m[0].latitude)
default:
geom = "LINESTRING("
for _, mr := range m {
geom = geom + fmt.Sprintf("%f %f,", mr.longitude, mr.latitude)
}
geom = strings.TrimSuffix(geom, ",")
geom = geom + ")"
}
for _, b := range mapBounds {
var in bool
err := db.QueryRow(`select ST_Within(ST_Shift_Longitude(st_setsrid(ST_GeomFromText($1), 4326)),
ST_Shift_Longitude(ST_MakeEnvelope($2,$3,$4,$5, 4326)))`, geom, b.llx, b.lly, b.urx, b.ury).Scan(&in)
if err != nil {
return bbox{}, err
}
if in {
return b, nil
}
}
return world, nil
} | [
"func",
"newBboxFromMarkers",
"(",
"m",
"[",
"]",
"Marker",
")",
"(",
"bbox",
",",
"error",
")",
"{",
"var",
"geom",
"string",
"\n",
"switch",
"len",
"(",
"m",
")",
"{",
"case",
"0",
":",
"return",
"bbox",
"{",
"}",
",",
"fmt",
".",
"Errorf",
"("... | // finds a bbox for the markers. Uses the default mapBounds for the set Region. | [
"finds",
"a",
"bbox",
"for",
"the",
"markers",
".",
"Uses",
"the",
"default",
"mapBounds",
"for",
"the",
"set",
"Region",
"."
] | 9dfd58c339375915a35c96438b0db973c4ece9d4 | https://github.com/GeoNet/map180/blob/9dfd58c339375915a35c96438b0db973c4ece9d4/bbox.go#L108-L138 |
154,587 | GeoNet/map180 | bbox.go | newMap3857 | func (b *bbox) newMap3857(width int) (m map3857, err error) {
// bbox on 3857
// tried using st_MakeEnvelope so that only needed to hit DB once
// but it does not do what I for crossing 180
err = db.QueryRow(`with p as (
select st_transform(st_setsrid(st_makepoint($1, $2), 4326), 3857) as pt
)
select ST_X(pt), ST_Y(pt) from p;`, b.llx, b.lly).Scan(&m.llx, &m.lly)
if err != nil {
return
}
err = db.QueryRow(`with p as (
select st_transform(st_setsrid(st_makepoint($1, $2), 4326), 3857) as pt
)
select ST_X(pt), ST_Y(pt) from p;`, b.urx, b.ury).Scan(&m.urx, &m.ury)
if err != nil {
return
}
// Minimum across the top of the bbox on 3857
// Allows for crossing 180
var x float64
err = db.QueryRow(`select ST_Distance(
st_transform(st_setsrid(st_makepoint($1, $2), 4326), 3857),
st_transform(st_setsrid(st_makepoint($3, $4), 4326), 3857)
)`, b.llx, b.ury, b.urx, b.ury).Scan(&x)
if err != nil {
return
}
if b.crosses180 {
m.crossesCentral = true
x = width3857 - x
}
m.width = width
m.dx = 1 / (x / float64(m.width))
m.height = int(math.Abs(m.ury-m.lly)*m.dx) + 1
// shift the map area into SVG view based on upper left corner.
m.xshift = m.llx * -1
m.yshift = m.ury * -1
m.width = width
m.region = b.region
mPix := x / float64(m.width) // m per pixel
// region 1 has higher zoom data.
switch m.region {
case 1:
switch {
case mPix < 50:
m.zoom = 3
case mPix < 500:
m.zoom = 2
case mPix < 5000.0:
m.zoom = 1
default:
m.zoom = 0
}
case 0:
m.zoom = 0
}
return
} | go | func (b *bbox) newMap3857(width int) (m map3857, err error) {
// bbox on 3857
// tried using st_MakeEnvelope so that only needed to hit DB once
// but it does not do what I for crossing 180
err = db.QueryRow(`with p as (
select st_transform(st_setsrid(st_makepoint($1, $2), 4326), 3857) as pt
)
select ST_X(pt), ST_Y(pt) from p;`, b.llx, b.lly).Scan(&m.llx, &m.lly)
if err != nil {
return
}
err = db.QueryRow(`with p as (
select st_transform(st_setsrid(st_makepoint($1, $2), 4326), 3857) as pt
)
select ST_X(pt), ST_Y(pt) from p;`, b.urx, b.ury).Scan(&m.urx, &m.ury)
if err != nil {
return
}
// Minimum across the top of the bbox on 3857
// Allows for crossing 180
var x float64
err = db.QueryRow(`select ST_Distance(
st_transform(st_setsrid(st_makepoint($1, $2), 4326), 3857),
st_transform(st_setsrid(st_makepoint($3, $4), 4326), 3857)
)`, b.llx, b.ury, b.urx, b.ury).Scan(&x)
if err != nil {
return
}
if b.crosses180 {
m.crossesCentral = true
x = width3857 - x
}
m.width = width
m.dx = 1 / (x / float64(m.width))
m.height = int(math.Abs(m.ury-m.lly)*m.dx) + 1
// shift the map area into SVG view based on upper left corner.
m.xshift = m.llx * -1
m.yshift = m.ury * -1
m.width = width
m.region = b.region
mPix := x / float64(m.width) // m per pixel
// region 1 has higher zoom data.
switch m.region {
case 1:
switch {
case mPix < 50:
m.zoom = 3
case mPix < 500:
m.zoom = 2
case mPix < 5000.0:
m.zoom = 1
default:
m.zoom = 0
}
case 0:
m.zoom = 0
}
return
} | [
"func",
"(",
"b",
"*",
"bbox",
")",
"newMap3857",
"(",
"width",
"int",
")",
"(",
"m",
"map3857",
",",
"err",
"error",
")",
"{",
"// bbox on 3857",
"// tried using st_MakeEnvelope so that only needed to hit DB once",
"// but it does not do what I for crossing 180",
"err",
... | // map3857 contains information for drawing map on EPSG3857 | [
"map3857",
"contains",
"information",
"for",
"drawing",
"map",
"on",
"EPSG3857"
] | 9dfd58c339375915a35c96438b0db973c4ece9d4 | https://github.com/GeoNet/map180/blob/9dfd58c339375915a35c96438b0db973c4ece9d4/bbox.go#L174-L243 |
154,588 | salsaflow/salsaflow | git/commit.go | Dump | func (commit *Commit) Dump(wr io.Writer) error {
funcMap := template.FuncMap{
"indent": func(content string) (string, error) {
var out bytes.Buffer
scanner := bufio.NewScanner(strings.NewReader(content))
for scanner.Scan() {
if _, err := fmt.Fprintln(&out, " ", scanner.Text()); err != nil {
return "", err
}
}
if err := scanner.Err(); err != nil {
return "", err
}
return out.String(), nil
},
}
tpl := template.Must(template.New("commit").Funcs(funcMap).Parse(commitTemplate))
return tpl.Execute(wr, commit)
} | go | func (commit *Commit) Dump(wr io.Writer) error {
funcMap := template.FuncMap{
"indent": func(content string) (string, error) {
var out bytes.Buffer
scanner := bufio.NewScanner(strings.NewReader(content))
for scanner.Scan() {
if _, err := fmt.Fprintln(&out, " ", scanner.Text()); err != nil {
return "", err
}
}
if err := scanner.Err(); err != nil {
return "", err
}
return out.String(), nil
},
}
tpl := template.Must(template.New("commit").Funcs(funcMap).Parse(commitTemplate))
return tpl.Execute(wr, commit)
} | [
"func",
"(",
"commit",
"*",
"Commit",
")",
"Dump",
"(",
"wr",
"io",
".",
"Writer",
")",
"error",
"{",
"funcMap",
":=",
"template",
".",
"FuncMap",
"{",
"\"",
"\"",
":",
"func",
"(",
"content",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
... | // Dump writes a human-friendly representation of the commit to the writer.
// The output closely resembles the output of git log. | [
"Dump",
"writes",
"a",
"human",
"-",
"friendly",
"representation",
"of",
"the",
"commit",
"to",
"the",
"writer",
".",
"The",
"output",
"closely",
"resembles",
"the",
"output",
"of",
"git",
"log",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/git/commit.go#L38-L57 |
154,589 | salsaflow/salsaflow | Godeps/_workspace/src/gopkg.in/tchap/gocli.v2/help.go | helpAction | func helpAction(exitCode int) func(*Command, []string) {
return func(cmd *Command, args []string) {
cmd.Usage()
os.Exit(exitCode)
}
} | go | func helpAction(exitCode int) func(*Command, []string) {
return func(cmd *Command, args []string) {
cmd.Usage()
os.Exit(exitCode)
}
} | [
"func",
"helpAction",
"(",
"exitCode",
"int",
")",
"func",
"(",
"*",
"Command",
",",
"[",
"]",
"string",
")",
"{",
"return",
"func",
"(",
"cmd",
"*",
"Command",
",",
"args",
"[",
"]",
"string",
")",
"{",
"cmd",
".",
"Usage",
"(",
")",
"\n",
"os",... | // Helper action that just wraps a call to Usage. | [
"Helper",
"action",
"that",
"just",
"wraps",
"a",
"call",
"to",
"Usage",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/Godeps/_workspace/src/gopkg.in/tchap/gocli.v2/help.go#L49-L54 |
154,590 | salsaflow/salsaflow | git/gitutil/gitutil.go | RelativePath | func RelativePath(pathFromRoot string) (relativePath string, err error) {
task := fmt.Sprintf("Get the relative for '%v'", pathFromRoot)
root, err := RepositoryRootAbsolutePath()
if err != nil {
return "", errs.NewError(task, err)
}
absolutePath := filepath.Join(root, pathFromRoot)
cwd, err := os.Getwd()
if err != nil {
return "", errs.NewError(task, err)
}
relativePath, err = filepath.Rel(cwd, absolutePath)
if err != nil {
return "", errs.NewError(task, err)
}
return relativePath, nil
} | go | func RelativePath(pathFromRoot string) (relativePath string, err error) {
task := fmt.Sprintf("Get the relative for '%v'", pathFromRoot)
root, err := RepositoryRootAbsolutePath()
if err != nil {
return "", errs.NewError(task, err)
}
absolutePath := filepath.Join(root, pathFromRoot)
cwd, err := os.Getwd()
if err != nil {
return "", errs.NewError(task, err)
}
relativePath, err = filepath.Rel(cwd, absolutePath)
if err != nil {
return "", errs.NewError(task, err)
}
return relativePath, nil
} | [
"func",
"RelativePath",
"(",
"pathFromRoot",
"string",
")",
"(",
"relativePath",
"string",
",",
"err",
"error",
")",
"{",
"task",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"pathFromRoot",
")",
"\n\n",
"root",
",",
"err",
":=",
"RepositoryRootAbsol... | // RelativePath returns the relative path from the current working directory to the file
// specified by the relative path from the repository root.
//
// This is useful for some other Git commands, particularly git status. | [
"RelativePath",
"returns",
"the",
"relative",
"path",
"from",
"the",
"current",
"working",
"directory",
"to",
"the",
"file",
"specified",
"by",
"the",
"relative",
"path",
"from",
"the",
"repository",
"root",
".",
"This",
"is",
"useful",
"for",
"some",
"other",... | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/git/gitutil/gitutil.go#L57-L77 |
154,591 | salsaflow/salsaflow | releases/git.go | ListNewTrunkCommits | func ListNewTrunkCommits() ([]*git.Commit, error) {
// Get git config.
config, err := git.LoadConfig()
if err != nil {
return nil, err
}
var (
remoteName = config.RemoteName
trunkBranch = config.TrunkBranchName
releaseBranch = config.ReleaseBranchName
stagingBranch = config.StagingBranchName
)
// By default, use the staging branch as the --not part.
// In other words, list commits that are on trunk,
// but which are not reachable from the staging branch.
// In case the staging branch doesn't exist, take the whole trunk.
// That probably means that no release has ever been started,
// so the staging branch has not been created yet.
var revRange string
for _, branch := range [...]string{releaseBranch, stagingBranch} {
err := git.CheckOrCreateTrackingBranch(branch, remoteName)
// In case the branch is ok, we use it.
if err == nil {
revRange = fmt.Sprintf("%v..%v", branch, trunkBranch)
break
}
// In case the branch does not exist, it's ok and we continue.
if _, ok := err.(*git.ErrRefNotFound); ok {
continue
}
// Otherwise we return the error since something has just exploded.
// This can mean that the branch is not up to date, but that is an error as well.
return nil, err
}
if revRange == "" {
revRange = trunkBranch
}
// Get the commits in range.
commits, err := git.ShowCommitRange(revRange)
if err != nil {
return nil, err
}
// Limit the commits by date.
repoConfig, err := repo.LoadConfig()
if err != nil {
return nil, err
}
enabledTimestamp := repoConfig.SalsaFlowEnabledTimestamp
commits = git.FilterCommits(commits, func(commit *git.Commit) bool {
return commit.AuthorDate.After(enabledTimestamp)
})
return commits, nil
} | go | func ListNewTrunkCommits() ([]*git.Commit, error) {
// Get git config.
config, err := git.LoadConfig()
if err != nil {
return nil, err
}
var (
remoteName = config.RemoteName
trunkBranch = config.TrunkBranchName
releaseBranch = config.ReleaseBranchName
stagingBranch = config.StagingBranchName
)
// By default, use the staging branch as the --not part.
// In other words, list commits that are on trunk,
// but which are not reachable from the staging branch.
// In case the staging branch doesn't exist, take the whole trunk.
// That probably means that no release has ever been started,
// so the staging branch has not been created yet.
var revRange string
for _, branch := range [...]string{releaseBranch, stagingBranch} {
err := git.CheckOrCreateTrackingBranch(branch, remoteName)
// In case the branch is ok, we use it.
if err == nil {
revRange = fmt.Sprintf("%v..%v", branch, trunkBranch)
break
}
// In case the branch does not exist, it's ok and we continue.
if _, ok := err.(*git.ErrRefNotFound); ok {
continue
}
// Otherwise we return the error since something has just exploded.
// This can mean that the branch is not up to date, but that is an error as well.
return nil, err
}
if revRange == "" {
revRange = trunkBranch
}
// Get the commits in range.
commits, err := git.ShowCommitRange(revRange)
if err != nil {
return nil, err
}
// Limit the commits by date.
repoConfig, err := repo.LoadConfig()
if err != nil {
return nil, err
}
enabledTimestamp := repoConfig.SalsaFlowEnabledTimestamp
commits = git.FilterCommits(commits, func(commit *git.Commit) bool {
return commit.AuthorDate.After(enabledTimestamp)
})
return commits, nil
} | [
"func",
"ListNewTrunkCommits",
"(",
")",
"(",
"[",
"]",
"*",
"git",
".",
"Commit",
",",
"error",
")",
"{",
"// Get git config.",
"config",
",",
"err",
":=",
"git",
".",
"LoadConfig",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
","... | // ListNewTrunkCommits returns the list of commits that are new since the last release.
// By the last release we mean the last release being tested, staged or released. | [
"ListNewTrunkCommits",
"returns",
"the",
"list",
"of",
"commits",
"that",
"are",
"new",
"since",
"the",
"last",
"release",
".",
"By",
"the",
"last",
"release",
"we",
"mean",
"the",
"last",
"release",
"being",
"tested",
"staged",
"or",
"released",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/releases/git.go#L19-L76 |
154,592 | salsaflow/salsaflow | releases/git.go | ListStoryIdsToBeAssigned | func ListStoryIdsToBeAssigned(tracker common.IssueTracker) ([]string, error) {
// Get the commits that modified trunk.
task := "Get the commits that modified trunk"
commits, err := ListNewTrunkCommits()
if err != nil {
return nil, errs.NewError(task, err)
}
// Collect the story IDs.
idSet := make(map[string]struct{}, len(commits))
for _, commit := range commits {
// Skip empty tags.
if commit.StoryIdTag == "" {
continue
}
// Parse the tag to get the story ID.
storyId, err := tracker.StoryTagToReadableStoryId(commit.StoryIdTag)
if err != nil {
continue
}
// Add the ID to the set.
idSet[storyId] = struct{}{}
}
// Convert the set to a list.
idList := make([]string, 0, len(idSet))
for id := range idSet {
idList = append(idList, id)
}
// Return the final list of story IDs.
return idList, nil
} | go | func ListStoryIdsToBeAssigned(tracker common.IssueTracker) ([]string, error) {
// Get the commits that modified trunk.
task := "Get the commits that modified trunk"
commits, err := ListNewTrunkCommits()
if err != nil {
return nil, errs.NewError(task, err)
}
// Collect the story IDs.
idSet := make(map[string]struct{}, len(commits))
for _, commit := range commits {
// Skip empty tags.
if commit.StoryIdTag == "" {
continue
}
// Parse the tag to get the story ID.
storyId, err := tracker.StoryTagToReadableStoryId(commit.StoryIdTag)
if err != nil {
continue
}
// Add the ID to the set.
idSet[storyId] = struct{}{}
}
// Convert the set to a list.
idList := make([]string, 0, len(idSet))
for id := range idSet {
idList = append(idList, id)
}
// Return the final list of story IDs.
return idList, nil
} | [
"func",
"ListStoryIdsToBeAssigned",
"(",
"tracker",
"common",
".",
"IssueTracker",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"// Get the commits that modified trunk.",
"task",
":=",
"\"",
"\"",
"\n",
"commits",
",",
"err",
":=",
"ListNewTrunkCommits",
... | // ListStoryIdsToBeAssigned lists the story IDs that are associated with
// the commits that modified trunk since the last release, i.e. with the commits
// as returned by ListNewTrunkCommits.
//
// Only the story IDs matching the issue tracker that is passed in are returned. | [
"ListStoryIdsToBeAssigned",
"lists",
"the",
"story",
"IDs",
"that",
"are",
"associated",
"with",
"the",
"commits",
"that",
"modified",
"trunk",
"since",
"the",
"last",
"release",
"i",
".",
"e",
".",
"with",
"the",
"commits",
"as",
"returned",
"by",
"ListNewTru... | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/releases/git.go#L83-L117 |
154,593 | salsaflow/salsaflow | releases/git.go | ListTags | func ListTags() (tags []string, err error) {
var task = "Get release tags"
// Get all release tags.
stdout, err := git.RunCommand("tag", "--list", "v*.*.*")
if err != nil {
return nil, errs.NewError(task, err)
}
// Parse the output to get sortable versions.
var vers []*version.Version
scanner := bufio.NewScanner(stdout)
for scanner.Scan() {
line := scanner.Text()
if line == "" {
continue
}
line = line[1:] // strip "v"
ver, _ := version.Parse(line)
vers = append(vers, ver)
}
if err := scanner.Err(); err != nil {
return nil, errs.NewError(task, err)
}
// Sort the versions.
sort.Sort(version.Versions(vers))
// Convert versions back to tag names and return.
tgs := make([]string, 0, len(vers))
for _, ver := range vers {
tgs = append(tgs, "v"+ver.String())
}
return tgs, nil
} | go | func ListTags() (tags []string, err error) {
var task = "Get release tags"
// Get all release tags.
stdout, err := git.RunCommand("tag", "--list", "v*.*.*")
if err != nil {
return nil, errs.NewError(task, err)
}
// Parse the output to get sortable versions.
var vers []*version.Version
scanner := bufio.NewScanner(stdout)
for scanner.Scan() {
line := scanner.Text()
if line == "" {
continue
}
line = line[1:] // strip "v"
ver, _ := version.Parse(line)
vers = append(vers, ver)
}
if err := scanner.Err(); err != nil {
return nil, errs.NewError(task, err)
}
// Sort the versions.
sort.Sort(version.Versions(vers))
// Convert versions back to tag names and return.
tgs := make([]string, 0, len(vers))
for _, ver := range vers {
tgs = append(tgs, "v"+ver.String())
}
return tgs, nil
} | [
"func",
"ListTags",
"(",
")",
"(",
"tags",
"[",
"]",
"string",
",",
"err",
"error",
")",
"{",
"var",
"task",
"=",
"\"",
"\"",
"\n\n",
"// Get all release tags.",
"stdout",
",",
"err",
":=",
"git",
".",
"RunCommand",
"(",
"\"",
"\"",
",",
"\"",
"\"",
... | // ListTags returns the list of all release tags, sorted by the versions they represent. | [
"ListTags",
"returns",
"the",
"list",
"of",
"all",
"release",
"tags",
"sorted",
"by",
"the",
"versions",
"they",
"represent",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/releases/git.go#L120-L154 |
154,594 | timehop/gos2 | r3/vector.go | ApproxEqual | func (v Vector) ApproxEqual(ov Vector) bool {
const epsilon = 1e-14
return math.Abs(v.X-ov.X) < epsilon && math.Abs(v.Y-ov.Y) < epsilon && math.Abs(v.Z-ov.Z) < epsilon
} | go | func (v Vector) ApproxEqual(ov Vector) bool {
const epsilon = 1e-14
return math.Abs(v.X-ov.X) < epsilon && math.Abs(v.Y-ov.Y) < epsilon && math.Abs(v.Z-ov.Z) < epsilon
} | [
"func",
"(",
"v",
"Vector",
")",
"ApproxEqual",
"(",
"ov",
"Vector",
")",
"bool",
"{",
"const",
"epsilon",
"=",
"1e-14",
"\n",
"return",
"math",
".",
"Abs",
"(",
"v",
".",
"X",
"-",
"ov",
".",
"X",
")",
"<",
"epsilon",
"&&",
"math",
".",
"Abs",
... | // ApproxEqual reports whether v and ov are equal within a small epsilon. | [
"ApproxEqual",
"reports",
"whether",
"v",
"and",
"ov",
"are",
"equal",
"within",
"a",
"small",
"epsilon",
"."
] | 004cde1d85c2ef02a66c6c769d44b293d28879f5 | https://github.com/timehop/gos2/blob/004cde1d85c2ef02a66c6c769d44b293d28879f5/r3/vector.go#L16-L19 |
154,595 | salsaflow/salsaflow | Godeps/_workspace/src/gopkg.in/salsita/go-pivotaltracker.v1/v5/pivotal/cursor.go | newCursor | func newCursor(client *Client, fn requestFn, limit int) (c *cursor, err error) {
return &cursor{client: client, requestFn: fn, limit: limit}, nil
} | go | func newCursor(client *Client, fn requestFn, limit int) (c *cursor, err error) {
return &cursor{client: client, requestFn: fn, limit: limit}, nil
} | [
"func",
"newCursor",
"(",
"client",
"*",
"Client",
",",
"fn",
"requestFn",
",",
"limit",
"int",
")",
"(",
"c",
"*",
"cursor",
",",
"err",
"error",
")",
"{",
"return",
"&",
"cursor",
"{",
"client",
":",
"client",
",",
"requestFn",
":",
"fn",
",",
"l... | // newCursor creates a new cursor to interate over an endpoint that
// supports limit and offest request parameters. | [
"newCursor",
"creates",
"a",
"new",
"cursor",
"to",
"interate",
"over",
"an",
"endpoint",
"that",
"supports",
"limit",
"and",
"offest",
"request",
"parameters",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/Godeps/_workspace/src/gopkg.in/salsita/go-pivotaltracker.v1/v5/pivotal/cursor.go#L31-L33 |
154,596 | salsaflow/salsaflow | Godeps/_workspace/src/gopkg.in/salsita/go-pivotaltracker.v1/v5/pivotal/cursor.go | getIntHeader | func getIntHeader(err *error, resp *http.Response, header string) int {
if *err != nil {
return 0
}
v := resp.Header.Get(header)
if v == "" {
return 0
}
i, ex := strconv.Atoi(v)
if ex != nil {
*err = ex
return 0
}
return i
} | go | func getIntHeader(err *error, resp *http.Response, header string) int {
if *err != nil {
return 0
}
v := resp.Header.Get(header)
if v == "" {
return 0
}
i, ex := strconv.Atoi(v)
if ex != nil {
*err = ex
return 0
}
return i
} | [
"func",
"getIntHeader",
"(",
"err",
"*",
"error",
",",
"resp",
"*",
"http",
".",
"Response",
",",
"header",
"string",
")",
"int",
"{",
"if",
"*",
"err",
"!=",
"nil",
"{",
"return",
"0",
"\n",
"}",
"\n",
"v",
":=",
"resp",
".",
"Header",
".",
"Get... | // Helper to extract and convert Header values that are Int's | [
"Helper",
"to",
"extract",
"and",
"convert",
"Header",
"values",
"that",
"are",
"Int",
"s"
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/Godeps/_workspace/src/gopkg.in/salsita/go-pivotaltracker.v1/v5/pivotal/cursor.go#L138-L152 |
154,597 | salsaflow/salsaflow | config/config_global.go | ReadGlobalConfig | func ReadGlobalConfig() (*GlobalConfig, error) {
task := "Read and parse the global configuration file"
// Get the global configuration file absolute path.
path, err := GlobalConfigFileAbsolutePath()
if err != nil {
return nil, errs.NewError(task, err)
}
// Read and parse the file.
var global GlobalConfig
if err := readAndUnmarshalConfig(path, &global); err != nil {
return nil, errs.NewError(task, err)
}
// Return the config struct.
return &global, nil
} | go | func ReadGlobalConfig() (*GlobalConfig, error) {
task := "Read and parse the global configuration file"
// Get the global configuration file absolute path.
path, err := GlobalConfigFileAbsolutePath()
if err != nil {
return nil, errs.NewError(task, err)
}
// Read and parse the file.
var global GlobalConfig
if err := readAndUnmarshalConfig(path, &global); err != nil {
return nil, errs.NewError(task, err)
}
// Return the config struct.
return &global, nil
} | [
"func",
"ReadGlobalConfig",
"(",
")",
"(",
"*",
"GlobalConfig",
",",
"error",
")",
"{",
"task",
":=",
"\"",
"\"",
"\n\n",
"// Get the global configuration file absolute path.",
"path",
",",
"err",
":=",
"GlobalConfigFileAbsolutePath",
"(",
")",
"\n",
"if",
"err",
... | // ReadGlobalConfig reads and parses the global configuration file
// and returns a struct representing the content. | [
"ReadGlobalConfig",
"reads",
"and",
"parses",
"the",
"global",
"configuration",
"file",
"and",
"returns",
"a",
"struct",
"representing",
"the",
"content",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/config/config_global.go#L36-L53 |
154,598 | salsaflow/salsaflow | config/config_global.go | WriteGlobalConfig | func WriteGlobalConfig(config *GlobalConfig) error {
task := "Write the global configuration file"
// Get the global configuration file absolute path.
path, err := GlobalConfigFileAbsolutePath()
if err != nil {
return errs.NewError(task, err)
}
// Write the file.
if err := writeConfig(path, config, 0644); err != nil {
return errs.NewError(task, err)
}
return nil
} | go | func WriteGlobalConfig(config *GlobalConfig) error {
task := "Write the global configuration file"
// Get the global configuration file absolute path.
path, err := GlobalConfigFileAbsolutePath()
if err != nil {
return errs.NewError(task, err)
}
// Write the file.
if err := writeConfig(path, config, 0644); err != nil {
return errs.NewError(task, err)
}
return nil
} | [
"func",
"WriteGlobalConfig",
"(",
"config",
"*",
"GlobalConfig",
")",
"error",
"{",
"task",
":=",
"\"",
"\"",
"\n\n",
"// Get the global configuration file absolute path.",
"path",
",",
"err",
":=",
"GlobalConfigFileAbsolutePath",
"(",
")",
"\n",
"if",
"err",
"!=",
... | // WriteGlobalConfig writes the given configuration struct
// into the global configuration file.
//
// In case the target path does not exist, it is created,
// including the parent directories.
//
// In case the file exists, it is truncated. | [
"WriteGlobalConfig",
"writes",
"the",
"given",
"configuration",
"struct",
"into",
"the",
"global",
"configuration",
"file",
".",
"In",
"case",
"the",
"target",
"path",
"does",
"not",
"exist",
"it",
"is",
"created",
"including",
"the",
"parent",
"directories",
".... | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/config/config_global.go#L62-L77 |
154,599 | salsaflow/salsaflow | prompt/storyprompt/dialog_options.go | NewIndexOption | func NewIndexOption() *DialogOption {
return &DialogOption{
Description: []string{
"Choose a story by inserting the associated index.",
},
IsActive: func(stories []common.Story, depth int) bool {
return len(stories) != 0
},
MatchesInput: func(input string, stories []common.Story) bool {
index, err := strconv.Atoi(input)
if err != nil {
return false
}
return 1 <= index && index <= len(stories)
},
SelectStory: func(
input string,
stories []common.Story,
currentDialog *Dialog,
) (common.Story, error) {
index, _ := strconv.Atoi(input)
return stories[index-1], nil
},
}
} | go | func NewIndexOption() *DialogOption {
return &DialogOption{
Description: []string{
"Choose a story by inserting the associated index.",
},
IsActive: func(stories []common.Story, depth int) bool {
return len(stories) != 0
},
MatchesInput: func(input string, stories []common.Story) bool {
index, err := strconv.Atoi(input)
if err != nil {
return false
}
return 1 <= index && index <= len(stories)
},
SelectStory: func(
input string,
stories []common.Story,
currentDialog *Dialog,
) (common.Story, error) {
index, _ := strconv.Atoi(input)
return stories[index-1], nil
},
}
} | [
"func",
"NewIndexOption",
"(",
")",
"*",
"DialogOption",
"{",
"return",
"&",
"DialogOption",
"{",
"Description",
":",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"}",
",",
"IsActive",
":",
"func",
"(",
"stories",
"[",
"]",
"common",
".",
"Story",
",",
... | // NewIndexOption returns an option that can be used to choose a story by its index. | [
"NewIndexOption",
"returns",
"an",
"option",
"that",
"can",
"be",
"used",
"to",
"choose",
"a",
"story",
"by",
"its",
"index",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/prompt/storyprompt/dialog_options.go#L14-L39 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.