summaryrefslogtreecommitdiff
path: root/morphlib/git.py
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@codethink.co.uk>2013-09-02 12:42:48 +0000
committerRichard Maw <richard.maw@codethink.co.uk>2013-09-05 09:46:37 +0000
commit400f77f81bc02c7c56f67f93d9eb53cbd08bf53d (patch)
treeb811532c429fd7deaabeae763056eff02204773a /morphlib/git.py
parente59906299a9f3bbbe316af9c288396d8424cd575 (diff)
downloadmorph-400f77f81bc02c7c56f67f93d9eb53cbd08bf53d.tar.gz
morphlib.git: Refactor is_valid_sha1
It now uses a generator expression instead of a list, which makes the operation lazy. It also uses string.hexdigits instead of redefining it.
Diffstat (limited to 'morphlib/git.py')
-rw-r--r--morphlib/git.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/morphlib/git.py b/morphlib/git.py
index 4ff08a72..27146206 100644
--- a/morphlib/git.py
+++ b/morphlib/git.py
@@ -20,6 +20,7 @@ import ConfigParser
import logging
import os
import re
+import string
import StringIO
import time
@@ -311,8 +312,7 @@ def clone_into(runcmd, srcpath, targetpath, ref=None):
def is_valid_sha1(ref):
'''Checks whether a string is a valid SHA1.'''
- valid_chars = 'abcdefABCDEF0123456789'
- return len(ref) == 40 and all([x in valid_chars for x in ref])
+ return len(ref) == 40 and all(x in string.hexdigits for x in ref)
def rev_parse(runcmd, gitdir, ref):
'''Find the sha1 for the given ref'''