diff --git a/katip.gemspec b/katip.gemspec index 9a008a7..fcc54f9 100644 --- a/katip.gemspec +++ b/katip.gemspec @@ -8,13 +8,12 @@ Gem::Specification.new do |spec| spec.version = Katip::VERSION spec.authors = %w[lab2023] spec.email = %w[info@lab2023.com] - spec.description = %q{TODO: Write a gem description} - spec.summary = %q{TODO: Write a gem summary} + spec.description = %q{Write a gem description} + spec.summary = %q{Write a gem summary} spec.homepage = 'https://github.com/kebab-project/katip' spec.license = 'MIT' spec.files = `git ls-files`.split($/) - spec.executables = %w[daktilo] spec.require_paths = %w[lib] spec.add_development_dependency 'bundler', '~> 1.3' diff --git a/lib/bin/daktilo b/lib/bin/daktilo deleted file mode 100755 index 19d8eb8..0000000 --- a/lib/bin/daktilo +++ /dev/null @@ -1,34 +0,0 @@ -# Get tags as an array -TAGS_ARRAY=(`git for-each-ref --sort='*authordate' --format='%(tag)' refs/tags | grep -v '^$'`) - -repo_url="../../commit/" - -# Set User defined file if exist else use default -if [ -n "$1" ]; then - OUTPUT=$1 -else - OUTPUT="CHANGELOG.md" -fi - -# Calculate the tag count -SIZE=${#TAGS_ARRAY[@]} - -echo "\n#### [Current]" > $OUTPUT - -# Iterate reversly on tags -for (( i = SIZE - 1; i >= 0 ; i-- )); -do - CURR_TAG=${TAGS_ARRAY[$i]} - echo "" >> $OUTPUT - if [ $PREV_TAG ];then - echo "#### [$PREV_TAG]" >> $OUTPUT - fi - git log --pretty=format:" * [%h]($repo_url%h) %s __(%an)__" $CURR_TAG..$PREV_TAG | grep -v "Merge branch " >> $OUTPUT - PREV_TAG=$CURR_TAG -done - -# Dump change log for first tag -FIRST=$(git tag -l | head -1) -echo "\n#### [$FIRST]" >> $OUTPUT - -git log --pretty=format:" * [%h]($repo_url%h) %s __(%an)__" $FIRST | grep -v "Merge branch " >> $OUTPUT diff --git a/lib/katip.rb b/lib/katip.rb index eb267da..a52ad02 100644 --- a/lib/katip.rb +++ b/lib/katip.rb @@ -2,4 +2,50 @@ module Katip require 'katip/railtie' if defined?(Rails) + + @@daktilo = <<-SHELL +# Get tags as an array +TAGS_ARRAY=(`git for-each-ref --sort='*authordate' --format='%(tag)' refs/tags | grep -v '^$'`) + +repo_url="../../commit/" + +# Set User defined file if exist else use default +if [ -n "$1" ]; then + OUTPUT=$1 +else + OUTPUT="CHANGELOG.md" +fi + +# Calculate the tag count +SIZE=${#TAGS_ARRAY[@]} + +echo "\n#### [Current]" > $OUTPUT + +# Iterate reversly on tags +for (( i = SIZE - 1; i >= 0 ; i-- )); +do + CURR_TAG=${TAGS_ARRAY[$i]} + echo "" >> $OUTPUT + if [ $PREV_TAG ];then + echo "#### [$PREV_TAG]" >> $OUTPUT + fi + git log --pretty=format:" * [%h]($repo_url%h) %s __(%an)__" $CURR_TAG..$PREV_TAG | grep -v "Merge branch " >> $OUTPUT + PREV_TAG=$CURR_TAG +done + +# Dump change log for first tag +FIRST=$(git tag -l | head -1) +echo "\n#### [$FIRST]" >> $OUTPUT + +git log --pretty=format:" * [%h]($repo_url%h) %s __(%an)__" $FIRST | grep -v "Merge branch " >> $OUTPUT + SHELL + + def self.set(param) + @@daktilo = param + end + + def self.get + @@daktilo + end + end diff --git a/lib/tasks/katip.rake b/lib/tasks/katip.rake index c8bb56e..39e8883 100644 --- a/lib/tasks/katip.rake +++ b/lib/tasks/katip.rake @@ -1,6 +1,7 @@ namespace :katip do desc 'Create CHANGELOG.md' task :create => [:environment] do - put 'Onur Ozgur OZKAN' + puts 'Create CHANGELOG.md' + exec Katip.get end end \ No newline at end of file