;ELC ;;; Compiled ;;; in Emacs version 28.0.50 ;;; with all optimizations. (byte-code "\300\301!\210\300\302!\210\300\303!\210\300\304!\207" [require ox ht op-util op-vars] 2) #@119 This function will verify whether REPO-DIR is a valid git repository. TODO: may add branch/commit verification later. (defalias 'op/verify-git-repository #[(repo-dir) "\301!\205\f\301\302\303\"!?\205\304\305\"\207" [repo-dir file-directory-p expand-file-name ".git/" error "Fatal: `%s' is not a valid git repository."] 4 (#$ . 189)]) #@162 This function execute shell commands in a specified directory. If NEED-GIT is non-nil, then DIR must be a git repository. COMMAND is the command to be executed. (defalias 'op/shell-command #[(dir command &optional need-git) "\203\305 !\210r\306\n!q\210\307 \210\310 !\311\f\312\313#\210\314 )\207" [need-git dir op/temp-buffer-name default-directory command op/verify-git-repository get-buffer-create erase-buffer file-name-as-directory shell-command t nil buffer-string] 4 (#$ . 536)]) #@177 This function will return a list contains all org files in git repository presented by REPO-DIR, if optional BRANCH is offered, will check that branch instead of pointer HEAD. (defalias 'op/git-all-files #[(repo-dir &optional branch) "\304\305\306 \206 \307P\310#\311\312\313\314\315\n\316\"\"\"*\207" [repo-dir branch output org-file-ext ".org" op/shell-command "git ls-tree -r --name-only " "HEAD" t delq nil mapcar #[(line) "\303 \304#\205\f\305 \n\"\207" [org-file-ext line repo-dir string-suffix-p t expand-file-name] 4] split-string "\n"] 7 (#$ . 1034)]) #@72 Return name of current branch of git repository presented by REPO-DIR. (defalias 'op/git-branch-name #[(repo-dir) "\302!\303\304\305#\306\307\310 #*\207" [repo-dir output file-name-as-directory op/shell-command "git rev-parse --abbrev-ref HEAD" t replace-regexp-in-string "[\n ]" ""] 5 (#$ . 1607)]) #@110 This function will create a new branch with BRANCH-NAME, and checkout it. TODO: verify if the branch exists. (defalias 'op/git-new-branch #[(repo-dir branch-name) "\303!\304\305 P\306#\307\310\n\"?\205\311\312 \"*\207" [repo-dir branch-name output file-name-as-directory op/shell-command "git checkout -b " t string-match "Switched to a new branch" error "Fatal: Failed to create a new branch with name '%s'."] 5 (#$ . 1918)]) #@126 This function will change branch to BRANCH-NAME of git repository presented by REPO-DIR. Do nothing if it is current branch. (defalias 'op/git-change-branch #[(repo-dir branch-name) "\303!\304\305 P\306#\307\310\n\"\205\311\312 #*\207" [repo-dir branch-name output file-name-as-directory op/shell-command "git checkout " t string-match "\\`error" error "Failed to change branch to '%s' of repository '%s'."] 5 (#$ . 2358)]) #@123 This function will initialize a new empty git repository. REPO-DIR is the directory where repository will be initialized. (defalias 'op/git-init-repo #[(repo-dir) "\301!\204 \302\303\"\210\304\305\306\307\310#\"?\205\311\312\"\207" [repo-dir file-directory-p mkdir t string-prefix-p "Initialized empty Git repository" op/shell-command "git init" nil error "Fatal: Failed to initialize new git repository '%s'."] 6 (#$ . 2796)]) #@119 This function will commit uncommitted changes to git repository presented by REPO-DIR, MESSAGE is the commit message. (defalias 'op/git-commit-changes #[(repo-dir message) "\303!\304\305\306\307#\210\305\310\311\n\"\307#\312\313 \"?\205!\314\315\"*\207" [repo-dir output message file-name-as-directory nil op/shell-command "git add ." t format "git commit -m \"%s\"" string-match "\\[.* .*\\]" error "Failed to commit changes on current branch of repository '%s'."] 5 (#$ . 3238)]) #@442 This function can get modified/deleted org files from git repository presented by REPO-DIR, diff based on BASE-COMMIT. The return value is a property list, property :update maps a list of updated/added files, property :delete maps a list of deleted files. For git, there are three types: Added, Modified, Deleted, but for org-page, only two types will work well: need to publish or need to delete. : robust enhance, branch check, etc. (defalias 'op/git-files-changed #[(repo-dir base-commit) "\306\307!\310\311 \312Q\313#\314\211\315\316\317\f\320\"\"\210\321 \322\nF-\207" [repo-dir base-commit del-list upd-list output org-file-ext ".org" file-name-as-directory op/shell-command "git diff --name-status " " HEAD" t nil mapc #[(line) "\304\305\"\203 \306\307\"P\nB\304\310\"\205! \306\307\"P B\211\207" [line repo-dir upd-list del-list string-match "\\`[A|M] \\(.*.org\\)\\'" match-string 1 "\\`D \\(.*.org\\)\\'"] 4] split-string "\n" :update :delete] 7 (#$ . 3735)]) #@165 This function will return the last commit date of a file in git repository presented by REPO-DIR, FILEPATH is the path of target file, can be absolute or relative. (defalias 'op/git-last-change-date #[(repo-dir filepath) "\303!\304\305 \306Q\307#\310\311\n\"\205\312\313\n\"*\207" [repo-dir filepath output file-name-as-directory op/shell-command "git log -1 --format=\"%ci\" -- \"" "\"" t string-match "\\`\\([0-9]+-[0-9]+-[0-9]+\\) .*\n\\'" match-string 1] 6 (#$ . 4734)]) #@141 This function will return all remote repository names of git repository presented by REPO-DIR, return nil if there is no remote repository. (defalias 'op/git-remote-name #[(repo-dir) "\302!\303\304\305#\306\307\310 \311\"\"*\207" [repo-dir output file-name-as-directory op/shell-command "git remote" t delete "" split-string "\n"] 5 (#$ . 5222)]) (provide 'op-git)