Skip to content

Commit

Permalink
merge f.* t.* snp.*
Browse files Browse the repository at this point in the history
  • Loading branch information
Show file tree
Hide file tree
Showing 343 changed files with 14,436 additions and 4,597 deletions.
674 changes: 674 additions & 0 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
0.4.8
0.4.9
204 changes: 204 additions & 0 deletions _script/build
@@ -0,0 +1,204 @@
#!/bin/bash


case $1 in
gentest)
cd ftplugin/
langs=`ls -d * | grep -v "^_" | awk '{printf($1" ");}'`
cd -

echo "vim -c \"XPTtestAll $langs\"" >test.bat
exit
;;

"")
mode=""
echo "export"
;;

"test")
mode=test
echo "export"
;;

*)
echo "error"
exit -1
;;

esac


CurrentDir=$PWD
ParentDir=${PWD%/*}
githash=`git log --max-count=1 --format=%h`
today=`date +%y%m%d`
ver=`cat VERSION`.$today-$githash
build_name=build-$today-$githash

dev_branch=dev
build_branch=master


compact() {
local file=$1

echo Join splitted lines
echo Remove Logs/Comments/Empty_Lines from $file

grep -v "call s:log.\(Log\|Debug\)(" $file |\
grep -v "^ *Assert " |\
grep -v "^ *\"" |\
grep -v "^ *$" |\
sed 's/ *" *{{{//; s/ *" *}}}//' |\
gawk -f _script/build-d/cleanspace.awk |\
gawk -f _script/build-d/joinlines.awk |\
gawk -f _script/build-d/formatindent.awk \
> .tmp

mv .tmp $file
}

create_tgz() {
rm -rf $ParentDir/xpt && mkdir $ParentDir/xpt && cp -R ./* $ParentDir/xpt/
cd $ParentDir/xpt && tar -czf ../xpt-$ver.tgz *
cd $CurrentDir
}

build_for_release () {
check_cur_branch \
&& create_build_branch \
&& compact_files \
&& update_doc \
&& clean_files \
&& remove_tests \
&& generate_version \
&& commit_build \
&& create_tgz \
&& update_built_branch \
&& echo "Done"
}

build_for_test () {
check_cur_branch \
&& git checkout $githash \
&& compact_files \
&& update_doc \
&& clean_files \
&& generate_version \
&& git commit -a -m "$build_name for test" \
&& vim -c 'call xpt#unittest#Runall() | call getchar() | qa' \
&& echo "Done building for test"
}

check_cur_branch() {
local cur_branch=$(git symbolic-ref HEAD 2>/dev/null | cut -c 12-)

echo $cur_branch

if [ ".$cur_branch" != ".$dev_branch" ]; then
echo "not on $dev_branch!!"
return -1;
fi
}

create_build_branch() {
git checkout -b $build_name || { echo "Failed to create branch $build_name"; return 1; }
}

clean_files() {
cat $CurrentDir/$0 | awk '/^# __TO_REMOVE__/,/^# __TO_REMOVE__ END/{ if ( $1 != "#" ) print $0; }' | while read f; do git rm -rf $f; done
git rm `find . -name "test.page*"`
rm `find . -name "*.xpt.vimc"`
return 0
}

remove_tests() {
git rm -rf test/
git rm -rf autoload/xpt/ut/
git rm -rf autoload/xpt/unittest.vim
}

compact_files() {

for file in `find {plugin,autoload}/ -name *.vim | grep -v "/debug\.vim$"`;do
compact $file
done
}

generate_version() {

mv plugin/xptemplate.vim .tmp
cat > plugin/xptemplate.vim <<-END
" GetLatestVimScripts: 2611 1 :AutoInstall: xpt.tgz
" VERSION: $ver
END
cat .tmp >> plugin/xptemplate.vim && rm .tmp
}

update_doc() {
local doc_sections="option snippet-function"

_script/credit-update \
&& _script/doc_merge.py \
|| return 1

for sec in $doc_sections; do
git rm -r doc/xpt/$sec || return 1
done

vim -c "helptags ./doc" -c 'qa!'

for sec in $doc_sections credit; do
git add doc/xpt/$sec.txt || return 1
done
}

commit_build() {
git commit -a -m "$build_name"
}

update_built_branch(){

local base=$(git merge-base $dev_branch $build_branch)
local mes="$(git log $base..$dev_branch --format="%b" | grep -v "x-update-from")"
local subject="$(git log $base..$dev_branch --format="%s")"
subject="$(echo $subject)"

local tree_hash=$(git_obj_get_tree "$build_name")
local built_commit_hash=$(echo "$subject
$mes" | git commit-tree $tree_hash -p $build_branch -p $dev_branch)
git update-ref refs/heads/$build_branch $built_commit_hash

git checkout $dev_branch \
&& git branch -D $build_name

}

git_obj_get_tree () {
git cat-file -p "$1" | head -n1 | awk '{print $2}'
}

if [ "$mode" == "test" ]; then
build_for_test
else
build_for_release
fi
exit

# __TO_REMOVE__
plugin/xptemplateTest.vim
plugin/xptTestKey.vim
plugin/xptemplate.importer.vim
doc/tags
make-dev
make-mix
tags
test.bat
test.sh
to-gitcafe
todo
_script/
VERSION
# __TO_REMOVE__ END
23 changes: 23 additions & 0 deletions _script/build-d/cleanspace.awk
@@ -0,0 +1,23 @@
/^[^"']*$/ {
gsub( /(\> +\<)/, " " );
$0 = gensub( /(\w) +(\w)/, "\\1 \\2", "g" );
$0 = gensub( /([^ 0-9a-z_]) +/, "\\1 ", "g" );
$0 = gensub( /(\w) +(\W)/, "\\1 \\2", "g" );

# space after brackets
$0 = gensub( /([\[{(,]) +/, "\\1", "g" );

# space before brackets
$0 = gensub( / +([\]})])/, "\\1", "g" );

# space at line end
$0 = gensub( / +$/, "", "g" );

print $0;
}
/['"]/ {
$0 = gensub( /^ *(\\ *'[^']+') *: */, "\\1:", "g" );
print $0;
}

# vim: tabstop=2
10 changes: 10 additions & 0 deletions _script/build-d/formatindent.awk
@@ -0,0 +1,10 @@
{
$0 = gensub( /^ /, " ", "g" );
$0 = gensub( /^ /, " ", "g" );
$0 = gensub( /^ /, " ", "g" );
$0 = gensub( /^ /, " ", "g" );
$0 = gensub( /^ /, " ", "g" );
print $0;
}

# vim: tabstop=2
14 changes: 14 additions & 0 deletions _script/build-d/joinlines.awk
@@ -0,0 +1,14 @@
$0 ~ /^ *\\/ {
t = $0;
gsub( /^ *\\ */, " ", t );
last = last t;
}
$0 !~ /^ *\\/ {
if ( last != "" ) {
print last;
}
last = $0;
}
END{
print last;
}
55 changes: 55 additions & 0 deletions _script/build-d/make-change-log
@@ -0,0 +1,55 @@
#!/bin/sh

onto_branch=dev
from_branch=mix

since_ts=$(git log -n1 --format="%at" $onto_branch)

# <ts> <hash> <date> <time> +0008 <mes>
git log --format="%at %h %ai %s" --no-merges $from_branch \
| sort -r \
| awk -v since=$since_ts '{
if ( int($1) > int(since) ) {
gsub(".", "", $1);
gsub(".", "", $4);
gsub(".", "", $5);
print $0;
}
}' \
| sed 's/^ //; s/ */ /g' \
| grep " Added: \| Changed: \| Deprecated: \| Removed: \| Fixed: " \
| python -c '
import sys
import datetime
import time
has_log = False
logs = {"Added":{}, "Changed":{}, "Deprecated":{}, "Removed":{}, "Fixed":{}}
for line in sys.stdin:
hsh, dt, tp, sec, mes = line.split(None, 4)
tp = tp[:-1]
sec = sec[:-1]
mes = mes.strip()
logs[tp][sec] = logs[tp].get(sec, []) + [mes]
has_log = True
if not has_log:
sys.exit(0)
now = datetime.datetime.utcfromtimestamp(int(time.time())).strftime("%Y-%m-%d")
print now
print "="*len(now)
print ""
for tp in ("Added", "Changed", "Deprecated", "Removed", "Fixed"):
if len(logs[tp]) == 0:
continue
print tp
print "-"*len(tp)
print ""
for sec in sorted(logs[tp].keys()):
for mes in logs[tp][sec]:
print "* " + sec + ": " + mes
print ""
'
1 change: 1 addition & 0 deletions _script/contributor.txt
@@ -0,0 +1 @@
@bstaint
11 changes: 11 additions & 0 deletions _script/credit-update
@@ -0,0 +1,11 @@
#!/bin/sh

fn=doc/xpt/credit.txt

echo "Thanks to:\n" > $fn
git log --all --no-merges --format="%an" \
| grep -v "drdr.\?xp\|xp\|zhang yanpo\|drmingdrmer\|no author" \
| sort | uniq \
>> $fn

cat _script/contributor.txt >>$fn
66 changes: 66 additions & 0 deletions _script/doc_merge.py
@@ -0,0 +1,66 @@
#!/usr/bin/env python
# coding: utf-8

import os

def out( f, *msgs ):
for msg in msgs:
f.write(msg + "\n" )

def fnlist( section ):
base = os.path.join( "doc", "xpt", section )
fns = os.listdir( base )
fns.sort()
anony = [x for x in fns
if x.startswith('_')]
chapters = [x for x in fns
if not x.startswith('_')]
return anony + chapters

def fread( fn ):
with open( fn, 'r' ) as f:
cont = f.read()
lines = cont.split( "\n" )
lines = [ x for x in lines
if not x.startswith( '" vi''m:' ) ]
return '\n'.join( lines )

def merge_doc( section, prefix ):

width = 78
title ='*xpt-' + section + '*'
title = title.rjust(width)
header = [
title,
'=' * width,
'',
'Table of Content ~',
'',
]

fns = fnlist( section )

fn = os.path.join( "doc", "xpt", section + ".txt" )
with open( fn, "w" ) as f:

out( f, *header )

indent = " "
for fn in fns:
optname = fn.split(".")[0]
if not optname.startswith('_'):
out( f, indent + "|" + prefix + optname + "|" )

out( f, "" )

for fn in fns:
cont = fread( os.path.join( "doc", "xpt", section, fn ) )
out( f, cont )

out( f, "" )
out( f, '" vi''m: tw='+str(width)+':ts=8:sw=8:sts=8:noet:ft=help:norl:' )

if __name__ == "__main__":

merge_doc( 'option', 'g:xptemplate_' )
merge_doc( 'snippet-function', '' )

0 comments on commit 8dbe987

Please sign in to comment.