text stringlengths 0 15.7k | source stringlengths 6 112 |
|---|---|
return desc_text | GitSync.applescript |
end sequence_description | GitSync.applescript |
on description_paragraph(the_list, prefix_text) | GitSync.applescript |
if (length of the_list > 0) then | GitSync.applescript |
set the_suffix to " file" | GitSync.applescript |
if (length of the_list > 1) then set the_suffix to the_suffix & "s" --multiple | GitSync.applescript |
set desc_text to desc_text & prefix_text & length of the_list & the_suffix & ":" & return | GitSync.applescript |
repeat with the_item in the_list | GitSync.applescript |
set desc_text to desc_text & (file_name of the_item) & return | GitSync.applescript |
end description_paragraph | GitSync.applescript |
script StatusUtil | GitSync.applescript |
on generate_status_list(local_repo_path) | GitSync.applescript |
set the_status to GitParser's status(local_repo_path, "-s") -- the -s stands for short message, and returns a short version of the status message, the short stauslist is used because it is easier to parse than the long status list | GitSync.applescript |
set the_status_list to TextParser's every_paragraph(the_status) --store each line as items in a list | GitSync.applescript |
set transformed_list to {} | GitSync.applescript |
if (length of the_status_list > 0) then | GitSync.applescript |
set transformed_list to my transform_status_list(the_status_list) | GitSync.applescript |
return transformed_list | GitSync.applescript |
end generate_status_list | GitSync.applescript |
on transform_status_list(the_status_list) | GitSync.applescript |
repeat with the_status_item in the_status_list | GitSync.applescript |
set the_status_parts to RegExpUtil's match(the_status_item, "^( )*([MARDU?]{1,2}) (.+)$") --returns 3 capturing groups, | GitSync.applescript |
if ((second item in the_status_parts) = " ") then --aka " M", remember that the second item is the first capturing group | GitSync.applescript |
set cmd to third item in the_status_parts --Changes not staged for commit: | GitSync.applescript |
set state to "Changes not staged for commit" -- you need to add them | GitSync.applescript |
else -- Changes to be committed--aka "M " or "??" or "UU" | GitSync.applescript |
set cmd to third item in the_status_parts --rename cmd to type | GitSync.applescript |
if (cmd = "??") then | GitSync.applescript |
set state to "Untracked files" | GitSync.applescript |
else if (cmd = "UU") then --Unmerged path | GitSync.applescript |
set state to "Unmerged path" | GitSync.applescript |
set state to "Changes to be committed" --this is when the file is ready to be commited | GitSync.applescript |
set file_name to the fourth item in the_status_parts | GitSync.applescript |
set status_item to {state:state, cmd:cmd, file_name:file_name} --store the individual parts in an accociative | GitSync.applescript |
set transformed_list to ListModifier's add_list(transformed_list, status_item) --add a record to a list | GitSync.applescript |
end transform_status_list | GitSync.applescript |
on process_status_list(local_repo_path, status_list) | GitSync.applescript |
set state to state of status_item | GitSync.applescript |
set file_name to file_name of status_item | GitSync.applescript |
if state = "Untracked files" then --this is when there exists a new file | GitSync.applescript |
log tab & "1. " & "Untracked files" | GitSync.applescript |
GitModifier's add(local_repo_path, file_name) --add the file to the next commit | GitSync.applescript |
else if state = "Changes not staged for commit" then --this is when you have not added a file that has changed to the next commit | GitSync.applescript |
log tab & "2. " & "Changes not staged for commit" | GitSync.applescript |
else if state = "Changes to be committed" then --this is when you have added a file to the next commit, but not commited it | GitSync.applescript |
log tab & "3. " & "Changes to be committed" --do nothing here | GitSync.applescript |
else if state = "Unmerged path" then --This is when you have files that have to be resolved first, but eventually added aswell | GitSync.applescript |
log tab & "4. " & "Unmerged path" | GitSync.applescript |
end process_status_list | GitSync.applescript |
script RepoUtil | GitSync.applescript |
on compile_repo_list(file_path) -- rename to generate_repo_list? | GitSync.applescript |
set theXMLRoot to XMLParser's root(file_path) | GitSync.applescript |
set num_children to length of XMLParser's every_element(theXMLRoot) --number of xml children in xml root element | GitSync.applescript |
set the_repo_list to {} | GitSync.applescript |
repeat with i from 1 to num_children | GitSync.applescript |
set theXMLChild to XMLParser's element_at(theXMLRoot, i) | GitSync.applescript |
set local_path to XMLParser's attribute_value_by_name(theXMLChild, "local-path") --this is the path to the local repository (we need to be in this path to execute git commands on this repo) | GitSync.applescript |
set local_path to do shell script "echo " & quoted form of local_path & " | sed 's/ /\\\\ /g'" --Shell doesnt handle file paths with space chars very well. So all space chars are replaced with a backslash and space, so that shell can read the paths. | GitSync.applescript |
set remote_path to XMLParser's attribute_value_by_name(theXMLChild, "remote-path") | GitSync.applescript |
set is_full_url to RegExpUtil's has_match(remote_path, "^https://.+$") --support for partial and full url | GitSync.applescript |
if is_full_url = true then | GitSync.applescript |
set remote_path to text 9 thru (length of remote_path) of remote_path --strip away the https://, since this will be added later | GitSync.applescript |
set keychain_item_name to XMLParser's attribute_value_by_name(theXMLChild, "keychain-item-name") | GitSync.applescript |
set interval to XMLParser's attribute_value_by_name(theXMLChild, "interval") --default is 30min | GitSync.applescript |
set key_value_pairs to {local_path:local_path, remote_path:remote_path, keychain_item_name:keychain_item_name, interval:interval} --remote_account_name:remote_account_name,commit_int:commit_int, push_int:push_int--TODO: shouldnt the line bellow be sudo acociative list? or does the record style list work as is?, if you ... | GitSync.applescript |
set the_repo_list to ListModifier's add_list(the_repo_list, key_value_pairs) | GitSync.applescript |
return the_repo_list | GitSync.applescript |
end compile_repo_list | GitSync.applescript |
on repo_xml() | GitSync.applescript |
set the_repo_xml to "<repositories>" & return --beginning | GitSync.applescript |
set the_repo_xml to the_repo_xml & tab & "<repository local-path=\"~/_projects/_code/_active/applescript/GitSync\" remote-path=\"https://github.com/eonist/GitSync.git\" interval=\"1\" keychain-item-name=\"github\"/>" & return | GitSync.applescript |
set the_repo_xml to the_repo_xml & tab & "<repository local-path=\"~/_projects/_code/_active/applescript/SqliteEdit/repo\" remote-path=\"github.com/eonist/SqliteEdit.git\" interval=\"1\" keychain-item-name=\"github\"/>" & return | GitSync.applescript |
set the_repo_xml to the_repo_xml & tab & "<repository local-path=\"~/Library/Scripts\" remote-path=\"github.com/eonist/applescripts.git\" interval=\"1\" keychain-item-name=\"github\"/>" & return | GitSync.applescript |
set the_repo_xml to the_repo_xml & tab & "<repository local-path=\"~/Documents/wiki/GitSync.wiki\" remote-path=\"github.com/eonist/GitSync.wiki\" interval=\"1\" keychain-item-name=\"github\"/>" & return | GitSync.applescript |
set the_repo_xml to the_repo_xml & "</repositories>" --end | GitSync.applescript |
return the_repo_xml | GitSync.applescript |
end repo_xml | GitSync.applescript |
script MergeUtil | GitSync.applescript |
on manual_merge(local_path, remote_path, branch) | GitSync.applescript |
log ("MergeUtil's manual_merge()") | GitSync.applescript |
if (GitAsserter's has_unmerged_paths(local_path)) then --Asserts if there are unmerged paths that needs resolvment | GitSync.applescript |
my MergeUtil's resolve_merge_conflicts(local_path, branch, GitParser's unmerged_files(local_path)) --Asserts if there are unmerged paths that needs resolvment | GitSync.applescript |
do_commit(local_path) --its best practice to always commit any uncommited files before you attempt to pull. | GitSync.applescript |
GitUtil's manual_pull(local_path, remote_path, branch) --manual clone down files | GitSync.applescript |
on error errMsg --merge conflicts | GitSync.applescript |
log tab & "error: " & errMsg | GitSync.applescript |
set unmerged_files to GitParser's unmerged_files(local_path) --compile a list of conflicting files somehow | GitSync.applescript |
resolve_merge_conflicts(local_path, branch, unmerged_files) --promt user, merge conflicts occured, resolve by a list of options, title: conflict in file text.txt: use local, use remote, use a mix (opens it up in textedit), use all local, use all remote, use all mix | GitSync.applescript |
do_commit(local_path) --add,commit if any files has an altered status | GitSync.applescript |
end manual_merge | GitSync.applescript |
on resolve_merge_conflicts(local_repo_path, branch, unmerged_files) | GitSync.applescript |
log ("MergeUtil's resolve_merge_conflicts()") | GitSync.applescript |
repeat with unmerged_file in unmerged_files | GitSync.applescript |
set last_selected_action to first item in options --you may want to make this a "property" to store the last item more permenantly | GitSync.applescript |
set the_action to choose from list options with title "Resolve merge conflict in:" with prompt unmerged_file & ":" default items {last_selected_action} cancel button name "Exit" --promt user with list of options, title: Merge conflict in: unmerged_file | GitSync.applescript |
handle_merge_conflict_dialog(the_action, unmerged_file, local_repo_path, branch, unmerged_files) | GitSync.applescript |
end resolve_merge_conflicts | GitSync.applescript |
on handle_merge_conflict_dialog(the_action, unmerged_file, local_repo_path, branch, unmerged_files) | GitSync.applescript |
log ("MergeUtil's handle_merge_conflict_dialog(): " & (item 1 of the_action)) | GitSync.applescript |
if the_action is false then --exit | GitSync.applescript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.