Hello community,
here is the log from the commit of package golang-github-kr-text for
openSUSE:Factory checked in at 2017-03-24 02:15:53
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/golang-github-kr-text (Old)
and /work/SRC/openSUSE:Factory/.golang-github-kr-text.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "golang-github-kr-text"
Fri Mar 24 02:15:53 2017 rev:2 rq:477177 version:0.0.0+git20160504.7cafcd8
Changes:
--------
---
/work/SRC/openSUSE:Factory/golang-github-kr-text/golang-github-kr-text.changes
2015-07-24 09:58:27.000000000 +0200
+++
/work/SRC/openSUSE:Factory/.golang-github-kr-text.new/golang-github-kr-text.changes
2017-03-24 02:15:54.664824008 +0100
@@ -1,0 +2,20 @@
+Thu Dec 08 13:19:22 UTC 2016 - [email protected]
+
+- Update to version 0.0.0+git20160504.7cafcd8:
+ * handle unicode input correctly
+ * add license (from plan 9 from user space)
+ * open only one file at a time
+ * indent writer
+ * refactor
+ * properly track prefix bytes written
+ * relicense whole repo under MIT
+ * Run 'gofmt -w -s' on sources
+ * text: fix infinite loop in Wrap
+ * cmd/agg: new command
+
+-------------------------------------------------------------------
+Thu Dec 8 13:13:12 UTC 2016 - [email protected]
+
+- Refactoring based on new packaging proposal
+
+-------------------------------------------------------------------
Old:
----
text-0.0.0+git20150520.e373e13.tar.xz
New:
----
rpmlintrc
text-0.0.0+git20160504.7cafcd8.tar.xz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ golang-github-kr-text.spec ++++++
--- /var/tmp/diff_new_pack.R1HBkM/_old 2017-03-24 02:15:55.232743653 +0100
+++ /var/tmp/diff_new_pack.R1HBkM/_new 2017-03-24 02:15:55.236743087 +0100
@@ -1,7 +1,7 @@
#
-# spec file for package golang-github-kr-text
+# spec file for package golang
#
-# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -16,45 +16,53 @@
#
-Name: golang-github-kr-text
-Version: 0.0.0+git20150520.e373e13
+%global provider github
+%global provider_tld com
+%global project kr
+%global repo text
+%global provider_prefix %{provider}.%{provider_tld}/%{project}/%{repo}
+%global import_path %{provider_prefix}
+
+Name: golang-%{provider}-%{project}-%{repo}
+Version: 0.0.0+git20160504.7cafcd8
Release: 0
Summary: Miscellaneous functions for formatting text
License: MIT
-Group: Development/Languages/Other
-Url: https://github.com/kr/text
-Source: text-%{version}.tar.xz
+Group: Development/Languages/Golang
+Url: https://%{provider_prefix}
+Source0: %{repo}-%{version}.tar.xz
+Source1: rpmlintrc
+BuildRoot: %{_tmppath}/%{name}-%{version}-build
+
BuildRequires: golang-packaging
BuildRequires: xz
-BuildRoot: %{_tmppath}/%{name}-%{version}-build
-Provides: go-kr-text = %{version}
-Obsoletes: go-kr-text < %{version}
+
+%{go_nostrip}
%{go_provides}
%description
This is a Go package for manipulating paragraphs of text.
-%gosrc_package
-
%prep
-%setup -q -n text-%{version}
+%setup -q -n %{repo}-%{version}
+
+# do not install the mc and agg binary
+rm -rf mc cmd/agg
%build
-%goprep github.com/kr/text
-%gobuild
+%goprep %{import_path}
+%gobuild ...
%install
%goinstall
-
%gosrc
+%gofilelist
+
+%check
+%gotest %{import_path}...
-%files
-%defattr(-,root,root)
-%doc License Readme
-%{go_contribdir}/*
-
-%files source
-%defattr(-,root,root)
-%{go_contribsrcdir}/*
+%files -f file.lst
+%defattr(-,root,root,-)
+%doc Readme License
%changelog
++++++ _service ++++++
--- /var/tmp/diff_new_pack.R1HBkM/_old 2017-03-24 02:15:55.292735164 +0100
+++ /var/tmp/diff_new_pack.R1HBkM/_new 2017-03-24 02:15:55.292735164 +0100
@@ -1,16 +1,17 @@
<services>
- <service name="tar_scm" mode="localonly">
- <param name="url">https://github.com/kr/text.git</param>
+ <service name="tar_scm" mode="disabled">
+ <param name="url">https://github.com/kr/text</param>
<param name="scm">git</param>
<param name="exclude">.git</param>
<param name="versionformat">0.0.0+git%cd.%h</param>
<param name="revision">master</param>
+ <param name="changesgenerate">enable</param>
</service>
- <service name="recompress" mode="localonly">
+ <service name="recompress" mode="disabled">
<param name="file">text-*.tar</param>
<param name="compression">xz</param>
</service>
- <service name="set_version" mode="localonly">
+ <service name="set_version" mode="disabled">
<param name="basename">text</param>
</service>
</services>
++++++ rpmlintrc ++++++
# We are preventing the stripping to keep backtraces intact
addFilter("unstripped-binary-or-object")
# Golang doesn't support dynamic linking yet in a proper way
addFilter("statically-linked-binary")
# We are aware of that but shorter names are not possible
addFilter("filename-too-long-for-joliet")
++++++ text-0.0.0+git20150520.e373e13.tar.xz ->
text-0.0.0+git20160504.7cafcd8.tar.xz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/text-0.0.0+git20150520.e373e13/cmd/agg/doc.go
new/text-0.0.0+git20160504.7cafcd8/cmd/agg/doc.go
--- old/text-0.0.0+git20150520.e373e13/cmd/agg/doc.go 1970-01-01
01:00:00.000000000 +0100
+++ new/text-0.0.0+git20160504.7cafcd8/cmd/agg/doc.go 2016-05-05
01:40:17.000000000 +0200
@@ -0,0 +1,73 @@
+/*
+
+Agg computes aggregate values over tabular text.
+It behaves somewhat like the SQL “GROUP BY” clause.
+
+Usage:
+
+ agg [function...]
+
+It reads input from stdin as a sequence of records, one per line.
+It treats each line as a set of fields separated by white space.
+One field (the first, by default) is designated as the key.
+Successive lines with equal keys are grouped into a group,
+and agg produces one line of output for each group.
+(Note that only contiguous input lines can form a group.
+If you need to make sure that all records for a given key
+are grouped together, sort the input first.)
+
+For each remaining field,
+agg applies a function to all the values in the group,
+producing a single output value.
+The command line arguments specify which functions to use,
+one per field in the input table.
+
+Functions
+
+The available functions are:
+
+ key group by this field (default for field 1)
+ first value from first line of group (default for rest)
+ last value from last line of group
+ sample value from any line of group, uniformly at random
+ prefix longest common string prefix
+ join:sep concatenate strings with given sep
+ smin lexically least string
+ smax lexically greatest string
+ min numerically least value
+ max numerically greatest value
+ sum numeric sum
+ mean arithmetic mean
+ count number of records (ignores input value)
+ const:val print val, ignoring input
+ drop omit the column entirely
+
+The numeric functions skip items that don't parse as numbers.
+
+Examples
+
+Using the following input:
+
+ $ cat >input
+ -rwx alice 100 /home/alice/bin/crdt
+ -rw- alice 210002 /home/alice/thesis.tex
+ -rw- bob 10051 /home/bob/expenses.tab
+ -rwx kr 862060 /home/kr/bin/blog
+ -rwx kr 304608 /home/kr/bin/agg
+
+Disk usage for each user, plus where that disk usage occurs
+(longest common prefix of filesystem paths):
+
+ $ agg <input drop key sum prefix
+ alice 210153 /home/alice/
+ bob 10051 /home/bob/expenses.tab
+ kr 1166668 /home/kr/
+
+Disk usage for executable vs non-executable files:
+
+ $ sort input | agg key drop sum join:,
+ -rw- 220053 /home/alice/thesis.tex,/home/bob/expenses.tab
+ -rwx 1166768 /home/alice/bin/crdt,/home/kr/bin/agg,/home/kr/bin/blog
+
+*/
+package main
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/text-0.0.0+git20150520.e373e13/cmd/agg/main.go
new/text-0.0.0+git20160504.7cafcd8/cmd/agg/main.go
--- old/text-0.0.0+git20150520.e373e13/cmd/agg/main.go 1970-01-01
01:00:00.000000000 +0100
+++ new/text-0.0.0+git20160504.7cafcd8/cmd/agg/main.go 2016-05-05
01:40:17.000000000 +0200
@@ -0,0 +1,112 @@
+package main
+
+// TODO(kr): tests
+
+import (
+ "bufio"
+ "fmt"
+ "log"
+ "math/rand"
+ "os"
+ "strings"
+ "time"
+)
+
+type agg interface {
+ merge(string)
+ String() string
+}
+
+var (
+ key = 0
+ funcmap = make(map[int]func(init, arg string) agg)
+ argmap = make(map[int]string)
+ symtab = map[string]func(init, arg string) agg{
+ "first": first,
+ "last": last,
+ "prefix": prefix,
+ "sample": sample,
+ "join": join,
+ "smin": smin,
+ "smax": smax,
+ "min": min,
+ "max": max,
+ "sum": sum,
+ "mean": mean,
+ "count": count,
+ "const": constf,
+ "drop": nil,
+ }
+)
+
+func main() {
+ log.SetPrefix("agg: ")
+ log.SetFlags(0)
+ rand.Seed(time.Now().UnixNano())
+ for i, sym := range os.Args[1:] {
+ if p := strings.IndexByte(sym, ':'); p >= 0 {
+ sym, argmap[i] = sym[:p], sym[p+1:]
+ }
+ if sym == "key" {
+ key, sym = i, "first"
+ }
+ f, ok := symtab[sym]
+ if !ok {
+ log.Fatalf("bad function: %q", sym)
+ }
+ funcmap[i] = f
+ }
+
+ sc := bufio.NewScanner(os.Stdin)
+ var g *group
+ for sc.Scan() {
+ ss := strings.Fields(sc.Text())
+ if !matches(g, ss) {
+ emit(g)
+ g = &group{key: ss[key]}
+ }
+ mergeLine(g, ss)
+ }
+ emit(g)
+}
+
+type group struct {
+ key string
+ agg []agg
+}
+
+func matches(g *group, ss []string) bool {
+ return g != nil && g.key == ss[key]
+}
+
+func emit(g *group) {
+ if g == nil {
+ return
+ }
+ rest := false
+ for i, a := range g.agg {
+ if f, ok := funcmap[i]; ok && f == nil {
+ continue
+ }
+ if rest {
+ fmt.Print("\t")
+ }
+ rest = true
+ fmt.Print(a)
+ }
+ fmt.Println()
+}
+
+func mergeLine(g *group, ss []string) {
+ for i, s := range ss {
+ if i >= len(g.agg) {
+ f := funcmap[i]
+ if f == nil {
+ f = first
+ }
+ g.agg = append(g.agg, f(s, argmap[i]))
+ } else {
+ g.agg[i].merge(s)
+ }
+ }
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/text-0.0.0+git20150520.e373e13/cmd/agg/num.go
new/text-0.0.0+git20160504.7cafcd8/cmd/agg/num.go
--- old/text-0.0.0+git20150520.e373e13/cmd/agg/num.go 1970-01-01
01:00:00.000000000 +0100
+++ new/text-0.0.0+git20160504.7cafcd8/cmd/agg/num.go 2016-05-05
01:40:17.000000000 +0200
@@ -0,0 +1,99 @@
+package main
+
+import (
+ "math/big"
+ "strconv"
+)
+
+func min(s, arg string) agg { return newBinop(s, opmin) }
+func max(s, arg string) agg { return newBinop(s, opmax) }
+func sum(s, arg string) agg { return newBinop(s, opsum) }
+
+type binop struct {
+ v *big.Float
+ f func(a, b *big.Float) *big.Float
+}
+
+func newBinop(s string, f func(a, b *big.Float) *big.Float) *binop {
+ v, _ := parseFloat(s)
+ return &binop{v, f}
+}
+
+func (o *binop) String() string {
+ if o.v == nil {
+ return "NaN"
+ }
+ return o.v.Text('f', -1)
+}
+
+func (o *binop) merge(s string) {
+ v, ok := parseFloat(s)
+ if !ok {
+ return
+ }
+ o.v = o.f(o.v, v)
+}
+
+func opmin(a, b *big.Float) *big.Float {
+ if a != nil && (b == nil || a.Cmp(b) <= 0) {
+ return a
+ }
+ return b
+}
+
+func opmax(a, b *big.Float) *big.Float {
+ if a != nil && (b == nil || a.Cmp(b) >= 0) {
+ return a
+ }
+ return b
+}
+
+func opsum(a, b *big.Float) *big.Float {
+ if a == nil {
+ return b
+ } else if b == nil {
+ return a
+ }
+ return a.Add(a, b)
+}
+
+type meanagg struct {
+ v *big.Float
+ d float64 // actually an integer
+}
+
+func mean(s, arg string) agg {
+ v, ok := parseFloat(s)
+ if !ok {
+ return &meanagg{new(big.Float), 0}
+ }
+ return &meanagg{v, 1}
+}
+
+func (m *meanagg) String() string {
+ if m.d == 0 {
+ return "NaN"
+ }
+ v := new(big.Float).Quo(m.v, big.NewFloat(m.d))
+ return v.Text('f', -1)
+}
+
+func (m *meanagg) merge(s string) {
+ v, ok := parseFloat(s)
+ if !ok {
+ return
+ }
+ m.v.Add(m.v, v)
+ m.d++
+}
+
+func parseFloat(s string) (*big.Float, bool) {
+ v, _, err := big.ParseFloat(s, 0, 1000, big.ToNearestEven)
+ return v, err == nil
+}
+
+type counter int
+
+func count(init, arg string) agg { return new(counter) }
+func (c *counter) String() string { return strconv.Itoa(int(*c) + 1) }
+func (c *counter) merge(string) { *c++ }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/text-0.0.0+git20150520.e373e13/cmd/agg/string.go
new/text-0.0.0+git20160504.7cafcd8/cmd/agg/string.go
--- old/text-0.0.0+git20150520.e373e13/cmd/agg/string.go 1970-01-01
01:00:00.000000000 +0100
+++ new/text-0.0.0+git20160504.7cafcd8/cmd/agg/string.go 2016-05-05
01:40:17.000000000 +0200
@@ -0,0 +1,74 @@
+package main
+
+import (
+ "math/rand"
+ "strings"
+)
+
+func first(s, arg string) agg { return &sbinop{s, opfirst} }
+func last(s, arg string) agg { return &sbinop{s, oplast} }
+func prefix(s, arg string) agg { return &sbinop{s, opprefix} }
+func join(s, arg string) agg { return &sbinop{s, opjoin(arg)} }
+func smin(s, arg string) agg { return &sbinop{s, opsmin} }
+func smax(s, arg string) agg { return &sbinop{s, opsmax} }
+
+type sbinop struct {
+ s string
+ f func(a, b string) string
+}
+
+func (o *sbinop) String() string { return o.s }
+
+func (o *sbinop) merge(s string) { o.s = o.f(o.s, s) }
+
+func opfirst(a, b string) string { return a }
+func oplast(a, b string) string { return b }
+
+func opprefix(a, b string) string {
+ for i := range a {
+ if i >= len(b) || a[i] != b[i] {
+ return a[:i]
+ }
+ }
+ return a
+}
+
+func opjoin(sep string) func(a, b string) string {
+ return func(a, b string) string {
+ return a + sep + b // TODO(kr): too slow? maybe strings.Join?
+ }
+}
+
+func opsmin(a, b string) string {
+ if strings.Compare(a, b) <= 0 {
+ return a
+ }
+ return b
+}
+
+func opsmax(a, b string) string {
+ if strings.Compare(a, b) >= 0 {
+ return a
+ }
+ return b
+}
+
+type sampler struct {
+ n int
+ s string
+}
+
+func sample(s, arg string) agg { return &sampler{1, s} }
+func (p *sampler) String() string { return p.s }
+func (p *sampler) merge(s string) {
+ p.n++
+ if rand.Intn(p.n) == 0 {
+ p.s = s
+ }
+}
+
+type constant string
+
+func constf(init, arg string) agg { return constant(arg) }
+func (c constant) String() string { return string(c) }
+func (c constant) merge(string) {}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/text-0.0.0+git20150520.e373e13/wrap.go
new/text-0.0.0+git20160504.7cafcd8/wrap.go
--- old/text-0.0.0+git20150520.e373e13/wrap.go 2015-07-12 12:08:19.000000000
+0200
+++ new/text-0.0.0+git20160504.7cafcd8/wrap.go 2016-05-05 01:40:17.000000000
+0200
@@ -58,7 +58,7 @@
cost[i] = math.MaxInt32
}
for i := n - 1; i >= 0; i-- {
- if length[i][n-1] <= lim {
+ if length[i][n-1] <= lim || i == n-1 {
cost[i] = 0
nbrk[i] = n
} else {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/text-0.0.0+git20150520.e373e13/wrap_test.go
new/text-0.0.0+git20160504.7cafcd8/wrap_test.go
--- old/text-0.0.0+git20150520.e373e13/wrap_test.go 2015-07-12
12:08:19.000000000 +0200
+++ new/text-0.0.0+git20160504.7cafcd8/wrap_test.go 2016-05-05
01:40:17.000000000 +0200
@@ -42,3 +42,21 @@
t.Fail()
}
}
+
+func TestWrapBug1(t *testing.T) {
+ cases := []struct {
+ limit int
+ text string
+ want string
+ }{
+ {4, "aaaaa", "aaaaa"},
+ {4, "a aaaaa", "a\naaaaa"},
+ }
+
+ for _, test := range cases {
+ got := Wrap(test.text, test.limit)
+ if got != test.want {
+ t.Errorf("Wrap(%q, %d) = %q want %q", test.text,
test.limit, got, test.want)
+ }
+ }
+}