-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug(cli): add support for repos that are submodules #1795
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1795 +/- ##
==========================================
- Coverage 94.79% 94.17% -0.62%
==========================================
Files 35 35
Lines 1748 1768 +20
==========================================
+ Hits 1657 1665 +8
- Misses 91 103 +12
Continue to review full report at Codecov.
|
src/git-utils.js
Outdated
@@ -30,14 +31,17 @@ class GitUtils { | |||
* | |||
* @param {string} dir working tree directory path of the git repo | |||
* @param {string} [homedir] optional users home directory | |||
* @param {string} [gitdir] the git directory path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @param {string} [gitdir] the git directory path | |
* @param {string} [gitdir] optional git directory path |
src/git-utils.js
Outdated
@@ -105,9 +109,10 @@ class GitUtils { | |||
* @param {string} dir working tree directory path of the git repo | |||
* @param {string} filepath file to check | |||
* @param {string} [homedir] optional users home directory | |||
* @param {string} [gitdir] the git directory path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @param {string} [gitdir] the git directory path | |
* @param {string} [gitdir] optional git directory path |
src/git-utils.js
Outdated
@@ -140,25 +145,35 @@ class GitUtils { | |||
* will be returned instead. | |||
* | |||
* @param {string} dir working tree directory path of the git repo | |||
* @param {string} [gitdir] the git directory path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @param {string} [gitdir] the git directory path | |
* @param {string} [gitdir] optional git directory path |
src/git-utils.js
Outdated
@@ -174,11 +189,12 @@ class GitUtils { | |||
* current branch or tag. | |||
* | |||
* @param {string} dir working tree directory path of the git repo | |||
* @param {string} [gitdir] the git directory path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @param {string} [gitdir] the git directory path | |
* @param {string} [gitdir] optional git directory path |
src/git-utils.js
Outdated
@@ -188,10 +204,11 @@ class GitUtils { | |||
* will be returned instead. | |||
* | |||
* @param {string} dir working tree directory path of the git repo | |||
* @param {string} [gitdir] the git directory path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @param {string} [gitdir] the git directory path | |
* @param {string} [gitdir] optional git directory path |
src/git-utils.js
Outdated
@@ -200,11 +217,12 @@ class GitUtils { | |||
* Returns the `origin` remote url or `''` if none is defined. | |||
* | |||
* @param {string} dir working tree directory path of the git repo | |||
* @param {string} [gitdir] the git directory path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @param {string} [gitdir] the git directory path | |
* @param {string} [gitdir] optional git directory path |
src/git-utils.js
Outdated
@@ -216,41 +234,50 @@ class GitUtils { | |||
* Same as #getOrigin() but returns a `GitUrl` instance instead of a string. | |||
* | |||
* @param {string} dir working tree directory path of the git repo | |||
* @param {string} [gitdir] the git directory path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @param {string} [gitdir] the git directory path | |
* @param {string} [gitdir] optional git directory path |
src/git-utils.js
Outdated
return origin ? new GitUrl(origin) : null; | ||
} | ||
|
||
/** | ||
* Returns the sha of the current (i.e. `HEAD`) commit. | ||
* | ||
* @param {string} dir working tree directory path of the git repo | ||
* @param {string} [gitdir] the git directory path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @param {string} [gitdir] the git directory path | |
* @param {string} [gitdir] optional git directory path |
src/git-utils.js
Outdated
} | ||
|
||
/** | ||
* Returns the commit oid of the curent commit referenced by `ref` | ||
* | ||
* @param {string} dir git repo path | ||
* @param {string} ref reference (branch, tag or commit sha) | ||
* @param {string} [gitdir] the git directory path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @param {string} [gitdir] the git directory path | |
* @param {string} [gitdir] optional git directory path |
src/git-utils.js
Outdated
@@ -263,16 +290,74 @@ class GitUtils { | |||
* @param {string} dir git repo path | |||
* @param {string} ref reference (branch, tag or commit sha) | |||
* @param {string} filePath relative path to file | |||
* @param {string} [gitdir] the git directory path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @param {string} [gitdir] the git directory path | |
* @param {string} [gitdir] optional git directory path |
src/up.cmd.js
Outdated
throw Error('hlx up needs local git repository.'); | ||
if (!this._gitHead) { | ||
this._gitDir = await GitUtils.getGitDir(this.directory); | ||
this._gitHead = path.join(this._gitDir, 'HEAD'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not path.resolve()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no real reason, this.directory
is already resolved and getGitDir()
returns a resolved path - do you always prefer path.resolve()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be good to add an integration test that runs hlx up from submodule directory.
Only nitpick from my side: use |
@maxakuru why did you close this PR ? |
@tripodsan seemed like the consensus on #1794 was that submodule support wasn't wanted so closed this for #1796 |
getGitDir()
function to GitUtils to find gitdir of a repo directorygetGitDir()
in UpCommandgitdir
argument to all GitUtils methods that use isomorphic-git APIs that support gitdir optionTODO
Related Issues
#1794