11import fs from 'fs' ;
22import path from 'path' ;
33import {
4- parseRemoteOriginURL ,
4+ parseRemoteOriginUrl ,
55 trim ,
6- parseINI ,
7- isGitDirectory
6+ parseIni ,
7+ isGitDirectory ,
8+ findGitPath
89} from './utils' ;
910
1011/**
@@ -22,16 +23,16 @@ export default (config: TypeConfig = {}): Object => {
2223 /**
2324 * @returns GitHub repository URL.
2425 */
25- gitinfo . url = ( ) : string => {
26- return 'https://github.com/' + gitinfo . username ( ) + '/' + gitinfo . name ( ) ;
26+ gitinfo . getGithubUrl = ( ) : string => {
27+ return 'https://github.com/' + gitinfo . getUsername ( ) + '/' + gitinfo . getName ( ) ;
2728 } ;
2829
2930 /**
3031 * Gets name of the current branch.
3132 *
3233 * @see http://stackoverflow.com/a/12142066/368691
3334 */
34- gitinfo . branch = ( ) : string => {
35+ gitinfo . getBranchName = ( ) : string => {
3536 const name = gitPath + '/HEAD' ;
3637
3738 /* istanbul ignore next */
@@ -54,9 +55,9 @@ export default (config: TypeConfig = {}): Object => {
5455 /**
5556 * @returns Remote URL of the current branch.
5657 */
57- gitinfo . remoteURL = ( ) : string => {
58- const branchName = gitinfo . branch ( ) ;
59- const gitConfig = gitinfo . config ( ) ;
58+ gitinfo . getRemoteUrl = ( ) : string => {
59+ const branchName = gitinfo . getBranchName ( ) ;
60+ const gitConfig = gitinfo . getConfig ( ) ;
6061 const branch = gitConfig [ 'branch "' + branchName + '"' ] ;
6162
6263 /* istanbul ignore next */
@@ -81,31 +82,31 @@ export default (config: TypeConfig = {}): Object => {
8182 /**
8283 * @returns Absolute path to the .git/ directory.
8384 */
84- gitinfo . gitPath = ( ) : string => {
85+ gitinfo . getGitPath = ( ) : string => {
8586 return gitPath ;
8687 } ;
8788
8889 /**
8990 * @returns Username of the repository author.
9091 */
91- gitinfo . username = ( ) : string => {
92- return parseRemoteOriginURL ( gitinfo . remoteURL ( ) ) . username ;
92+ gitinfo . getUsername = ( ) : string => {
93+ return parseRemoteOriginUrl ( gitinfo . getRemoteUrl ( ) ) . username ;
9394 } ;
9495
9596 /**
9697 * @returns Repository name.
9798 */
98- gitinfo . name = ( ) : string => {
99- return parseRemoteOriginURL ( gitinfo . remoteURL ( ) ) . name ;
99+ gitinfo . getName = ( ) : string => {
100+ return parseRemoteOriginUrl ( gitinfo . getRemoteUrl ( ) ) . name ;
100101 } ;
101102
102103 /**
103- * @returns Commit SHA of the current branch
104+ * @returns Commit SHA of the current branch.
104105 */
105- gitinfo . sha = ( ) : string => {
106+ gitinfo . getHeadSha = ( ) : string => {
106107 let sha ;
107108
108- const branch = gitinfo . branch ( ) ;
109+ const branch = gitinfo . getBranchName ( ) ;
109110 const shaFile = path . join ( gitPath , 'refs' , 'heads' , branch ) ;
110111
111112 try {
@@ -121,8 +122,8 @@ export default (config: TypeConfig = {}): Object => {
121122 /**
122123 * @returns Representation of the .git/config file.
123124 */
124- gitinfo . config = ( ) : Object => {
125- return parseINI ( gitPath + '/config' ) ;
125+ gitinfo . getConfig = ( ) : Object => {
126+ return parseIni ( gitPath + '/config' ) ;
126127 } ;
127128
128129 config . gitPath = config . gitPath || __dirname ;
@@ -132,7 +133,7 @@ export default (config: TypeConfig = {}): Object => {
132133 if ( isGitDirectory ( config . gitPath ) ) {
133134 gitPath = config . gitPath ;
134135 } else {
135- gitPath = gitPath ( config . gitPath ) ;
136+ gitPath = findGitPath ( config . gitPath ) ;
136137 }
137138
138139 /* istanbul ignore next */
0 commit comments