How to use the dbutils.Branch.fromName function in DBUtils

To help you get started, we’ve selected a few DBUtils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jensl / critic / src / dbutils / review.py View on Github external
def fromName(db, repository, name):
        from dbutils import Branch
        return Review.fromBranch(db, Branch.fromName(db, repository, name))
github jensl / critic / src / gitutils.py View on Github external
if head_branch:
            yield head_branch
        cursor = db.cursor()
        cursor.execute(
            """SELECT local_name
                 FROM trackedbranches
                 JOIN branches ON (branches.repository=trackedbranches.repository
                               AND branches.name=trackedbranches.local_name)
                WHERE branches.repository=%s
                  AND branches.type='normal'
             ORDER BY trackedbranches.id ASC""",
                       (self.id,))
        for (branch_name,) in cursor:
            if head_branch and head_branch.name == branch_name:
                continue
            yield dbutils.Branch.fromName(db, self, branch_name)
github jensl / critic / src / index.py View on Github external
def createBranch(db, user, repository, name, head, multiple, flags):
    try:
        update(repository.path, "refs/heads/" + name, None, head)
    except Reject as rejected:
        raise IndexException(str(rejected))
    except Exception:
        pass

    cursor = db.cursor()

    # Check if a branch with this name already "exists".
    branch = dbutils.Branch.fromName(db, repository, name, load_review=True)
    if branch is not None:
        if branch.archived:
            # This is a (review) branch that has been archived.  It's expected
            # that Git thinks the user is creating a new branch.
            message = """\
This repository already contains a branch named '%s', but it has been archived,
meaning it has been hidden from view to reduce the number of visible refs in
this repository.""" % name

            if branch.review:
                message += """

To continue working on this branch, you need to first reopen the review that is
associated with the branch.  You can do this from the review's front-page:

%s""" % branch.review.getURL(db, user, indent=2)