latest_branch
→ latest_branch -a <proj_name>
→ alias_all_projects
What
Return the most-recently-updated folder starting with a common prefix. This is useful where your project branches all start with the same name as the project, e.g.
- /path/to/wizzo —trunk
- /path/to/wizzo_feature1 —branch for feature1 Last touched
- /path/to/wizzo_feature2 —branch for feature2
$ latest_branch --app=wizzo --path=/path/to /path/to/wizzo_feature1 --> returns absolute folder path for most recently modified folder
Or, where all your branches and trunk appear as subfolders, e.g.
- /path/to/booya/trunk —trunk Last touched
- /path/to/booya/branches/feature1 —branch for feature1
- /path/to/booya/branches/feature2 —branch for feature2
$ latest_branch --app=booya --root=/path/to /path/to/booya/trunk --> returns absolute folder within the tree of trunk and branch folders
Bonus – alias_all_projects
You can generate aliases for all your projects’ latest branches with the included command alias_all_projects.
You can call it multiple times with different --path options to specify alternate path project paths.
For example, I add the following four lines to my .profile to create aliases for all my gems and rails projects.
alias_all_projects --path=~/Documents/rails_apps/ . ~/.project_aliases alias_all_projects --prefix="gem_" --path=~/Documents/ruby/gems/ . ~/.project_aliases
Installing
sudo gem install latest_branch
Requirements
It uses the location of Rakefile files to determine application/project path folders, and the --app parameter is the prefix of the base path to the projects.
Use in .profile
If you just wanted to add aliases to a selection of projects, you could add the following line to .profile:
export RAILS_APPS="~/Documents/rails_apps" alias wizzo="cd `latest_branch --app=wizzo`"
or
alias wizzo="cd \`latest_branch --app=wizzo --path=~/Documents/rails_apps\`"
BUT, I prefer the following…
Generate aliases for all your projects
For each folder that contains your projects (even if they are within subfolders such as trunk, branches etc), add alias_all_projects --path=ROOT_FOLDER to your .profile and then execute the generated ~/.project_aliases file.
For example, I add the following four lines to my .profile to create aliases for all my gems and rails projects.
alias_all_projects --path=~/Documents/rails_apps/ . ~/.project_aliases alias_all_projects --prefix="gem_" --path=~/Documents/ruby/gems/ . ~/.project_aliases
Articles
Licence
This code is free to use under the terms of the MIT licence.
Contact
Comments are welcome. Send an email to Dr Nic Williams.
Dr Nic, 16th April 2007
Theme extended from Paul Battley