Exemplo n.º 1
0
    def delete_page(self, name, username=None, email=None, message=None):
        """Delete page.
        :param name: Page that will be deleted
        :param username: Committer name
        :param email: Committer email
        :return: str -- Commit sha1

        """

        username, email = self._get_user(username, email)

        if not message:
            message = "Deleted %s" % name

        filename = cname_to_filename(name)

        # gittle.rm won't actually remove the file, have to do it ourselves
        os.remove(os.path.join(self.path, filename))
        self.gittle.rm(filename)
        commit = self.gittle.commit(name=username,
                                    email=email,
                                    message=message,
                                    files=[filename])
        cache.delete_many(self._cache_key(name))
        return commit
Exemplo n.º 2
0
    def delete_page(self, name, username=None, email=None, message=None):
        """Delete page.
        :param name: Page that will be deleted
        :param username: Committer name
        :param email: Committer email
        :return: str -- Commit sha1

        """

        username, email = self._get_user(username, email)

        if not message:
            message = "Deleted %s" % name

        filename = cname_to_filename(name)

        # gittle.rm won't actually remove the file, have to do it ourselves
        os.remove(os.path.join(self.path, filename))
        self.gittle.rm(filename)
        commit = self.gittle.commit(name=username,
                                    email=email,
                                    message=message,
                                    files=[filename])
        cache.delete_many(name)
        return commit
Exemplo n.º 3
0
 def rename_page(self, old_name, new_name):
     old_name, new_name = map(self.cname_to_filename, [old_name, new_name])
     self.repo.mv([(old_name, new_name)])
     self.repo.commit(
         name=self.default_committer_name,
         email=self.default_committer_email,
         message="Moving %s to %s" % (old_name, new_name),
         files=[old_name],
     )
     cache.delete_many(old_name, new_name)
Exemplo n.º 4
0
    def rename_page(self,
                    old_name,
                    new_name,
                    username=None,
                    email=None,
                    message=None):
        """Rename page.

        :param old_name: Page that will be renamed.
        :param new_name: New name of page.
        :param username: Committer name
        :param email: Committer email
        :return: str -- Commit sha1

        """
        old_filename, new_filename = map(cname_to_filename,
                                         [old_name, new_name])
        if old_filename not in self.gittle.index:
            # old doesn't exist
            return None

        if old_filename == new_filename:
            return

        if new_filename in self.gittle.index:
            # file is being overwritten, but that is ok, it's git!
            pass

        username, email = self._get_user(username, email)

        if not message:
            message = "Moved %s to %s" % (old_name, new_name)

        os.rename(os.path.join(self.path, old_filename),
                  os.path.join(self.path, new_filename))

        self.gittle.add(new_filename)
        self.gittle.rm(old_filename)

        commit = self.gittle.commit(name=username,
                                    email=email,
                                    message=message,
                                    files=[old_filename, new_filename])

        cache.delete_many(self._cache_key(old_name), self._cache_key(new_name))

        return commit
Exemplo n.º 5
0
    def rename_page(self, old_name, new_name, user=None):
        old_filename, new_filename = map(cname_to_filename, [old_name, new_name])
        if old_filename not in self.gittle.index:
            # old doesn't exist
            return None

        if new_filename in self.gittle.index:
            # file is being overwritten, but that is ok, it's git!
            pass

        os.rename(os.path.join(self.path, old_filename), os.path.join(self.path, new_filename))

        self.gittle.add(new_filename)
        self.gittle.rm(old_filename)

        self.gittle.commit(name=getattr(user, 'username', self.default_committer_name),
                           email=getattr(user, 'email', self.default_committer_email),
                           message="Moved %s to %s" % (old_name, new_name),
                           files=[old_filename, new_filename])

        cache.delete_many(old_filename, new_filename)
Exemplo n.º 6
0
    def rename_page(self, old_name, new_name, username=None, email=None, message=None):
        """Rename page.

        :param old_name: Page that will be renamed.
        :param new_name: New name of page.
        :param username: Committer name
        :param email: Committer email
        :return: str -- Commit sha1

        """
        old_filename, new_filename = map(cname_to_filename, [old_name, new_name])
        if old_filename not in self.gittle.index:
            # old doesn't exist
            return None

        if old_filename == new_filename:
            return

        if new_filename in self.gittle.index:
            # file is being overwritten, but that is ok, it's git!
            pass

        username, email = self._get_user(username, email)

        if not message:
            message = "Moved %s to %s" % (old_name, new_name)

        os.rename(os.path.join(self.path, old_filename), os.path.join(self.path, new_filename))

        self.gittle.add(new_filename)
        self.gittle.rm(old_filename)

        commit = self.gittle.commit(name=username,
                                    email=email,
                                    message=message,
                                    files=[old_filename, new_filename])

        cache.delete_many(old_name, new_name)

        return commit
Exemplo n.º 7
0
    def delete_page(self, name, username=None, email=None, message=None):
        """Delete page.
        :param name: Page that will be deleted
        :param username: Committer name
        :param email: Committer email
        :return: str -- Commit sha1

        """

        username, email = self._get_user(username, email)

        if not message:
            message = "Deleted %s" % name

        filename = cname_to_filename(name)
        self.gittle.rm(filename)
        commit = self.gittle.commit(name=username,
                                    email=email,
                                    message=message,
                                    files=[str(filename)])
        cache.delete_many(name)
        return commit
Exemplo n.º 8
0
    def delete_page(self, name, username=None, email=None, message=None):
        """Delete page.
        :param name: Page that will be deleted
        :param username: Committer name
        :param email: Committer email
        :return: str -- Commit sha1

        """

        username, email = self._get_user(username, email)

        if not message:
            message = "Deleted %s" % name

        filename = cname_to_filename(name)
        self.gittle.rm(filename)
        commit = self.gittle.commit(name=username,
                                    email=email,
                                    message=message,
                                    files=[str(filename)])
        cache.delete_many(name)
        return commit