Drupal Version Control & File System Basics

4,626 views
4,547 views

Published on

Presentation for Triangle Drupal User's Group on March 17, 2010. Includes discussion of why version control is a good idea, how to deal with special Drupal issues (updating modules, core) and how to set up your file structure.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
4,626
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
20
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Drupal Version Control & File System Basics

  1. 1. Drupal Version Control & File System Basics Julia Kulla-Mader Triangle Drupal User’s Group March 17, 2010 http://www.juliakm.com @juliakm
  2. 2. What is version control? • A way of managing changes to documents, programs, or other data stored as computer files. (Wikipedia)
  3. 3. What are some version control systems?
  4. 4. Why use version control? • Real world scenarios
  5. 5. Why am I getting a white screen of death? • Version control lets you see what the most recent code change was on your site.
  6. 6. Can I get rid of that white screen of death? • Version control lets you roll back to a previous version.
  7. 7. 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).
  8. 8. 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.
  9. 9. 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.
  10. 10. 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.
  11. 11. Who was the last person to touch this module? • Version control lets to see the last person who edited a file.
  12. 12. 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.
  13. 13. 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.
  14. 14. What Does Version Control Look Like In Practice? • Example: Association for the Advancement of Sustainability in Higher Education • Version Control System: Subversion
  15. 15. 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
  16. 16. 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.
  17. 17. What does the release script do? • Creates the next tag. svn copy file://$path/www/branches/branch-3.0/ file://$path/www/releases/release-$release -m "$commit" • Creates an export of the branch repository. svn export --force file://$path/www/releases/release-$release /var/www/aashe.org/releases/release-$release • Creates a symlink from the public folder to the new release. rm /var/www/aashe.org/public ln -s /var/www/aashe.org/releases/release-$release /var/www/aashe.org/public • Creates symlinks to the file directories (explanation to follow)
  18. 18. What are some version control hurdles specific to Drupal?
  19. 19. 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
  20. 20. 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 wget http://ftp.drupal.org/files/projects/drupal-6.16.tar.gz tar -xzf drupal-6.16.tar.gz wget http://ftp.drupal.org/files/projects/drupal-6.15.tar.gz tar -xzf drupal-6.15.tar.gz diff -Naur drupal-6.15 drupal-6.16 > drupal-current-to-drupal-latest.patch • Next, we test to see if there are any conflicts by doing a dry run from the root Drupal directory patch -p1 --dry-run < drupal-current-to-drupal-latest.patch • Last, we apply the patch file for real from the root directory patch -p1 < drupal-current-to-drupal-latest.patch
  21. 21. 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/files ln -s /var/www/aashe.org/documents /var/www/aashe.org/public/documents
  22. 22. 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
  23. 23. Next Up: Mastering the Drupal Database • Hello Allen

×