示例#1
0
def get_changeset(ui, repo, revision, authors={}):
    node = repo.lookup(revision)
    (manifest, user, (time, timezone), files, desc,
     extra) = repo.changelog.read(node)
    tz = "%+03d%02d" % (-timezone / 3600, ((-timezone % 3600) / 60))
    branch = get_branch(extra.get('branch', 'master'))
    return (node, manifest, fixup_user(user, authors), (time, tz), files, desc,
            branch, extra)
def get_author(logmessage,committer,authors):
  """As git distincts between author and committer of a patch, try to
  extract author by detecting Signed-off-by lines.

  This walks from the end of the log message towards the top skipping
  empty lines. Upon the first non-empty line, it walks all Signed-off-by
  lines upwards to find the first one. For that (if found), it extracts
  authorship information the usual way (authors table, cleaning, etc.)

  If no Signed-off-by line is found, this defaults to the committer.

  This may sound stupid (and it somehow is), but in log messages we
  accidentially may have lines in the middle starting with
  "Signed-off-by: foo" and thus matching our detection regex. Prevent
  that."""

  loglines=logmessage.split('\n')
  i=len(loglines)
  # from tail walk to top skipping empty lines
  while i>=0:
    i-=1
    if len(loglines[i].strip())==0: continue
    break
  if i>=0:
    # walk further upwards to find first sob line, store in 'first'
    first=None
    while i>=0:
      m=sob_re.match(loglines[i])
      if m==None: break
      first=m
      i-=1
    # if the last non-empty line matches our Signed-Off-by regex: extract username
    if first!=None:
      r=fixup_user(first.group(1),authors)
      if r.find('>') < r.find('<'):
          return "Invalid User <*****@*****.**>"
      return r
  if committer.find('>') < committer.find('<'):
      return "Invalid User <*****@*****.**>"
  return committer
示例#3
0
def get_author(logmessage, committer, authors):
    """As git distincts between author and committer of a patch, try to
  extract author by detecting Signed-off-by lines.

  This walks from the end of the log message towards the top skipping
  empty lines. Upon the first non-empty line, it walks all Signed-off-by
  lines upwards to find the first one. For that (if found), it extracts
  authorship information the usual way (authors table, cleaning, etc.)

  If no Signed-off-by line is found, this defaults to the committer.

  This may sound stupid (and it somehow is), but in log messages we
  accidentially may have lines in the middle starting with
  "Signed-off-by: foo" and thus matching our detection regex. Prevent
  that."""

    loglines = logmessage.split(b'\n')
    i = len(loglines)
    # from tail walk to top skipping empty lines
    while i >= 0:
        i -= 1
        if len(loglines[i].strip()) == 0: continue
        break
    if i >= 0:
        # walk further upwards to find first sob line, store in 'first'
        first = None
        while i >= 0:
            m = sob_re.match(loglines[i])
            if m == None: break
            first = m
            i -= 1
        # if the last non-empty line matches our Signed-Off-by regex: extract username
        if first != None:
            r = fixup_user(first.group(1), authors)
            return r
    return committer
示例#4
0
def get_changeset(ui,repo,revision,authors={}):
  node=repo.lookup(revision)
  (manifest,user,(time,timezone),files,desc,extra)=repo.changelog.read(node)
  tz="%+03d%02d" % (-timezone / 3600, ((-timezone % 3600) / 60))
  branch=get_branch(extra.get('branch','master'))
  return (node,manifest,fixup_user(user,authors),(time,tz),files,desc,branch,extra)