def getCreationDate(tag): lineNumber = getLineNumber(tag) (originalLineNumber, originalCommit) = getOriginalLineNumber(lineNumber) command = "git show -s --format=\"%ct\" " + str(originalCommit) (output, error) = general.execute(command) return (output.strip(), originalCommit)
def updateLineCounts(): (connection, cursor) = general.connect() command = "wc -l *.tex" (output, error) = general.execute(command) for line in filter(None, output.split("\n")): (linecount, filename) = line.split() update("linecount " + filename, linecount, cursor) general.close(connection)
def updatePageCounts(): (connection, cursor) = general.connect() command = "ls tags/tmp/*.log" (output, error) = general.execute(command) for filename in filter(None, output.split("\n")): f = open(config.websiteProject + "/" + filename) for line in f: if "Output written on " in line: update("pagecount " + filename.split("/")[-1].split(".")[0], line.split(" ")[4][1:], cursor) general.close(connection)
def getOriginalLineNumber(lineNumber, start = "HEAD"): # assuming it is always on the first line command = "git blame -L" + str(lineNumber) + ",+1 " + str(start) + " tags/tags -n -p" (output, error) = general.execute(command) # we get an error, which means that the line didn't exist, ergo it was added in this commit if error != "": return (lineNumber, start) # these are on the first line previousNumber = output.split("\n")[0].split(" ")[1] # this one is prefixed previous previousCommit = filter(lambda s: s[0:8] == "previous", output.split("\n")) # we've gone all the way to the original tags file if previousCommit == []: return (previousNumber, output.split("\n")[0].split(" ")[0].strip()) else: return getOriginalLineNumber(previousNumber, previousCommit[0].split(" ")[1].strip())
def updateCommits(): (connection, cursor) = general.connect() (what, error) = general.execute("git whatchanged --reverse -p tags/tags") creation = {} modified = {} for line in what.split("\n"): if line == "": continue if line.find('commit') == 0: commit = line[7:] new = 1 continue if line.find('Date') == 0: date = line[12:] continue if line.find('#') >= 0: continue if line.find('@@') == 0: new = 0 continue if new == 0: c = line[0] if not c == '+': continue line = line.lstrip(c) tag = line.split(',')[0] label = line.split(',')[1] if tag not in creation: creation[tag] = [date, commit] modified[tag] = [date, commit] tags = getTags(cursor) for tag in tags: updateCommitInformation(tag, creation[tag], modified[tag], cursor) general.close(connection)
def getModificationDate(tag): lineNumber = getLineNumber(tag) command = "git blame -L" + str(lineNumber) + ",+1 tags/tags -p" (output, error) = general.execute(command) return (filter(lambda s: s[0:11] == "author-time", output.split("\n"))[0].split(" ")[1], output.split("\n")[0].split(" ")[0])