[137943] branches/gsoc15-portfile/github2port/github2port
chunyang at macports.org
chunyang at macports.org
Tue Jun 23 10:06:04 PDT 2015
Revision: 137943
https://trac.macports.org/changeset/137943
Author: chunyang at macports.org
Date: 2015-06-23 10:06:03 -0700 (Tue, 23 Jun 2015)
Log Message:
-----------
github2port: Simplify regexp use and use list rather than concat for making proc return
Modified Paths:
--------------
branches/gsoc15-portfile/github2port/github2port
Modified: branches/gsoc15-portfile/github2port/github2port
===================================================================
--- branches/gsoc15-portfile/github2port/github2port 2015-06-23 15:52:16 UTC (rev 137942)
+++ branches/gsoc15-portfile/github2port/github2port 2015-06-23 17:06:03 UTC (rev 137943)
@@ -22,50 +22,61 @@
expr {$val ne "" ? $val : $def}
}
-proc parse_tarball_name {v} {
+# Extract version and tag_prefix from tarball name, e.g., v0.2.3.tar.gz and v_0.1.2.tar.gz
+proc parse_tarball_name {tarball_name} {
set version ""
set tag_prefix ""
- if {[regexp {[0-9]+([.-][0-9]+)+} $v version]} {
- if {[string length $version] < [string length $v]} {
- set tag_prefix [string range $v 0 [expr [string first $version $v] -1]]
- }
+ if {[regexp -indices {[0-9]+([.-][0-9]+)+} $tarball_name location]} {
+ set version [string range $tarball_name {*}$location]
+ set tag_prefix [string range $tarball_name 0 [expr [lindex $location 0]-1]]
}
return [list $version $tag_prefix]
}
proc parse_github_url {url} {
array set urlparts [uri::split $url]
-
if {![string equal $urlparts(host) github.com]} {
return -code error \
"expected github url but got \"$url\""
}
+ set res {}
+
set path [split $urlparts(path) /]
- set author [lindex $path 0]
- set project [lindex $path 1]
+ set author [lindex $path 0] ; lappend res $author
+ set project [lindex $path 1] ; lappend res $project
+
set tarball [lindex $path end]
+ foreach i [parse_tarball_name $tarball] {
+ lappend res $i
+ }
set tarball_from [expr {[string match */releases/download/* $url] ? "release" : ""}]
+ lappend res $tarball_from
- return [concat $author $project [parse_tarball_name $tarball] $tarball_from]
+ return $res
}
proc parse_bitbucket_url {url} {
array set urlparts [uri::split $url]
-
if {![string equal $urlparts(host) bitbucket.org]} {
return -code error \
"expected bitbucket url but got \"$url\""
}
+ set res {}
+
set path [split $urlparts(path) /]
- set author [lindex $path 0]
- set project [lindex $path 1]
+ set author [lindex $path 0] ; lappend res $author
+ set project [lindex $path 1] ; lappend res $project
+
set tarball [lindex $path end]
+ foreach i [parse_tarball_name $tarball] {
+ lappend res $i
+ }
- return [concat $author $project [parse_tarball_name $tarball]]
+ return $res
}
proc request_github {author project} {
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20150623/b7d3e9cf/attachment.html>
More information about the macports-changes
mailing list