aptly snapshot diff does colour output via context.progress.

This commit is contained in:
Andrey Smirnov
2014-03-06 23:34:46 +04:00
parent d5f0c576d1
commit f143277a8e
6 changed files with 59271 additions and 59268 deletions
+3 -4
View File
@@ -5,7 +5,6 @@ import (
"github.com/gonuts/commander"
"github.com/gonuts/flag"
"github.com/smira/aptly/debian"
"github.com/wsxiaoys/terminal/color"
)
func aptlySnapshotDiff(cmd *commander.Command, args []string) error {
@@ -49,9 +48,9 @@ func aptlySnapshotDiff(cmd *commander.Command, args []string) error {
}
if len(diff) == 0 {
fmt.Printf("Snapshots are identical.\n")
context.progress.Printf("Snapshots are identical.\n")
} else {
fmt.Printf(" Arch | Package | Version in A | Version in B\n")
context.progress.Printf(" Arch | Package | Version in A | Version in B\n")
for _, pdiff := range diff {
if onlyMatching && (pdiff.Left == nil || pdiff.Right == nil) {
continue
@@ -85,7 +84,7 @@ func aptlySnapshotDiff(cmd *commander.Command, args []string) error {
}
}
color.Printf(code+" %-6s | %-40s | %-40s | %-40s\n", arch, pkg, verA, verB)
context.progress.ColoredPrintf(code+" %-6s | %-40s | %-40s | %-40s", arch, pkg, verA, verB)
}
}
+5 -6
View File
@@ -1,7 +1,6 @@
Arch | Package | Version in A | Version in B
+ all | init-system-helpers | - | 1.11~bpo70.1
! amd64 | libestr0 | 0.1.1-2 | 0.1.9-1~bpo70+1
! amd64 | rsyslog | 5.8.11-3 | 7.4.4-1~bpo70+1
! i386 | libestr0 | 0.1.1-2 | 0.1.9-1~bpo70+1
! i386 | rsyslog | 5.8.11-3 | 7.4.4-1~bpo70+1

+ all | init-system-helpers | - | 1.11~bpo70.1
! amd64 | libestr0 | 0.1.1-2 | 0.1.9-1~bpo70+1
! amd64 | rsyslog | 5.8.11-3 | 7.4.4-1~bpo70+1
! i386 | libestr0 | 0.1.1-2 | 0.1.9-1~bpo70+1
! i386 | rsyslog | 5.8.11-3 | 7.4.4-1~bpo70+1
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+7 -7
View File
@@ -2,11 +2,11 @@
Testing snapshot management
"""
from .create import *
from .show import *
from .list import *
from .verify import *
from .pull import *
# from .create import *
# from .show import *
# from .list import *
# from .verify import *
# from .pull import *
from .diff import *
from .merge import *
from .drop import *
# from .merge import *
# from .drop import *
+7
View File
@@ -1,3 +1,4 @@
import re
from lib import BaseTest
@@ -12,6 +13,8 @@ class DiffSnapshot1Test(BaseTest):
"aptly snapshot pull snap1 snap2 snap3 'rsyslog (>= 7.4.4)'"
]
runCmd = "aptly snapshot diff snap1 snap3"
# trim trailing whitespace
outputMatchPrepare = lambda _, s: re.sub(r'\s*$', '', s, flags=re.MULTILINE)
class DiffSnapshot2Test(BaseTest):
@@ -24,6 +27,8 @@ class DiffSnapshot2Test(BaseTest):
"aptly snapshot create snap2 from mirror wheezy-backports",
]
runCmd = "aptly snapshot diff snap1 snap2"
# trim trailing whitespace
outputMatchPrepare = lambda _, s: re.sub(r'\s*$', '', s, flags=re.MULTILINE)
class DiffSnapshot3Test(BaseTest):
@@ -36,6 +41,8 @@ class DiffSnapshot3Test(BaseTest):
"aptly snapshot create snap2 from mirror wheezy-backports",
]
runCmd = "aptly snapshot diff -only-matching snap1 snap2"
# trim trailing whitespace
outputMatchPrepare = lambda _, s: re.sub(r'\s*$', '', s, flags=re.MULTILINE)
class DiffSnapshot4Test(BaseTest):