Skip to content

Commit 4c89f14

Browse files
fix: Exception on initial key imports
1 parent c8b0147 commit 4c89f14

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/)
55
and this project adheres to [Semantic Versioning](http://semver.org/).
66

7+
# 0.9.4 - 2019-05-12
8+
## Added
9+
10+
## Fixed
11+
- Handling of HTTP errors
12+
- Domain names in tests
13+
14+
## Changed
15+
16+
717
# 0.9.3 - 2019-05-12
818
## Added
919
- Default server set to `https://gitta.enotar.ch`; can be changed with

git_timestamp/timestamp.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
import pygit2 as git
3636
import requests
3737

38-
VERSION = '0.9.3'
38+
VERSION = '0.9.4'
3939

4040

4141
class GitArgumentParser(argparse.ArgumentParser):
@@ -179,7 +179,7 @@ def get_keyid(server):
179179
# Obtain key in TOFU fashion and remember keyid
180180
r = requests.get(server, params={'request': 'get-public-key-v1'},
181181
timeout=30)
182-
quit_if_http_error(args, r)
182+
quit_if_http_error(server, r)
183183
(keyid, name) = validate_key_and_import(r.text)
184184
gcfg = git.Config.get_global_config()
185185
gcfg['timestamper.%s.keyid' % key] = keyid
@@ -270,12 +270,12 @@ def validate_tag(text, commit, keyid, name, args):
270270
else:
271271
sys.exit("No OpenPGP signature found")
272272

273-
def quit_if_http_error(args, r):
273+
def quit_if_http_error(server, r):
274274
if r.status_code == 301:
275275
sys.exit("Timestamping server URL changed from %s to %s\n"
276276
"Please change this on the command line(s) or run\n"
277277
" git config [--global] timestamp.server %s"
278-
% (args.server, r.headers['Location'], r.headers['Location']))
278+
% (server, r.headers['Location'], r.headers['Location']))
279279
if r.status_code != 200:
280280
sys.exit("Timestamping request failed; server responded with %d %s"
281281
% (r.status_code, r.reason))
@@ -297,7 +297,7 @@ def timestamp_tag(repo, commit, keyid, name, args):
297297
'commit': commit.id,
298298
'tagname': args.tag
299299
}, allow_redirects=False)
300-
quit_if_http_error(args, r)
300+
quit_if_http_error(args.server, r)
301301
validate_tag(r.text, commit, keyid, name, args)
302302
tagid = repo.write(git.GIT_OBJ_TAG, r.text)
303303
repo.create_reference('refs/tags/%s' % args.tag, tagid)
@@ -363,7 +363,7 @@ def timestamp_branch(repo, commit, keyid, name, args):
363363
pass
364364
try:
365365
r = requests.post(args.server, data=data, allow_redirects=False)
366-
quit_if_http_error(args, r)
366+
quit_if_http_error(args.server, r)
367367
validate_branch(r.text, keyid, name, data, args)
368368
commitid = repo.write(git.GIT_OBJ_COMMIT, r.text)
369369
repo.create_reference('refs/heads/' + args.branch, commitid, force=True)

0 commit comments

Comments
 (0)