Ejemplo n.º 1
0
def test_git_log():
    host, owner, repo = gitutil.parse_giturl(REPO_URL)
    t_en = gitutil.git_log(os.path.join(REPO_EN, repo))
    t_cn = gitutil.git_log(os.path.join(REPO_CN, repo))
    expect = [(u'e744949159ecea5a9f68a1715e8d1e4fafd87dea', u'guyskk', u'*****@*****.**', u'Sun Sep 27 15:24:39 2015 +0800', u'add md'),
              (u'1a1bba5d3c2a4958644e4bbfb1a4ebb8abfafd23', u'kk', u'*****@*****.**', u'Sun Sep 27 11:51:26 2015 +0800', u'Initial commit')]
    assert len(t_en) >= 2
    assert t_en[-2:] == expect
    assert t_cn == t_en
Ejemplo n.º 2
0
def update(user_id, local=False, rebuild=False):
    with db_session:
        u = model.BlogUser.get(user_id=user_id)
        if not u:
            abort(404, "bloguser %s not exists" % user_id)
        repo_url = u.article_repo
        old_commit = u.latest_commit
        gitname = u.gitname
    if rebuild:
        clear_db(gitname)
        old_commit = ""
    msg = "local"
    err = None
    if not local:
        __, owner, __ = gitutil.parse_giturl(repo_url)
        err, ret = update_local(repo_url, owner)
        msg = unicode(err) if err else ret
    if not err:
        mddir = get_mddir(repo_url)
        update_db(mddir, gitname, old_commit)
        logs = gitutil.git_log(mddir)
        if logs:
            latest_commit = logs[0][0]
            with db_session:
                u = model.BlogUser.get(user_id=user_id)
                u.latest_commit = latest_commit
    return err, msg
Ejemplo n.º 3
0
def print_changes(repo_path, since_rev, until_rev):
    os.chdir(repo_path)
    if since_rev != until_rev:
        log = gitutil.git_log(since_rev, until_rev)
        tickets = find_tickets(log)
        if not tickets:
            print("   Changed but no tickets resolved")
        else:
            for ticket in tickets:
                print("  %s" % ticket.decode('utf-8'))
    else:
        print("   No changes")