Skip to content

Commit

Permalink
Merge pull request quiltdata#79 from quiltdata/log2
Browse files Browse the repository at this point in the history
quilt log prints reverse chrono, handles timestamps instead of datetime
  • Loading branch information
akarve authored Apr 18, 2017
2 parents e2d211e + fbe03e6 commit c30343e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions quilt/test/test_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
Tests for commands.
"""

from datetime import datetime
import json
import os
import pytest
import requests
import responses
import time

from six import assertRaisesRegex

Expand Down Expand Up @@ -149,7 +149,7 @@ def _mock_logs_list(self, owner, package, pkg_hash):
logs_url = "%s/api/log/%s/%s/" % (command.QUILT_PKG_URL, owner, package)
resp = dict(logs=[dict(
hash=pkg_hash,
created=str(datetime.now()),
created=time.time(),
author=owner)])
print("MOCKING URL=%s" % logs_url)
self.requests_mock.add(responses.GET, logs_url, json.dumps(resp))
10 changes: 6 additions & 4 deletions quilt/tools/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from __future__ import print_function
from builtins import input
import argparse
from datetime import datetime
import json
import os
import stat
Expand Down Expand Up @@ -203,10 +204,11 @@ def log(session, package):

format_str = "%-64s %-19s %s"

print(format_str % ("Hash", "Created", "Author"))
for entry in response.json()['logs']:
# TODO: convert "created" to local time.
print(format_str % (entry['hash'], entry['created'], entry['author']))
print(format_str % ("Hash", "Pushed", "Author"))
for entry in reversed(response.json()['logs']):
ugly = datetime.fromtimestamp(entry['created'])
nice = ugly.strftime("%Y-%m-%d %H:%M:%S")
print(format_str % (entry['hash'], nice, entry['author']))

def push(session, package):
"""
Expand Down

0 comments on commit c30343e

Please sign in to comment.