Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 39 additions & 2 deletions github.ado
Original file line number Diff line number Diff line change
Expand Up @@ -523,9 +523,46 @@ prog define github

quietly copy "`path'" "`packagename'-`version'.zip", replace
quietly unzipfile "`packagename'-`version'.zip", replace
local dir "`packagename'-`version'"
local wd : pwd
qui cd "`dir'"

// The archive's root folder is named by GitHub, and does not always
// equal "<package>-<version>":
//
// * a tag written v1.2.3 unpacks into <package>-1.2.3 (GitHub drops
// the leading "v"), so -version(v1.2.3)- used to stop with r(170)
// on repositories that tag with that prefix;
// * archive/master.zip on a repository whose default branch is main
// unpacks into <package>-main, not <package>-master.
//
// Candidates are tried in order, so the expected name still wins and
// nothing changes for archives that already matched. Directory
// discovery is deliberately NOT used: this command unpacks into the
// user's working directory and leaves the folder there, so a second
// install in the same directory would leave several <package>-*
// folders and make discovery ambiguous.
local candidates "`packagename'-`version'"
if regexm("`version'", "^v[0-9]") {
local stripped = regexr("`version'", "^v", "")
local candidates "`candidates' `packagename'-`stripped'"
}
if "`version'" == "master" local candidates "`candidates' `packagename'-main"
if "`version'" == "main" local candidates "`candidates' `packagename'-master"

local found 0
foreach c of local candidates {
if !`found' {
capture cd "`c'"
if _rc == 0 {
local found 1
local dir "`c'"
Comment on lines +556 to +557
}
}
}
if !`found' {
di as err "cannot locate the folder unpacked from `packagename'-`version'.zip"
di as txt "looked for: `candidates'"
exit 601
}
local pkg : pwd

// check that the package does not include PKG and TOC before `force'
Expand Down