Stuff with the Perl Foundation. A couple of patches in the Perl core. A few CPAN modules. That about sums it up.
This is for Subversion, but I'm sure you could extend it.
We branch for every feature we add, but I sometimes forget to add branch names to a commit. No longer. Add the following two lines to your
filetype plugin on
au! FileType svn:call AddBranchName()
And create a file named
function! AddBranchName()
let cwd = getcwd()
let path = split( cwd, '/' )
let cwd = path[ len(path) - 1 ]
if bufname("%") == "svn-commit.tmp" && cwd != 'trunk'
call append(0, "Branch: " . cwd)
call append(1, "")
call append(2, " - ")
call cursor(3, 4)
endif
endfunction
Now, when I type 'svn commit', I see something like the following, with the cursor already positioned where it needs to be:
Branch: errors_on_data_objects_with_drilldown
- _
--This line, and those below, will be ignored--
M root/reports/validation_exceptions_by_period_table.tt
M conf/log/log.conf
A lib/Pips3/C/Reports/Imports/Validation/ObjectsByPeriod.pm
M lib/Pips3/Report/Query/Validation.pm
This makes a few assumptions about your environment, so I would love to get some portability comments. I also wanted to leave the editor in insert mode, but couldn't figure out how to do that. Vim is one of the few tools I use regularly for which Google is almost useless.
why and the command you're looking for (Score:1)
Re: (Score:2)
I have to put the branch name in there because it's part of our coding standards. Argue with jplindstrom and others :)
And yes, startinsert is exactly what I needed. Thanks!
Re: (Score:1)
Re: (Score:1)
That sort of rule is common in shops stuck on Subversion… since Subversion does so little to actually help with branches (other than making them cheap to create, as if that bought you anything), you need to put a bunch of information in your commit messages manually in order to be able to babysit Subversion later. VCSs that actually have useful merge support, such as any DVCS of your choice, make it unnecessary to do that sort of bookkeeping.
And if you like browsing Trac, wait to see the
gitkbrowseRe: (Score:1)
The silver lining: we're looking at moving to git. We just need to find a good point in time to take the productivity hit of switching.
Branch names (Score:1)
Can your plugin instead use "svn info" to pull the actual branch name? It could pull the URL from "svn info" and then assume that the next path segment after "/branches" (or
Re: (Score:1)
Turns out that's quite straightforward. Here's my version (below) modified to do that:
Re: (Score:1)
"svn-commit.2.tmp" 4L, 63C
Error detected while processing function AddBranchName:line 3:
E486: Pattern not found: retired
Here's my full plugin source:
Re: (Score:1)
Ooops, my fault!
s//repeats the most recent match; I'm guessing you previously searched for “retired” and that you have something in your Vim config which remembers the search register across sessions.Make that
s/^/instead. Sorry about that.Note you don't need that function definition around it; what I posted was intended to be the complete plug-in. See below for the explanation.
Refactored (Score:1)
Note that you're duplicating the filetype detection there, twice. The standard
$VIMRUNTIME/filetype.vimdefines an autocommand such that starting to edit a file matchingsvn-commit*.tmpwill trigger a FileType event forsvn. As you've got it set up, making a commit causes these steps to run:.vim/ftplugin/svn.vimis run (because you have filetype plug-ins enabled), which in your case defines a function.svn.vimhas just defined.