aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/names.py
diff options
context:
space:
mode:
Diffstat (limited to 'libbe/names.py')
-rw-r--r--libbe/names.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/libbe/names.py b/libbe/names.py
index d2e077a..c86063d 100644
--- a/libbe/names.py
+++ b/libbe/names.py
@@ -35,3 +35,21 @@ def creator():
return os.environ["LOGNAME"]
else:
return os.environ["USERNAME"]
+
+def unique_name(bug, bugs):
+ """
+ Generate short names from uuids. Picks the minimum number of
+ characters (>=3) from the beginning of the uuid such that the
+ short names are unique.
+
+ Obviously, as the number of bugs in the database grows, these
+ short names will cease to be unique. The complete uuid should be
+ used for long term reference.
+ """
+ chars = 3
+ for some_bug in bugs:
+ if bug.uuid == some_bug.uuid:
+ continue
+ while (bug.uuid[:chars] == some_bug.uuid[:chars]):
+ chars+=1
+ return bug.uuid[:chars]