Download - Drupal Version Control & File System Basics
![Page 1: Drupal Version Control & File System Basics](https://reader034.vdocuments.net/reader034/viewer/2022052523/5552f2b1b4c90587048b4c06/html5/thumbnails/1.jpg)
Drupal Version Control & File System Basics
Julia Kulla-MaderTriangle Drupal User’s GroupMarch 17, 2010http://www.juliakm.com@juliakm
![Page 2: Drupal Version Control & File System Basics](https://reader034.vdocuments.net/reader034/viewer/2022052523/5552f2b1b4c90587048b4c06/html5/thumbnails/2.jpg)
What is version control?
• A way of managing changes to documents, programs, or other data stored as computer files. (Wikipedia)
![Page 3: Drupal Version Control & File System Basics](https://reader034.vdocuments.net/reader034/viewer/2022052523/5552f2b1b4c90587048b4c06/html5/thumbnails/3.jpg)
What are some version control systems?
![Page 4: Drupal Version Control & File System Basics](https://reader034.vdocuments.net/reader034/viewer/2022052523/5552f2b1b4c90587048b4c06/html5/thumbnails/4.jpg)
Why use version control?
• Real world scenarios
![Page 5: Drupal Version Control & File System Basics](https://reader034.vdocuments.net/reader034/viewer/2022052523/5552f2b1b4c90587048b4c06/html5/thumbnails/5.jpg)
Why am I getting a white screen of death?
• Version control lets you see what the most recent code change was on your site.
![Page 6: Drupal Version Control & File System Basics](https://reader034.vdocuments.net/reader034/viewer/2022052523/5552f2b1b4c90587048b4c06/html5/thumbnails/6.jpg)
Can I get rid of that white screen of death?
• Version control lets you roll back to a previous version.
![Page 7: Drupal Version Control & File System Basics](https://reader034.vdocuments.net/reader034/viewer/2022052523/5552f2b1b4c90587048b4c06/html5/thumbnails/7.jpg)
My client decided that they prefer a way earlier version of my module
• Version control lets you roll back a specific file to any point in time (when it was under version control).
![Page 8: Drupal Version Control & File System Basics](https://reader034.vdocuments.net/reader034/viewer/2022052523/5552f2b1b4c90587048b4c06/html5/thumbnails/8.jpg)
I really want to use this new module but I'm afraid it's going to destroy my site.
• Using version control, you can maintain multiple versions of your code. For example, you can create a sandbox (“trunk”) just for testing out experimental modules.
![Page 9: Drupal Version Control & File System Basics](https://reader034.vdocuments.net/reader034/viewer/2022052523/5552f2b1b4c90587048b4c06/html5/thumbnails/9.jpg)
My co-worker and I are editing the same page. What if we overwrite one another?
• Version control lets you merge changes when conflicts arise.
![Page 10: Drupal Version Control & File System Basics](https://reader034.vdocuments.net/reader034/viewer/2022052523/5552f2b1b4c90587048b4c06/html5/thumbnails/10.jpg)
Why the heck did I make this change last year?
• Version control lets you record log messages over time so that you can communicate with your old self.
![Page 11: Drupal Version Control & File System Basics](https://reader034.vdocuments.net/reader034/viewer/2022052523/5552f2b1b4c90587048b4c06/html5/thumbnails/11.jpg)
Who was the last person to touch this module?
• Version control lets to see the last person who edited a file.
![Page 12: Drupal Version Control & File System Basics](https://reader034.vdocuments.net/reader034/viewer/2022052523/5552f2b1b4c90587048b4c06/html5/thumbnails/12.jpg)
I want to quickly deploy my code on a new server.
• Version control makes it easy to quickly grab a repository and put in on your local computer or a new server.
![Page 13: Drupal Version Control & File System Basics](https://reader034.vdocuments.net/reader034/viewer/2022052523/5552f2b1b4c90587048b4c06/html5/thumbnails/13.jpg)
I'm sick of copying files from my computer to the server.
• Using “hooks” you can set up you server to automatically reflect a new change to your site made on your local computer.
![Page 14: Drupal Version Control & File System Basics](https://reader034.vdocuments.net/reader034/viewer/2022052523/5552f2b1b4c90587048b4c06/html5/thumbnails/14.jpg)
What Does Version Control Look Like In Practice?
• Example: Association for the Advancement of Sustainability in Higher Education
• Version Control System: Subversion
![Page 15: Drupal Version Control & File System Basics](https://reader034.vdocuments.net/reader034/viewer/2022052523/5552f2b1b4c90587048b4c06/html5/thumbnails/15.jpg)
How is AASHE’s repository set up?
• Trunk: the latest, least stable version of our code
• Branch: the working version of code, very similar to live code
• Tags: each new version of the site is tagged
![Page 16: Drupal Version Control & File System Basics](https://reader034.vdocuments.net/reader034/viewer/2022052523/5552f2b1b4c90587048b4c06/html5/thumbnails/16.jpg)
What does this look like when we are coding?
• If we are testing out new modules or major upgrades, we work in trunk first.
• Commits to trunk show up at dev.aashe.org
• If we are fixing bugs or updating code, we work in the current branch first.
• Commits to the current branch show up at stage.aashe.org
• We never touch the releases, we just create a new one when the branch code is tested.
• We have a release script for making a new release.
![Page 17: Drupal Version Control & File System Basics](https://reader034.vdocuments.net/reader034/viewer/2022052523/5552f2b1b4c90587048b4c06/html5/thumbnails/17.jpg)
What does the release script do?
• Creates the next tag.
• Creates an export of the branch repository.
• Creates a symlink from the public folder to the new release.
• Creates symlinks to the file directories (explanation to follow)
svn copy file://$path/www/branches/branch-3.0/ file://$path/www/releases/release-$release -m "$commit"
svn export --force file://$path/www/releases/release-$release /var/www/aashe.org/releases/release-$release
rm /var/www/aashe.org/publicln -s /var/www/aashe.org/releases/release-$release /var/www/aashe.org/public
![Page 18: Drupal Version Control & File System Basics](https://reader034.vdocuments.net/reader034/viewer/2022052523/5552f2b1b4c90587048b4c06/html5/thumbnails/18.jpg)
What are some version control hurdles specific to Drupal?
![Page 19: Drupal Version Control & File System Basics](https://reader034.vdocuments.net/reader034/viewer/2022052523/5552f2b1b4c90587048b4c06/html5/thumbnails/19.jpg)
Updating Modules
• We use drush to update Drupal modules locally, then commit to the staging site (unless it’s Views or CCK, then trunk)
• drush is a command line shell and Unix scripting interface for Drupal, a veritable Swiss Army knife designed to make life easier for those of us who spend some of our working hours hacking away at the command prompt.
drush up mymodulename
![Page 20: Drupal Version Control & File System Basics](https://reader034.vdocuments.net/reader034/viewer/2022052523/5552f2b1b4c90587048b4c06/html5/thumbnails/20.jpg)
Updating Core
• We download the version of Drupal we are using from Drupal.org and the latest version, unzip them, and create a patch file using the diff command
• Next, we test to see if there are any conflicts by doing a dry run from the root Drupal directory
• Last, we apply the patch file for real from the root directory
wget http://ftp.drupal.org/files/projects/drupal-6.16.tar.gztar -xzf drupal-6.16.tar.gzwget http://ftp.drupal.org/files/projects/drupal-6.15.tar.gztar -xzf drupal-6.15.tar.gzdiff -Naur drupal-6.15 drupal-6.16 > drupal-current-to-drupal-latest.patch
patch -p1 --dry-run < drupal-current-to-drupal-latest.patch
patch -p1 < drupal-current-to-drupal-latest.patch
![Page 21: Drupal Version Control & File System Basics](https://reader034.vdocuments.net/reader034/viewer/2022052523/5552f2b1b4c90587048b4c06/html5/thumbnails/21.jpg)
Preventing Files From Being Accidentally Deleted or Versioned
• We store our files at the same level as our public directory and create a symlink to it
• Our release script rebuilds these symlinks each time there is a new release
ln -s /var/www/aashe.org/files /var/www/aashe.org/public/filesln -s /var/www/aashe.org/documents /var/www/aashe.org/public/documents
![Page 22: Drupal Version Control & File System Basics](https://reader034.vdocuments.net/reader034/viewer/2022052523/5552f2b1b4c90587048b4c06/html5/thumbnails/22.jpg)
Next Steps
• Pick your favorite version control system
• Research your version control system of choice
• If you don’t want to mess with the command-line, look for a GUI tool like TortiseSVN, Versions, SvnX, or a code editor like Eclipse, Textmate
• Decide on your repository structure
• Start writing versioned code
![Page 23: Drupal Version Control & File System Basics](https://reader034.vdocuments.net/reader034/viewer/2022052523/5552f2b1b4c90587048b4c06/html5/thumbnails/23.jpg)
Next Up: Mastering the Drupal Database
• Hello Allen