Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This is a stack that will fix the LiveCode repo to point to their new username. While we are poking around it also fixes the submodule remotes to point to your forks of them.
script "RepoFixer"
on preOpenCard
create button "Fix Repo"
set the rect of it to 10,10,100,33
create field "Username"
set the rect of it to 10,40,100,61
set the visible of me to true
end preOpenCard
on mouseUp
if the short name of the target is "Fix Repo" then
put field "Username" into theUsername
if theUsername is empty then
answer "If you don't enter your github username we can't fix the submodules to point origin to your fork." with "Continue and live to regret it" or "Cancel"
if it is "Cancel" then
exit mouseUp
end if
end if
answer folder "Choose LiveCode repo"
put it into theRepo
if theRepo is not empty then
put the folder into theOldFolder
set the folder to theRepo
-- remotes for main repo
put shell("git remote show") into theRemotes
repeat for each line theRemote in theRemotes
put shell("git ls-remote --get-url" && theRemote) into theRemoteURL
if theRemoteURL contains "runrev/" then
replace "runrev/" with "livecode/" in theRemoteURL
put shell("git remote set-url" && theRemote && theRemoteURL) & return after msg
end if
end repeat
-- remotes for submodules
repeat for each word theSubmodule in "ide thirdparty"
set the folder to theRepo & slash & theSubmodule
put shell("git remote show") into theRemotes
put the number of lines of theRemotes is 1 and line 1 of theRemotes is "origin" into setUpstream
repeat for each line theRemote in theRemotes
put shell("git ls-remote --get-url" && theRemote) into theRemoteURL
if theRemoteURL contains "runrev/" then
if setUpstream then
put shell("git remote rename origin upstream")
replace "runrev/" with "livecode/" in theRemoteURL
put shell("git remote set-url upstream" && theRemoteURL) & return after msg
replace "livecode/" with theUsername&"/" in theRemoteURL
put shell("git remote add origin" && theRemoteURL) & return after msg
else
replace "runrev/" with "livecode/" in theRemoteURL
put shell("git remote set-url" && theRemote && theRemoteURL) & return after msg
end if
end if
end repeat
end repeat
set the folder to theOldFolder
end if
end if
end mouseUp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.