<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_signature(self, base_commit=None):
 """Get the signature of the current state of the repository TODO right now `get_signature` is an effectful process in that it adds all untracked file to staging. This is the only way to get accruate diff on new files. This is ok because we only use it on a disposable copy of the repo. Args: base_commit - the base commit ('HEAD', sha, etc.) Returns: str """

        if base_commit is None:
            base_commit = 'HEAD'
        self.run('add', '-A', self.path)
        sha = self.run('rev-parse', '--verify', base_commit).strip()
        diff = self.run('diff', sha).strip()
        if len(diff) == 0:
            try:
                return self.get_signature(base_commit + '~1')
            except CommandError:
                pass
        h = hashlib.sha1()
        h.update(sha)
        h.update(diff)
        return h.hexdigest()