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

[File Explorer Integration] Git submodule status and commit log inside submodule #3745

Merged
merged 16 commits into from
Sep 7, 2024

Conversation

DefaultRyan
Copy link
Member

@DefaultRyan DefaultRyan commented Sep 3, 2024

Summary of the pull request

Parse submodule status (which submodules are new, changed, and/or dirty) and report latest commit info from files within the submodule.

Still to do: display folder and file status for submodule contents. That is coming next, but this commit is getting big enough as it is.

Detailed description of the pull request / Additional comments

A big part of this PR is the addition of test repos under the resources folder. This allows us to "freeze" a repository in a specific state, including the working directory and index. We're able to do this by renaming .git to dot-git and .gitmodules to dot-gitmodules, and this makes Git see these files/folders as just normal stuff, instead of special Git infrastructure. When deploying the repo to a temp location for testing, we undo that rename. This approach was inspired by similar approaches seen in libgit2 and libgit2sharp for their unit testing.

When finding the latest commit, always run the git command from the leaf-most folder. This way, git will automatically use the correct history when were are inside a submodule.

Parse submodule-specific status and provide the appropriate property values. New submodule status values are:

  • Submodule staged
    • The submodule has been added, and this addition is staged.
  • Submodule changed
    • This repository's submodule is pointing to a different commit than the superproject's submodule.
  • Submodule dirty
    • Files have been changed in the submodule's index or working directory.

Validation steps performed

Ran newly added unit tests.

PR checklist

  • Tests added/passed
  • Documentation updated

@@ -45,6 +36,11 @@ public void Add(string path, GitStatusEntry status)
}
}

public bool TryAdd(string path, SubmoduleStatus status)
Copy link
Contributor

Choose a reason for hiding this comment

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

May we consider using a more descriptive method name instead of TryAdd which is identical to the called Dictionary method name? Thanks!

Copy link
Member Author

Choose a reason for hiding this comment

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

I deliberately chose TryAdd because it is identical to the method on Dictionary. My hope was that would make the semantics clear.

@DefaultRyan DefaultRyan added the Needs-Second Pull request that needs another approval label Sep 4, 2024
@DefaultRyan DefaultRyan changed the title Git submodule status and commit log inside submodule [File Explorer Integration] Git submodule status and commit log inside submodule Sep 5, 2024
@DefaultRyan DefaultRyan merged commit 229084a into main Sep 7, 2024
4 checks passed
@krschau krschau removed the Needs-Second Pull request that needs another approval label Sep 9, 2024
@krschau krschau added this to the Dev Home v0.18 milestone Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants