)]}'
{"api-ref/source/conf.py":[{"author":{"_account_id":20764,"name":"Sachin","email":"psachin@redhat.com","username":"psachin"},"change_message_id":"28621936a360120a6b33e38a33ffdd3123215a6d","unresolved":false,"context_lines":[{"line_number":161,"context_line":"git_cmd \u003d [\"git\", \"log\", \"--pretty\u003dformat:\u0027%ad, commit %h\u0027\", \"--date\u003dlocal\","},{"line_number":162,"context_line":"           \"-n1\"]"},{"line_number":163,"context_line":"try:"},{"line_number":164,"context_line":"    html_last_updated_fmt \u003d subprocess.check_output(git_cmd).decode(\u0027utf-8\u0027)"},{"line_number":165,"context_line":"except OSError:"},{"line_number":166,"context_line":"    warnings.warn(\u0027Cannot get last updated time from git repository. \u0027"},{"line_number":167,"context_line":"                  \u0027Not setting \"html_last_updated_fmt\".\u0027)"}],"source_content_type":"text/x-python","patch_set":1,"id":"9f0e0f27_37dc7845","line":164,"updated":"2017-06-09 06:57:17.000000000","message":"I get following error if I try to run this code snippet when we have no commits\n\n~~~\nfatal: your current branch \u0027master\u0027 does not have any commits yet\nTraceback (most recent call last):\n  File \"../gerrit-review-472534.py\", line 8, in \u003cmodule\u003e\n    h \u003d subprocess.check_output(git_cmd).decode(\u0027utf-8\u0027)\n  File \"/usr/lib64/python3.5/subprocess.py\", line 316, in check_output\n    **kwargs).stdout\n  File \"/usr/lib64/python3.5/subprocess.py\", line 398, in run\n    output\u003dstdout, stderr\u003dstderr)\nsubprocess.CalledProcessError: Command \u0027[\u0027git\u0027, \u0027log\u0027, \"--pretty\u003dformat:\u0027%ad, commit %h\u0027\", \u0027--date\u003dlocal\u0027, \u0027-n1\u0027]\u0027 returned non-zero exit status 128\n~~~\n\nWhereas old code just works fine:\n\nSuggestion:\n~~~\ntry:\n    h \u003d subprocess.check_output(git_cmd).decode(\u0027utf-8\u0027)\nexcept subprocess.CalledProcessError:\n    warnings.warn(\"Cannot get..\")\n~~~","commit_id":"5c4f490547dcc8443e987ed032208b9d21f4f3a5"}]}
