Skip to content

Commit

Permalink
* op-git.el: Fix checkdoc warnings
Browse files Browse the repository at this point in the history
(op/git-all-files):
(op/git-new-branch):
(op/git-change-branch):
(op/git-init-repo):
(op/git-commit-changes):
(op/git-files-changed):
(op/git-last-change-date):
(op/git-remote-name):
(op/git-push-remote):
  • Loading branch information
yantar92 committed Aug 25, 2023
1 parent cfc1a95 commit e1788a8
Showing 1 changed file with 25 additions and 27 deletions.
52 changes: 25 additions & 27 deletions op-git.el
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@
(require 'dash)

(defun op/git-all-files (repo-dir &optional branch)
"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."
"Return a list of all org files in git repository presented by REPO-DIR.
When optional BRANCH is offered, check that branch instead of pointer HEAD."
(let* ((org-file-ext ".org")
(git-repo repo-dir)
(output (git-run "ls-tree" "-r" "--name-only"
Expand All @@ -50,41 +49,40 @@ instead of pointer HEAD."
(git-on-branch)))

(defun op/git-new-branch (repo-dir branch-name)
"This function will create a new branch with BRANCH-NAME, and checkout it."
"Create a new branch with BRANCH-NAME in REPO-DIR, and checkout the branch."
(let ((git-repo repo-dir))
(unless (git-branch? branch-name)
(git-branch branch-name))
(git-checkout branch-name)))

(defun op/git-change-branch (repo-dir branch-name)
"This function will change branch to BRANCH-NAME of git repository presented
by REPO-DIR. Do nothing if it is current branch."
"Change branch to BRANCH-NAME in git repository REPO-DIR.
Do nothing if it is the current branch."
(let ((git-repo repo-dir))
(unless (git-on-branch? branch-name)
(git-checkout branch-name))))

(defun op/git-init-repo (repo-dir)
"This function will initialize a new empty git repository. REPO-DIR is the
directory where repository will be initialized."
"Initialize a new empty git repository in REPO-DIR."
(unless (file-directory-p repo-dir)
(mkdir repo-dir t))
(git-init repo-dir))

(defun op/git-commit-changes (repo-dir message)
"This function will commit uncommitted changes to git repository presented by
REPO-DIR, MESSAGE is the commit message."
"Commit uncommitted changes to git repository in REPO-DIR.
MESSAGE is the commit message."
(let ((git-repo repo-dir))
(git-add)
(git-commit message)))

(defun op/git-files-changed (repo-dir base-commit)
"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.
<TODO>: robust enhance, branch check, etc."
"Get modified/deleted org files from git repositoryin 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. <TODO>: robust enhance, branch check, etc."
(let* ((org-file-ext ".org")
(git-repo (file-name-as-directory repo-dir))
(output (git-run "diff" "--name-status" base-commit "HEAD"))
Expand All @@ -99,26 +97,26 @@ only two types will work well: need to publish or need to delete.
(list :update upd-list :delete del-list)))

(defun op/git-last-change-date (repo-dir filepath)
"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."
"Return the last commit date of a file in git repository REPO-DIR.
FILEPATH is the path of target file, can be absolute or relative."
(let* ((git-repo repo-dir)
(output (git-run "log" "-1" "--format=\"%ci\"" "--" filepath)))
(when (string-match "\\`\"\\([0-9]+-[0-9]+-[0-9]+\\) .*\"\n\\'" output)
(match-string 1 output))))

(defun op/git-remote-name (repo-dir)
"This function will return all remote repository names of git repository
presented by REPO-DIR, return nil if there is no remote repository."
"Return all remote repository names of git repository REPO-DIR.
Return nil if there is no remote repository."
(let ((git-repo repo-dir))
(git-remotes)))

(defun op/git-push-remote (repo-dir remote-repo branch)
"This function will push local branch to remote repository, REPO-DIR is the
local git repository, REMOTE-REPO is the remote repository, BRANCH is the name
of branch will be pushed (the branch name will be the same both in local and
remote repository), and if there is no branch named BRANCH in remote repository,
it will be created."
"Push local branch to remote repository.
REPO-DIR is the local git repository. REMOTE-REPO is the remote
repository. BRANCH is the name of branch will be pushed (the branch
name will be the same both in local and remote repository), and if
there is no branch named BRANCH in remote repository, it will be
created."
(let ((git-repo repo-dir))
(git-push remote-repo branch)))

Expand Down

0 comments on commit e1788a8

Please sign in to comment.