def commitpofile(self, request, store): """commits an individual PO file to version control""" if not check_permission("commit", request): raise PermissionDenied(_("You do not have rights to commit files here")) store.sync(update_structure=True, update_translation=True, conservative=False) stats = store.getquickstats() author = request.user.username message = stats_message("Commit from %s by user %s." % (settings.TITLE, author), stats) # Try to append email as well, since some VCS does not allow omitting it (ie. Git). if request.user.is_authenticated() and len(request.user.email): author += " <%s>" % request.user.email try: filestocommit = hooks.hook(self.project.code, "precommit", store.file.path, author=author, message=message) except ImportError: # Failed to import the hook - we're going to assume there just isn't a hook to # import. That means we'll commit the original file. filestocommit = [store.file.path] success = True try: for file in filestocommit: versioncontrol.commitfile(file, message=message, author=author) request.user.message_set.create(message="Committed file: <em>%s</em>" % file) except Exception, e: logging.error("Failed to commit files: %s", e) request.user.message_set.create(message="Failed to commit file: %s" % e) success = False
def commitpofile(self, user, store): """Commits an individual file to version control. This does not do permission checking. """ store.sync(update_structure=False, update_translation=True, conservative=True) stats = store.getquickstats() author = user.username message = stats_message("Commit from %s by user %s." % (settings.TITLE, author), stats) # Try to append email as well, since some VCS does not allow omitting it (ie. Git). if user.is_authenticated() and len(user.email): author += " <%s>" % user.email from pootle.scripts import hooks try: filestocommit = hooks.hook(self.project.code, "precommit", store.file.path, author=author, message=message) except ImportError: # Failed to import the hook - we're going to assume there just isn't a hook to # import. That means we'll commit the original file. filestocommit = [store.file.path] success = True try: from translate.storage import versioncontrol for file in filestocommit: versioncontrol.commitfile(file, message=message, author=author) user.message_set.create(message="Committed file: <em>%s</em>" % file) except Exception, e: logging.error(u"Failed to commit files: %s", e) user.message_set.create(message="Failed to commit file: %s" % e) success = False
def commitpofile(self, request, store): """commits an individual PO file to version control""" #FIXME: this is a view what is it doing here if not check_permission("commit", request): raise PermissionDenied( _("You do not have rights to commit files here")) store.sync(update_structure=False, update_translation=True, conservative=True) stats = store.getquickstats() author = request.user.username message = stats_message( "Commit from %s by user %s." % (settings.TITLE, author), stats) # Try to append email as well, since some VCS does not allow omitting it (ie. Git). if request.user.is_authenticated() and len(request.user.email): author += " <%s>" % request.user.email try: filestocommit = hooks.hook(self.project.code, "precommit", store.file.path, author=author, message=message) except ImportError: # Failed to import the hook - we're going to assume there just isn't a hook to # import. That means we'll commit the original file. filestocommit = [store.file.path] success = True try: for file in filestocommit: versioncontrol.commitfile(file, message=message, author=author) request.user.message_set.create( message="Committed file: <em>%s</em>" % file) except Exception, e: logging.error(u"Failed to commit files: %s", e) request.user.message_set.create( message="Failed to commit file: %s" % e) success = False
def commitpofile(self, user, store): """Commits an individual file to version control. This does not do permission checking. """ store.sync(update_structure=False, update_translation=True, conservative=True) stats = store.getquickstats() author = user.username message = stats_message( "Commit from %s by user %s." % (settings.TITLE, author), stats) # Try to append email as well, since some VCS does not allow omitting it (ie. Git). if user.is_authenticated() and len(user.email): author += " <%s>" % user.email from pootle.scripts import hooks try: filestocommit = hooks.hook(self.project.code, "precommit", store.file.path, author=author, message=message) except ImportError: # Failed to import the hook - we're going to assume there just isn't a hook to # import. That means we'll commit the original file. filestocommit = [store.file.path] success = True try: from translate.storage import versioncontrol for file in filestocommit: versioncontrol.commitfile(file, message=message, author=author) user.message_set.create(message="Committed file: <em>%s</em>" % file) except Exception, e: logging.error(u"Failed to commit files: %s", e) user.message_set.create(message="Failed to commit file: %s" % e) success = False
def commit_file(path, message, author): vcs_path = to_vcs_path(path) path = to_podir_path(path) shutil.copy2(path, vcs_path) versioncontrol.commitfile(vcs_path, message=message, author=author)