text stringlengths 0 15.7k | source stringlengths 6 112 |
|---|---|
else --deploy mode | GitSync.applescript |
set repo_file_path to ((path to me) & "Contents" & ":" & "Resources" & ":" & "repo.xml") as text | GitSync.applescript |
if (FileAsserter's does_file_exist(repo_file_path) = false) then --if the xml is empty, add some static values to it | GitSync.applescript |
set the_repo_xml to my RepoUtil's repo_xml() | GitSync.applescript |
FileModifier's write_data(the_repo_xml, repo_file_path, false) --create the repo.xml file inside the GitSync.app | GitSync.applescript |
end if --else do nothing, the repo.xml already exists | GitSync.applescript |
on idle {} | GitSync.applescript |
return the_interval --the_interval --return new idle time in seconds | GitSync.applescript |
on handle_interval() | GitSync.applescript |
log "handle_interval()" | GitSync.applescript |
set repo_list to my RepoUtil's compile_repo_list(repo_file_path) --try to avoid calling this on every intervall, its nice to be able to update on the fly, be carefull though | GitSync.applescript |
set current_time_in_min to (current_time / 60) --divide the seconds by 60 seconds to get minutes | GitSync.applescript |
log "current_time_in_min: " & current_time_in_min | GitSync.applescript |
repeat with repo_item in repo_list --iterate over every repo item | GitSync.applescript |
if (current_time_in_min mod (interval of repo_item) = 0) then handle_commit_interval(repo_item, "master") --is true every time spesified by the user | GitSync.applescript |
if (current_time_in_min mod (interval of repo_item) = 0) then handle_push_interval(repo_item, "master") --is true every time spesified by the user | GitSync.applescript |
set current_time to current_time + the_interval --increment the interval (in seconds) | GitSync.applescript |
end handle_interval | GitSync.applescript |
on handle_commit_interval(repo_item, branch) | GitSync.applescript |
log "GitSync's handle_commit_interval() a repo with remote path: " & (remote_path of repo_item) & " local path: " & (local_path of repo_item) | GitSync.applescript |
if (GitAsserter's has_unmerged_paths(local_path of repo_item)) then --Asserts if there are unmerged paths that needs resolvment | GitSync.applescript |
log tab & "has unmerged paths to resolve" | GitSync.applescript |
my MergeUtil's resolve_merge_conflicts(local_path of repo_item, branch, GitParser's unmerged_files(local_path of repo_item)) --Asserts if there are unmerged paths that needs resolvment | GitSync.applescript |
log do_commit(local_path of repo_item) --if there were no commits false will be returned | GitSync.applescript |
end handle_commit_interval | GitSync.applescript |
on handle_push_interval(repo_item, branch) | GitSync.applescript |
log ("GitSync's handle_push_interval()") | GitSync.applescript |
my MergeUtil's manual_merge((local_path of repo_item), (remote_path of repo_item), branch) --commits, merges with promts, (this method also test if a merge is needed or not, and skips it if needed) | GitSync.applescript |
set has_local_commits to GitAsserter's has_local_commits((local_path of repo_item), branch) --TODO: maybe use GitAsserter's is_local_branch_ahead instead of this line | GitSync.applescript |
if (has_local_commits) then --only push if there are commits to be pushed, hence the has_commited flag, we check if there are commits to be pushed, so we dont uneccacerly push if there are no local commits to be pushed, we may set the commit interval and push interval differently so commits may stack up until its ready... | GitSync.applescript |
set the_keychain_item_name to (keychain_item_name of repo_item) | GitSync.applescript |
log "the_keychain_item_name: " & the_keychain_item_name | GitSync.applescript |
set keychain_data to KeychainParser's keychain_data(keychain_item_name of repo_item) | GitSync.applescript |
set keychain_password to the_password of keychain_data | GitSync.applescript |
log "keychain_password: " & keychain_password | GitSync.applescript |
set remote_account_name to account_name of keychain_data | GitSync.applescript |
log "remote_account_name: " & remote_account_name | GitSync.applescript |
set push_call_back to GitModifier's push(local_path of repo_item, remote_path of repo_item, remote_account_name, keychain_password, branch) | GitSync.applescript |
log "push_call_back: " & push_call_back | GitSync.applescript |
end handle_push_interval | GitSync.applescript |
on do_commit(local_repo_path) | GitSync.applescript |
log ("GitSync's do_commit()") | GitSync.applescript |
set status_list to my StatusUtil's generate_status_list(local_repo_path) --get current status | GitSync.applescript |
if (length of status_list > 0) then | GitSync.applescript |
log tab & "there is something to add or commit" | GitSync.applescript |
my StatusUtil's process_status_list(local_repo_path, status_list) --process current status by adding files, now the status has changed, some files may have disapared, some files now have status as renamed that prev was set for adding and del | GitSync.applescript |
set commit_msg_title to my CommitUtil's sequence_commit_msg_title(status_list) --sequence commit msg title for the commit | GitSync.applescript |
log tab & "commit_msg_title: " & commit_msg_title | GitSync.applescript |
set commit_msg_desc to my DescUtil's sequence_description(status_list) --sequence commit msg description for the commit | GitSync.applescript |
log tab & "commit_msg_desc: " & commit_msg_desc | GitSync.applescript |
set commit_result to GitModifier's commit(local_repo_path, commit_msg_title, commit_msg_desc) --commit | GitSync.applescript |
log tab & "commit_result: " & commit_result | GitSync.applescript |
log tab & "----------------ERROR:-----------------" & errMsg | GitSync.applescript |
return true --return true to indicate that the commit completed | GitSync.applescript |
log tab & "nothing to add or commit" | GitSync.applescript |
return false --break the flow since there is nothing to commit or process | GitSync.applescript |
end do_commit | GitSync.applescript |
script CommitUtil | GitSync.applescript |
on sequence_commit_msg_title(status_list) | GitSync.applescript |
set num_of_new_files to 0 | GitSync.applescript |
set num_of_modified_files to 0 | GitSync.applescript |
set num_of_deleted_files to 0 | GitSync.applescript |
set num_of_renamed_files to 0 | GitSync.applescript |
repeat with status_item in status_list | GitSync.applescript |
set cmd to cmd of status_item --TODO: rename to type or status_type | GitSync.applescript |
if (cmd = "M") then | GitSync.applescript |
set num_of_modified_files to num_of_modified_files + 1 | GitSync.applescript |
else if (cmd = "D") then | GitSync.applescript |
set num_of_deleted_files to num_of_deleted_files + 1 | GitSync.applescript |
else if (cmd = "A") then | GitSync.applescript |
set num_of_new_files to num_of_new_files + 1 | GitSync.applescript |
else if (cmd = "R") then --This command seems to never be triggered in git | GitSync.applescript |
set num_of_renamed_files to num_of_renamed_files + 1 | GitSync.applescript |
else if (cmd = "??") then --untracked files, | GitSync.applescript |
else if (cmd = "UU") then --unmerged files, | GitSync.applescript |
set commit_msg to "" | GitSync.applescript |
if (num_of_new_files > 0) then | GitSync.applescript |
set commit_msg to commit_msg & "New files added: " & num_of_new_files | GitSync.applescript |
if (num_of_modified_files > 0) then | GitSync.applescript |
if (length of commit_msg > 0) then set commit_msg to commit_msg & ", " --append comma | GitSync.applescript |
set commit_msg to commit_msg & "Files modified: " & num_of_modified_files | GitSync.applescript |
if (num_of_deleted_files > 0) then | GitSync.applescript |
set commit_msg to commit_msg & "Files deleted: " & num_of_deleted_files | GitSync.applescript |
if (num_of_renamed_files > 0) then | GitSync.applescript |
set commit_msg to commit_msg & "Files renamed: " & num_of_renamed_files | GitSync.applescript |
return commit_msg | GitSync.applescript |
end sequence_commit_msg_title | GitSync.applescript |
script DescUtil | GitSync.applescript |
on sequence_description(status_list) | GitSync.applescript |
set desc_text to "" | GitSync.applescript |
set modified_items to {} | GitSync.applescript |
set deleted_items to {} | GitSync.applescript |
set added_items to {} | GitSync.applescript |
if (cmd of status_item is "D") then set deleted_items to ListModifier's add_list(deleted_items, status_item) --add a record to a list | GitSync.applescript |
if (cmd of status_item is "M") then set modified_items to ListModifier's add_list(modified_items, status_item) --add a record to a list | GitSync.applescript |
if (cmd of status_item is "??") then set added_items to ListModifier's add_list(added_items, status_item) --add a record to a list | GitSync.applescript |
if (cmd of status_item is "UU") then set modified_items to ListModifier's add_list(modified_items, status_item) --add a record to a list | GitSync.applescript |
set desc_text to desc_text & description_paragraph(added_items, "Added ") & return --add an extra line break at the end "paragraph like" | GitSync.applescript |
set desc_text to desc_text & description_paragraph(deleted_items, "Deleted ") & return | GitSync.applescript |
set desc_text to desc_text & description_paragraph(modified_items, "Modified ") | GitSync.applescript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.