Skip to content
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

Closed
wants to merge 0 commits into from

Conversation

maxakuru
Copy link
Member

  • Add getGitDir() function to GitUtils to find gitdir of a repo directory
  • Use getGitDir() in UpCommand
  • Add gitdir argument to all GitUtils methods that use isomorphic-git APIs that support gitdir option

TODO

  • tests for added branches

Related Issues

#1794

@codecov
Copy link

codecov bot commented Jun 29, 2021

Codecov Report

Merging #1795 (74e345c) into main (289b590) will decrease coverage by 0.61%.
The diff coverage is 70.00%.

Impacted file tree graph

@@            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     
Impacted Files Coverage Δ
src/git-utils.js 88.28% <62.50%> (-10.63%) ⬇️
src/up.cmd.js 87.87% <100.00%> (+0.06%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 636cda0...74e345c. Read the comment docs.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @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');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not path.resolve() ?

Copy link
Member Author

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()?

Copy link
Contributor

@tripodsan tripodsan left a 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.

@trieloff
Copy link
Contributor

Only nitpick from my side: use fix(cli): instead of bug(cli): in the commit message, as only fix, feat and BREAKING CHANGE increase the version counter and lead to new releases.

@tripodsan
Copy link
Contributor

@maxakuru why did you close this PR ?

@maxakuru
Copy link
Member Author

maxakuru commented Jul 1, 2021

@tripodsan seemed like the consensus on #1794 was that submodule support wasn't wanted so closed this for #1796

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants