Creating a patch/es

From Joomla! Documentation

Revision as of 21:08, 26 October 2015 by Abulafia (talk | contribs) (Created page with "Si tienes Subclipse y Eclipse puedes comprobar un nuevo proyecto desde Joomla! SVN (cuya rama/liberación es relevante para el fallo) y, a continuación, utiliza esta opción...")

Una parte importante de la creación de un parche para Joomla! es asegurarse que has conseguido crear todo correctamente. Como un estándar todos los parches deben ser creados en la raíz de tu sitio Joomla!. De esta manera, cuando llegamos a probarlo, no necesitamos averiguar en qué directorio debe estar el archivo que se está tratando de cambiar o modificar tu fichero de parche para que funcione correctamente en nuestro sistema local. Esto puede ser un problema, porque si el parche sólo cambia un archivo, puede haber un archivo con ese nombre. Por ejemplo, recientemente hemos recibido un parche para un archivo llamado banner.php. Hay cinco diferentes archivos de Joomla! que se llaman banner.php, así que tenemos que adivinar a que archivo es al que se hace referencia en este caso en particular.

Crear un parche en la línea de comandos

Para los usuarios de Linux/Mac, el uso de la línea de comandos es a menudo la manera más rápida de crear un parche. Dependiendo de cuantos cambios se hayan realizado en tu instalación local podrías tener un par de cambios diferentes. El mejor método para evitar esto es tener una instalación limpia de Joomla! obtenidad desde el SVN y, a continuación, realiza los cambios en este. A continuación, en la raíz del Joomla!, ejecuta el siguiente comando:

svn diff > file.patch

Necesitas asegurarte que sólo los cambios se han hecho en el archivo y no cualquier otro cambio irrelevante. Si no puedes hacer esto, debes especificar que archivos ha cambiado como parte del parche:

svn diff libraries/joomla/database/table.php > jtable.patch

Asegúrate que estás en el directorio raíz de Joomla!, no en el directorio de los archivos (podrás ver las carpetas como libraries, administrator, plugins, components, modules, etc).

Crear un parche utilizando Eclipse

Si tienes Subclipse y Eclipse puedes comprobar un nuevo proyecto desde Joomla! SVN (cuya rama/liberación es relevante para el fallo) y, a continuación, utiliza esta opción para crear un archivo del parche. Ten en cuenta que, de forma predeterminada, Eclipse crea parches que incluyen la ruta completa a los archivos, que no es lo que queremos. Suponiendo que has creado un nuevo proyecto mediante el uso de SVN y utilizas la raíz de un sitio Joomla!, deberías ser capaz de crear un parche válido fácilmente.

To create a patch, select the files you have changed and then right click on one of them and select "Team > Create Patch". The first screen asks you where you want to put the file: the clipboard, into the filesystem or in the workspace. Typically you'll want to create it somewhere in the filesystem. I personally use a patch folder where I keep all of the patches that I make. You should also notice at the bottom of this screen the list of files that will be included in this patch. If you have included files you didn't want to, you can deselect them here. If you are missing a file from this list you will need to reselect your files and add them.

Once you have worked out where you are going to put the patch and that you've selected the right files, click "Next" to continue. If you click "Finish" here your patch will be created incorrect so it is important that you click "Next" here. In this area select "Project" and then click "Finish" to create the patch. Doing this will ensure that your patch file is created properly.

Creating a patch using NetBeans

You can use NetBeans IDE to create patch files too. There's a video that explains how to create a patch for Joomla! with SVN: http://www.vimeo.com/11981229.

Line endings and encodings

It is important that with anything you add that you are using the correct line endings. The line ending style for Joomla! is just line feeds or Unix style, and all files should use the UTF-8 encoding. If you are using Eclipse you can change your settings in Window -> Preferences -> General -> Workspace. Select your text file encoding as UTF-8 and your line delimiter as "Unix".