ZyX_I avatar ZyX_I committed 5884469

@aurum/commit: Made :AuCommit throw an error if there is nothing to commit
Made s:F.savemsg not save message in case it is blank

Comments (0)

Files changed (5)

 @aurum/status:
     1.0: Renamed |:AuStatus| “rev1” and “rev2” options to “rev” and “wdrev” 
          respectively. Same for |aurum://status| “rev1” and “rev2” options.
+@aurum/commit:
+    1.0: Added fifth argument to _r.commit.commit()
 
 vim: ft=help:tw=78

ftplugin/aurumcommit.vim

 setlocal nomodeline
 execute frawor#Setup('0.0', {'@aurum/bufvars': '0.0',
             \                    '@/mappings': '0.0',
-            \                 '@aurum/commit': '0.0',})
+            \                 '@aurum/commit': '1.0',})
 "▶1 com.runcommap
 function s:F.runcommap(action)
     let buf=bufnr('%')

ftplugin/aurumstatus.vim

             \                '@aurum/vimdiff': '0.2',
             \               '@aurum/cmdutils': '0.0',
             \                   '@aurum/edit': '1.0',
-            \                 '@aurum/commit': '0.0',
+            \                 '@aurum/commit': '1.0',
             \                    '@/mappings': '0.0',
             \                          '@/os': '0.0',})
 let s:_messages={
     endif
     let files=map(copy(range), 'bvar.files[v:val]')
     if a:action is# 'commit'
-        if s:_r.commit.commit(bvar.repo, bvar.opts, files, bvar.status)
+        if s:_r.commit.commit(bvar.repo, bvar.opts, files, bvar.status,
+                    \         ['modified', 'added', 'removed', 'deleted',
+                    \          'unknown'])
             silent edit!
         else
             augroup AuStatusCommit

plugin/aurum/commit.vim

 "▶1 
 scriptencoding utf-8
 if !exists('s:_pluginloaded')
-    execute frawor#Setup('0.0', {'@/resources': '0.0',
+    execute frawor#Setup('1.0', {'@/resources': '0.0',
                 \                  '@/options': '0.0',
                 \              '@aurum/status': '1.0',
                 \            '@aurum/cmdutils': '0.0',
             \'emptmsg': 'Message must contain at least one non-blank character',
             \'nocfile': 'Unsure what should be commited',
             \'nocread': 'Cannot read aurum://commit',
+            \  'nocom': 'Nothing to commit',
         \}
 let s:_options={
             \'remembermsg':         {'default': 1, 'filter': 'bool'},
     endif
     return r
 endfunction
-"▶1 commit :: repo, opts, files, status → + repo
+"▶1 commit :: repo, opts, files, status, types → + repo
 let s:defdate=['strftime("%Y")',
             \  'strftime("%m")',
             \  'strftime("%d")',
 let s:statmsgs.deleted=s:statmsgs.removed
 " TODO Investigate why closing commit buffer on windows consumes next character
 " XXX Do not change names of options used here, see :AuRecord
-function s:F.commit(repo, opts, files, status)
+function s:F.commit(repo, opts, files, status, types)
     let user=''
     let date=''
     let message=''
     let cb=get(a:opts, 'closebranch', 0)
     let revstatus={}
-    call map(copy(a:status),
+    call map(filter(copy(a:status), 'index(a:types, v:key)!=-1'),
                 \'map(copy(v:val),"extend(revstatus,{v:val : ''".v:key."''})")')
+    if !empty(a:files)
+        call filter(revstatus, 'index(a:files, v:key)!=-1')
+    endif
     for key in filter(['user', 'date', 'message'], 'has_key(a:opts, v:val)')
         let l:{key}=a:opts[key]
     endfor
             unlet g:AuPreviousRepoPath g:AuPreviousTip g:AuPreviousCommitMessage
         endif
         let fmessage=[]
-        for file in a:files
-            let fmessage+=['# '.s:statmsgs[revstatus[file]].' '.file]
+        for [file, state] in items(revstatus)
+            let fmessage+=['# '.s:statmsgs[state].' '.file]
         endfor
         call sort(fmessage)
         call append('.', fmessage)
 endfunction
 "▶1 savemsg :: message, bvar → + g:
 function s:F.savemsg(message, bvar)
+    if a:message!~#"[^[:blank:]\n]"
+        return
+    endif
     let g:AuPreviousCommitMessage=a:message
     let g:AuPreviousTip=a:bvar.repo.functions.gettiphex(a:bvar.repo)
     let g:AuPreviousRepoPath=a:bvar.repo.path
     call s:_r.cmdutils.checkrepo(repo)
     let status=repo.functions.status(repo)
     "▶2 Get file list
+    let types=['modified', 'added', 'removed']
     if a:0 && index(a:000, 'all')!=-1
         let files=[]
     elseif a:0
         if has_key(a:opts, 'type')
             let types=s:_r.status.parseshow(a:opts.type)
+            call filter(types, 'v:val isnot# "clean" && v:val isnot# "ignored"')
         endif
         let filepats=map(filter(copy(a:000), 'v:val isnot# ":"'),
                     \    's:_r.globtopat('.
                     \    'repo.functions.reltorepo(repo, v:val))')
         let statfiles={}
         for [type, sfiles] in items(status)
-            if type is# 'clean' || type is# 'ignored' ||
-                        \(exists('types')?(index(types, type)==-1):
-                        \                 (type is# 'unknown' ||
-                        \                  type is# 'deleted'))
+            if index(types, type)==-1
                 continue
             endif
             let curfiles=[]
         call s:_f.throw('nocfile')
     endif
     "▲2
-    return s:F.commit(repo, a:opts, files, status)
+    return s:F.commit(repo, a:opts, files, status, types)
 endfunction
 let s:commfunc['@FWC']=['-onlystrings '.
             \           '{  repo '.s:_r.cmdutils.nogetrepoarg.

plugin/aurum/record.vim

                 \                    '@/mappings': '0.0',
                 \                    '@/commands': '0.0',
                 \                   '@/functions': '0.0',
-                \                 '@aurum/commit': '0.0',
+                \                 '@aurum/commit': '1.0',
                 \               '@aurum/cmdutils': '0.0',
                 \                   '@aurum/repo': '2.0',
                 \                   '@aurum/edit': '1.0',
             return
         endif
         aboveleft let r=s:_r.commit.commit(bvar.repo, bvar.recopts, files,
-                    \                      bvar.status)
+                    \                      bvar.status, keys(s:ntypes))
         if r
             call s:F.unload(bvar)
         else
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.