changelog-gen.tcl: Добавлены опции командной строки, добавлен вывод в файл
This commit is contained in:
parent
6b5d116743
commit
cb5c21c077
|
@ -63,7 +63,7 @@ switch $tcl_platform(platform) {
|
||||||
}
|
}
|
||||||
|
|
||||||
proc ReadGitLog {} {
|
proc ReadGitLog {} {
|
||||||
global gitCommand lastCommitTimeStampSec projectName
|
global args gitCommand lastCommitTimeStampSec
|
||||||
set cmd exec
|
set cmd exec
|
||||||
set i 0
|
set i 0
|
||||||
lappend cmd "$gitCommand"
|
lappend cmd "$gitCommand"
|
||||||
|
@ -71,7 +71,7 @@ proc ReadGitLog {} {
|
||||||
lappend cmd "--abbrev-commit"
|
lappend cmd "--abbrev-commit"
|
||||||
# Проверяем была ли запись для данного проекта если была то к времени последнего коммита прибавляем 1 сек.
|
# Проверяем была ли запись для данного проекта если была то к времени последнего коммита прибавляем 1 сек.
|
||||||
# и получаем журнал после этой даты
|
# и получаем журнал после этой даты
|
||||||
if [info exists lastCommitTimeStampSec] {
|
if {[info exists lastCommitTimeStampSec] && [info exists args(--last)]} {
|
||||||
lappend cmd "--after='[clock format [clock add $lastCommitTimeStampSec 1 second] -format {%a, %e %b %Y %H:%M:%S %z}]'"
|
lappend cmd "--after='[clock format [clock add $lastCommitTimeStampSec 1 second] -format {%a, %e %b %Y %H:%M:%S %z}]'"
|
||||||
}
|
}
|
||||||
lappend cmd "--all"
|
lappend cmd "--all"
|
||||||
|
@ -101,16 +101,16 @@ proc ReadGitLog {} {
|
||||||
if [info exists res] {
|
if [info exists res] {
|
||||||
return $res
|
return $res
|
||||||
} else {
|
} else {
|
||||||
puts "\nRepository '$projectName' do not have any changes\n"
|
puts "\nRepository '$args(--project-name)' do not have any changes\n"
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
proc StoreProjectInfo {projectName projectVersion projectRelease timeStamp} {
|
proc StoreProjectInfo {timeStamp} {
|
||||||
global dir
|
global dir args
|
||||||
set cfgFile [open [file join $dir(cfg) $projectName.conf] "w+"]
|
set cfgFile [open [file join $dir(cfg) $args(--project-name).conf] "w+"]
|
||||||
puts $cfgFile "# set projectVersion \"$projectVersion\""
|
puts $cfgFile "# set args(--project-version) \"$args(--project-version)\""
|
||||||
puts $cfgFile "# set projectRelease \"$projectRelease\""
|
puts $cfgFile "# set args(--project-release) \"$args(--project-release)\""
|
||||||
puts $cfgFile "set lastCommitTimeStamp \"$timeStamp\""
|
puts $cfgFile "set lastCommitTimeStamp \"$timeStamp\""
|
||||||
puts $cfgFile "set lastCommitTimeStampSec [clock scan $timeStamp]"
|
puts $cfgFile "set lastCommitTimeStampSec [clock scan $timeStamp]"
|
||||||
close $cfgFile
|
close $cfgFile
|
||||||
|
@ -118,7 +118,7 @@ proc StoreProjectInfo {projectName projectVersion projectRelease timeStamp} {
|
||||||
|
|
||||||
|
|
||||||
proc GenerateChangelogDEB {} {
|
proc GenerateChangelogDEB {} {
|
||||||
global projectName projectVersion projectRelease
|
global args
|
||||||
# puts "GenerateChangelogDEB"
|
# puts "GenerateChangelogDEB"
|
||||||
set lastCommitTimeStamp ""
|
set lastCommitTimeStamp ""
|
||||||
set commiter ""
|
set commiter ""
|
||||||
|
@ -127,6 +127,7 @@ proc GenerateChangelogDEB {} {
|
||||||
set lst [lsort -integer -index 0 [ReadGitLog]]
|
set lst [lsort -integer -index 0 [ReadGitLog]]
|
||||||
# puts $lst
|
# puts $lst
|
||||||
# exit
|
# exit
|
||||||
|
set outText ""
|
||||||
foreach l $lst {
|
foreach l $lst {
|
||||||
set index [lindex $l 0]
|
set index [lindex $l 0]
|
||||||
set line [lindex $l 1]
|
set line [lindex $l 1]
|
||||||
|
@ -140,24 +141,30 @@ proc GenerateChangelogDEB {} {
|
||||||
set timeStamp [clock format [clock scan $timeStamp] -format {%a, %e %b %Y %H:%M:%S %z}]
|
set timeStamp [clock format [clock scan $timeStamp] -format {%a, %e %b %Y %H:%M:%S %z}]
|
||||||
# puts "> $commiter"
|
# puts "> $commiter"
|
||||||
if {$index == 0} {
|
if {$index == 0} {
|
||||||
puts "$projectName ($projectVersion-$projectRelease) stable; urgency=medium\n"
|
puts "$args(--project-name) ($args(--project-version)-$args(--project-release)) stable; urgency=medium\n"
|
||||||
|
append outText "$args(--project-name) ($args(--project-version)-$args(--project-release)) stable; urgency=medium\n\n"
|
||||||
set commiter [lindex $record 2]
|
set commiter [lindex $record 2]
|
||||||
StoreProjectInfo $projectName $projectVersion $projectRelease $timeStamp
|
StoreProjectInfo $timeStamp
|
||||||
# puts "\n \[ [string trim $commiter] \]"
|
# puts "\n \[ [string trim $commiter] \]"
|
||||||
}
|
}
|
||||||
# puts ">> $commiter"
|
# puts ">> $commiter"
|
||||||
if {$commiter ne [lindex $record 2]} {
|
if {$commiter ne [lindex $record 2]} {
|
||||||
puts "\n -- [string trim $commiter] <$email> $timeStamp"
|
puts "\n -- [string trim $commiter] <$email> $timeStamp"
|
||||||
puts "\n$projectName ($projectVersion-$projectRelease) stable; urgency=medium\n"
|
append outText "\n -- [string trim $commiter] <$email> $timeStamp\n"
|
||||||
|
puts "\n$args(--project-name) ($args(--project-version)-$args(--project-release)) stable; urgency=medium\n"
|
||||||
|
append outText "\n$args(--project-name) ($args(--project-version)-$args(--project-release)) stable; urgency=medium\n\n"
|
||||||
set commiter [lindex $record 2]
|
set commiter [lindex $record 2]
|
||||||
# puts "\n \[ [string trim $commiter] \]"
|
# puts "\n \[ [string trim $commiter] \]"
|
||||||
}
|
}
|
||||||
|
|
||||||
set commitTex [lindex $record 4]
|
set commitTex [lindex $record 4]
|
||||||
puts " * $commitTex"
|
puts " * $commitTex"
|
||||||
|
append outText " * $commitTex\n"
|
||||||
|
|
||||||
}
|
}
|
||||||
puts "\n -- [string trim $commiter] <$email> $timeStamp"
|
puts "\n -- [string trim $commiter] <$email> $timeStamp"
|
||||||
|
append outText "\n -- [string trim $commiter] <$email> $timeStamp\n"
|
||||||
|
return $outText
|
||||||
}
|
}
|
||||||
|
|
||||||
proc GenerateChangelogRPM {} {
|
proc GenerateChangelogRPM {} {
|
||||||
|
@ -175,45 +182,104 @@ proc GenerateChangelogTXT {} {
|
||||||
proc ShowHelp {} {
|
proc ShowHelp {} {
|
||||||
puts "\nChangelog generator from the Git commit history. For DEB and RPM packages"
|
puts "\nChangelog generator from the Git commit history. For DEB and RPM packages"
|
||||||
puts "Usage:\n"
|
puts "Usage:\n"
|
||||||
puts "\tchangelog-gen.tcl {DEB RPM TXT}\n"
|
puts "\tchangelog-gen \[options\]\n"
|
||||||
puts "Where{DEB RPM TXT} - changelog format for same packages. The list can be either complete or from any number of elements.\nDefault is a TXT"
|
puts "Where options:"
|
||||||
|
puts "\t--project-name - name of project (package) "
|
||||||
|
puts "\t--project-version - package version"
|
||||||
|
puts "\t--project-release - package release name (number)"
|
||||||
|
puts "\t--deb - debian package format of changelog"
|
||||||
|
puts "\t--rpm - rpm package format of changelog"
|
||||||
|
puts "\t--txt - plain text changelog out"
|
||||||
|
puts "\t--out-file - changelog file name"
|
||||||
|
puts "\t--last - The timestamp since the last launch of this program for a given project"
|
||||||
}
|
}
|
||||||
|
|
||||||
if [info exists env(PROJECT_NAME)] {
|
set arglen [llength $argv]
|
||||||
set projectName $env(PROJECT_NAME)
|
set index 0
|
||||||
# puts $projectName
|
while {$index < $arglen} {
|
||||||
} else {
|
set arg [lindex $argv $index]
|
||||||
puts "You mast set PROJECT_NAME variable \n"
|
switch -exact $arg {
|
||||||
exit
|
--project-name {
|
||||||
}
|
set args($arg) [lindex $argv [incr index]]
|
||||||
if [info exists env(PROJECT_VERSION)] {
|
}
|
||||||
set projectVersion $env(PROJECT_VERSION)
|
--project-version {
|
||||||
# puts $projectVersion
|
set args($arg) [lindex $argv [incr index]]
|
||||||
} else {
|
}
|
||||||
puts "You mast set PROJECT_VERSION variable \n"
|
--project-release {
|
||||||
exit
|
set args($arg) [lindex $argv [incr index]]
|
||||||
}
|
}
|
||||||
if [info exists env(PROJECT_RELEASE)] {
|
--deb {
|
||||||
set projectRelease $env(PROJECT_RELEASE)
|
set args($arg) true
|
||||||
# puts $projectRelease
|
}
|
||||||
} else {
|
--rpm {
|
||||||
puts "You mast set PROJECT_RELEASE variable \n"
|
set args($arg) true
|
||||||
exit
|
}
|
||||||
}
|
--txt {
|
||||||
|
set args($arg) true
|
||||||
if [file exists [file join $dir(cfg) $projectName.conf]] {
|
}
|
||||||
source [file join $dir(cfg) $projectName.conf]
|
--out-file {
|
||||||
}
|
set args($arg) [lindex $argv [incr index]]
|
||||||
|
}
|
||||||
if { $::argc > 1 } {
|
--last {
|
||||||
foreach arg $::argv {
|
set args($arg) true
|
||||||
switch -glob -nocase $arg {
|
}
|
||||||
DEB {GenerateChangelogDEB}
|
--help {
|
||||||
RPM {GenerateChangelogRPM}
|
ShowHelp
|
||||||
TXT {GenerateChangelogTXT}
|
exit
|
||||||
*help {ShowHelp}
|
}
|
||||||
|
default {
|
||||||
|
set filename [lindex $argv $index]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
incr index
|
||||||
ShowHelp
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ![info exists args(--project-name)] {
|
||||||
|
puts "You mast set --project-name option\n"
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
if ![info exists args(--project-version)] {
|
||||||
|
puts "You mast set --project-version option\n"
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
if ![info exists args(--project-release)] {
|
||||||
|
puts "You mast set --project-release option\n"
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
if [file exists [file join $dir(cfg) $args(--project-name).conf]] {
|
||||||
|
source [file join $dir(cfg) $args(--project-name).conf]
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach arg [array names args] {
|
||||||
|
puts "$arg $args($arg)"
|
||||||
|
}
|
||||||
|
|
||||||
|
if [info exists args(--deb)] {
|
||||||
|
set outText [GenerateChangelogDEB]
|
||||||
|
if [info exists args(--out-file)] {
|
||||||
|
if [file exists $args(--out-file)] {
|
||||||
|
if [info exists args(--last)] {
|
||||||
|
set outFile [open $args(--out-file) "r+"]
|
||||||
|
puts $outFile $outText
|
||||||
|
close $outFile
|
||||||
|
} else {
|
||||||
|
set outFile [open $args(--out-file) "w+"]
|
||||||
|
puts $outFile $outText
|
||||||
|
close $outFile
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
set outFile [open $args(--out-file) "w+"]
|
||||||
|
puts $outFile $outText
|
||||||
|
close $outFile
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if [info exists args(--rpm)] {
|
||||||
|
GenerateChangelogRPM
|
||||||
|
}
|
||||||
|
if [info exists args(--txt)] {
|
||||||
|
GenerateChangelogTXT
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user