Exemplo n.º 1
0
    def gitPush(self, path, comment=None):
            # Announce changes to git
            cmd = Git(path)
            changed = False
            for line in cmd.status("--porcelain").splitlines():
                changed = True
                line = line.lstrip()
                self.log.info("staging changes for %s" % line.split(" ", 1)[1:])

                mode, file_path = line.split(" ", 1)
                file_path = os.path.join(*file_path.split("/")[0:])

                # Remove data?
                if mode == "D":
                    cmd.rm("-r", file_path)

                # Add data...
                else:
                    cmd.add(file_path)

            # No need to deal...
            if not changed:
                return False

            # Commit changes
            if not comment:
                comment = "Change made with no comment"

            self.log.info("committing changes for module %s" % path)
            cmd.commit("-m", comment)
            cmd.push("origin")

            return True