Hi all,
I want to create a mail rule that triggers on SVN commit mails from five different projects. When these arrive the triggered AppleScript should figure out from which project this comes and then run a shell script depending on the project.
so far I have
set xu4 to "xU4"
set exult to "Exult"
set pent to "Pentagram"
set dos to "DOSBox"
set nuvie to "Nuvie"
using terms from application "Mail"
on perform mail action with messages theMessages for rule theRule
tell application "Mail"
repeat with eachMessage in theMessages
if the subject begins with "[" & xu4 and body contains "trunk/" & xu4 then
set subj to xu4
else if the subject begins with "[" & exult and body contains exult & "/trunk" then
set subj to exult
else if the subject begins with "[" & pent and body contains pent & "/trunk" then
set subj to pent
else if the subject begins with "[" & dos and body contains dos & "/trunk" then
set subj to dos
else if the subject begins with "[" & nuvie and body contains nuvie & "/trunk" then
set subj to nuvie
end if
end repeat
end tell
end perform mail action with messages
end using terms from
tell application "Mail"
activate
set snapshotdialog to display dialog "TEST!!! Build " & subj & " snapshot?" buttons {"Cancel", "OK"} giving up after 2 with icon caution with title subj
if button returned of snapshotdialog = "OK" or gave up of snapshotdialog is true then
tell application "Terminal"
activate
tell application "System Events" to tell process "Terminal" to keystroke "t" using {command down}
delay 1
do script "cd ~/code/sh; . " & subj & "snapshot.sh" in selected tab of the front window
end tell
end if
end tell
or
set xu4 to "xU4"
set exult to "Exult"
set pent to "Pentagram"
set dos to "DOSBox"
set nuvie to "Nuvie"
using terms from application "Mail"
on perform mail action with messages theMessages for rule theRule
tell application "Mail"
repeat with eachMessage in theMessages
if the subject begins with "[" & xu4 and body contains "trunk/" & xu4 then
set subj to xu4
else if the subject begins with "[" & exult and body contains exult & "/trunk" then
set subj to exult
else if the subject begins with "[" & pent and body contains pent & "/trunk" then
set subj to pent
else if the subject begins with "[" & dos and body contains dos & "/trunk" then
set subj to dos
else if the subject begins with "[" & nuvie and body contains nuvie & "/trunk" then
set subj to nuvie
end if
activate
set snapshotdialog to display dialog "TEST!!! Build " & subj & " snapshot?" buttons {"Cancel", "OK"} giving up after 2 with icon caution with title subj
if button returned of snapshotdialog = "OK" or gave up of snapshotdialog is true then
tell application "Terminal"
activate
tell application "System Events" to tell process "Terminal" to keystroke "t" using {command down}
delay 1
do script "cd ~/code/sh; . " & subj & "snapshot.sh" in selected tab of the front window
end tell
end if
end repeat
end tell
end perform mail action with messages
end using terms from
but I can’t get this to run, anyone got any pointers? Or how to slim down the long if/else if loop?