33
33
(require 'dash )
34
34
35
35
(defun op/git-all-files (repo-dir &optional branch )
36
- " This function will return a list contains all org files in git repository
37
- presented by REPO-DIR, if optional BRANCH is offered, will check that branch
38
- instead of pointer HEAD."
36
+ " Return a list of all org files in git repository presented by REPO-DIR.
37
+ When optional BRANCH is offered, check that branch instead of pointer HEAD."
39
38
(let* ((org-file-ext " .org" )
40
39
(git-repo repo-dir)
41
40
(output (git-run " ls-tree" " -r" " --name-only"
@@ -50,41 +49,40 @@ instead of pointer HEAD."
50
49
(git-on-branch)))
51
50
52
51
(defun op/git-new-branch (repo-dir branch-name )
53
- " This function will create a new branch with BRANCH-NAME, and checkout it ."
52
+ " Create a new branch with BRANCH-NAME in REPO-DIR , and checkout the branch ."
54
53
(let ((git-repo repo-dir))
55
54
(unless (git-branch? branch-name)
56
55
(git-branch branch-name))
57
56
(git-checkout branch-name)))
58
57
59
58
(defun op/git-change-branch (repo-dir branch-name )
60
- " This function will change branch to BRANCH-NAME of git repository presented
61
- by REPO-DIR. Do nothing if it is current branch."
59
+ " Change branch to BRANCH-NAME in git repository REPO-DIR.
60
+ Do nothing if it is the current branch."
62
61
(let ((git-repo repo-dir))
63
62
(unless (git-on-branch? branch-name)
64
63
(git-checkout branch-name))))
65
64
66
65
(defun op/git-init-repo (repo-dir )
67
- " This function will initialize a new empty git repository. REPO-DIR is the
68
- directory where repository will be initialized."
66
+ " Initialize a new empty git repository in REPO-DIR."
69
67
(unless (file-directory-p repo-dir)
70
68
(mkdir repo-dir t ))
71
69
(git-init repo-dir))
72
70
73
71
(defun op/git-commit-changes (repo-dir message )
74
- " This function will commit uncommitted changes to git repository presented by
75
- REPO-DIR, MESSAGE is the commit message."
72
+ " Commit uncommitted changes to git repository in REPO-DIR.
73
+ MESSAGE is the commit message."
76
74
(let ((git-repo repo-dir))
77
75
(git-add)
78
76
(git-commit message)))
79
77
80
78
(defun op/git-files-changed (repo-dir base-commit )
81
- " This function can get modified/deleted org files from git repository
82
- presented by REPO-DIR, diff based on BASE-COMMIT. The return value is a
83
- property list, property :update maps a list of updated/added files, property
84
- :delete maps a list of deleted files.
85
- For git, there are three types: Added, Modified, Deleted, but for org-page,
86
- only two types will work well: need to publish or need to delete.
87
- <TODO>: robust enhance, branch check, etc."
79
+ " Get modified/deleted org files from git repositoryin REPO-DIR.
80
+ Diff based on BASE-COMMIT.
81
+ The return value is a property list, property :update maps a list of
82
+ updated/added files, property :delete maps a list of deleted files.
83
+ For git, there are three types: Added, Modified, Deleted, but for
84
+ org-page, only two types will work well: need to publish or need to
85
+ delete. <TODO>: robust enhance, branch check, etc."
88
86
(let* ((org-file-ext " .org" )
89
87
(git-repo (file-name-as-directory repo-dir))
90
88
(output (git-run " diff" " --name-status" base-commit " HEAD" ))
@@ -99,26 +97,26 @@ only two types will work well: need to publish or need to delete.
99
97
(list :update upd-list :delete del-list)))
100
98
101
99
(defun op/git-last-change-date (repo-dir filepath )
102
- " This function will return the last commit date of a file in git repository
103
- presented by REPO-DIR, FILEPATH is the path of target file, can be absolute or
104
- relative."
100
+ " Return the last commit date of a file in git repository REPO-DIR.
101
+ FILEPATH is the path of target file, can be absolute or relative."
105
102
(let* ((git-repo repo-dir)
106
103
(output (git-run " log" " -1" " --format=\" %ci\" " " --" filepath)))
107
104
(when (string-match " \\ `\" \\ ([0-9]+-[0-9]+-[0-9]+\\ ) .*\"\n \\ '" output)
108
105
(match-string 1 output))))
109
106
110
107
(defun op/git-remote-name (repo-dir )
111
- " This function will return all remote repository names of git repository
112
- presented by REPO-DIR, return nil if there is no remote repository."
108
+ " Return all remote repository names of git repository REPO-DIR.
109
+ Return nil if there is no remote repository."
113
110
(let ((git-repo repo-dir))
114
111
(git-remotes)))
115
112
116
113
(defun op/git-push-remote (repo-dir remote-repo branch )
117
- " This function will push local branch to remote repository, REPO-DIR is the
118
- local git repository, REMOTE-REPO is the remote repository, BRANCH is the name
119
- of branch will be pushed (the branch name will be the same both in local and
120
- remote repository), and if there is no branch named BRANCH in remote repository,
121
- it will be created."
114
+ " Push local branch to remote repository.
115
+ REPO-DIR is the local git repository. REMOTE-REPO is the remote
116
+ repository. BRANCH is the name of branch will be pushed (the branch
117
+ name will be the same both in local and remote repository), and if
118
+ there is no branch named BRANCH in remote repository, it will be
119
+ created."
122
120
(let ((git-repo repo-dir))
123
121
(git-push remote-repo branch)))
124
122
0 commit comments