Skip to content

Commit ce52252

Browse files
committed
Clean up bookmark comments implementation and document
1 parent 7d03fb9 commit ce52252

File tree

3 files changed

+10
-23
lines changed

3 files changed

+10
-23
lines changed

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
v0.6 (unreleased):
22

3+
- Support simple comments in the bookmarks file. (#51)
34
- Add an integrated pytest testing suite, runnable with `--selftest`.
45
- Refactor internals, remove deprecated options, and drop support for
56
end-of-life Python versions.

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (C) 2011-2018 Ben Kurtovic <[email protected]>
1+
Copyright (C) 2011-2019 Ben Kurtovic <[email protected]>
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy
44
of this software and associated documentation files (the "Software"), to deal

gitup/update.py

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -259,15 +259,14 @@ def _get_basename(base, path):
259259
except exc.NoSuchPathError:
260260
if is_comment(base):
261261
comment = get_comment(base)
262-
if len(comment) > 0:
262+
if comment:
263263
print(CYAN + BOLD + comment)
264264
return
265-
else:
266-
paths = glob(base)
267-
if not paths:
268-
print(ERROR, BOLD + base, "doesn't exist!")
269-
return
270-
valid = _collect(paths, max_depth)
265+
paths = glob(base)
266+
if not paths:
267+
print(ERROR, BOLD + base, "doesn't exist!")
268+
return
269+
valid = _collect(paths, max_depth)
271270
except exc.InvalidGitRepositoryError:
272271
if not os.path.isdir(base) or args.max_depth == 0:
273272
print(ERROR, BOLD + base, "isn't a repository!")
@@ -285,24 +284,11 @@ def _get_basename(base, path):
285284

286285
def is_comment(path):
287286
"""Does the line start with a # symbol?"""
288-
cs = path.lstrip()
289-
if cs[0] == "#":
290-
return True
291-
return False
287+
return path.lstrip().startswith("#")
292288

293289
def get_comment(path):
294290
"""Return the string minus the comment symbol."""
295-
rs = ""
296-
cs = path.lstrip()
297-
if len(cs) > 0:
298-
for j in range(0, len(cs)):
299-
c = cs[j]
300-
if c == "#" and len(rs) == 0:
301-
continue
302-
rs = rs + c
303-
if len(rs) > 0:
304-
rs = rs.lstrip()
305-
return rs
291+
return path.lstrip().lstrip("#").strip()
306292

307293
def update_bookmarks(bookmarks, args):
308294
"""Loop through and update all bookmarks."""

0 commit comments

Comments
 (0)