Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Conversation

@jcansdale
Copy link
Collaborator

@jcansdale jcansdale commented Dec 14, 2017

Functionality

  • Option to sync submodules after checking out a PR with submodule changes
  • Allows user to check out a different PR branch when there are submodule change
  • Usage tracking using NumberOfSyncSubmodules counter
  • When when the Sync button is pressed, the following GIt commands will be executed (see What git commands should we execute when checking out a PR #848):
git submodule init
git submodule sync --recursive
git submodule update --recursive

image

To do

  • Write test plan for added, removed and changed submodules (paging @meaghanlewis)

Merged PRs

Test plan

Syncing submodules

  1. Check out a PR
  2. Check out another PR with submodule changes (I've been using PR 614 for testing)
  3. Click the the [SyncSubmodules] button
  4. Once sync submodules completes, the branch should appear up to date

Ignoring submodules

  1. Check out a PR
  2. Check out another PR with submodule changes (I've been using PR 614 for testing)
  3. Ignore the [SyncSubmodules] button and check out original PR
  4. Original branch should appear up to date (previously this wouldn't have worked)

Git.exe not on PATH

  1. Remove Git.exe from PATH.
  2. Check out a PR
  3. Check out another PR with submodule changes (I've been using PR 614 for testing)
  4. Click the the [SyncSubmodules] button
  5. Something like this should appear:
    image

Related issues

Fixes #826

If we checkout a PR branch, we should allow the user to move away from that branch (if they haven't touched anything).
Only show button when there are sunbmodules to sync.
Adding submodules using LibGit2Sharp wasn't working well.
Doesn't use libgit2sharp so GitClient didn't make sense.
If git.exe can't be found or returns an error code,  display stdout/err on UI.
Reviewing PR with submodule changes MVP
@jcansdale
Copy link
Collaborator Author

jcansdale commented Jan 15, 2018

Deciding what to do when updating submodules and git.exe isn't on the users path.

Visual Studio 2018 will show the following if Git for Windows isn't installed:

image

image

The Install buttons simply opens the following in the users default browser:
https://git-scm.com/download/win

The current commit will show the following (it will show git not gitx):

image

I'm looking to make the message a little friendlier. The user will probably already have Git installed, so there is no need to go overboard with a solution!

Something along the lines of:

Couldn't find Git.exe on PATH.

Please install Git for Windows from:
https://git-scm.com/download/win

image

jcansdale and others added 5 commits January 15, 2018 12:53
VS 2017 will guide user to install Git for Windows as soon as Team Explorer is opened.
The user not having Git.exe on their PATH isn't the common case, so don't want to overengineer a solution.
Change IsSyncSubmodulesRequired to CountSubmodulesToSync.
@donokuda
Copy link
Contributor

I pushed a couple of commits that clean up the sync submodules number. Here's what it looks like (with some stubbed info):

screen shot 2018-01-21 at 9 28 19 am

For the sake of space, I kept the action to "Sync." Could we use a tooltip that says something along the lines of "Sync [number] submodules?" I tried adding one myself, but couldn't figure out how to do it in the time I allotted for myself. (The GitHubActionLink component is based of a regular xaml button component if that's any help.)

I'm looking to make the message a little friendlier. The user will probably already have Git installed, so there is no need to go overboard with a solution!

@jcansdale I forgot if you mentioned this earlier, but we should move any errors from an action into an infobar.

@jcansdale
Copy link
Collaborator Author

@donokuda, Looking sweet! 😄

I've added a tooltip like this:

image

@grokys
Copy link
Contributor

grokys commented Feb 7, 2018

Just tried this on #1415 and I'm getting:

image

Which is strange because submodules/Octokit.GraphQL doesn't exist on this branch. Doing a git submodule update from the command line works fine however.

Copy link
Contributor

@grokys grokys left a comment

Choose a reason for hiding this comment

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

I think this looks good. I'm still a little concerned about a couple of things:

  • Shelling out to git.exe - though this looks simpler than I'd imagined probably isn't a problem
  • This is really Team Explorer/git functionality. In particular git.exe now has this feature. I can see that it's definitely useful however so maybe implementing it here isnt the wrong thing to do.

But having weighed everything up, I think I'm lightly 👍 on this feature. However, I can't approve it yet because the feature didn't work with one of the PRs I tried it on (see comment above).

// If culture isn't English, user will see the local equivalent of:
// "'git' is not recognized as an internal or external command"
var message = output.ToString();
if (exitCode == 1 && message.StartsWith("'git' is not recognized as an internal or external command,", StringComparison.Ordinal))
Copy link
Contributor

Choose a reason for hiding this comment

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

This strikes me as a bit of a hack. Might there be a way to check whether git.exe is on the path and display an error rather than parsing the (localizable) error message?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I can change it to use WHERE to find out where Git.exe is on the path.

var message = output.ToString();
if (exitCode == 1 && message.StartsWith("'git' is not recognized as an internal or external command,", StringComparison.Ordinal))
{
message =
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be in a resources file.

@jcansdale
Copy link
Collaborator Author

jcansdale commented Feb 7, 2018

@grokys,

Just tried this on #1415 and I'm getting...

That was a bit of an edge case, but I'm glad you found it. I've tweaked it so that it won't give up quite so easily and will always do git submodule update. It now behaves as you expected.

@grokys
Copy link
Contributor

grokys commented Feb 7, 2018

A few other things I've noticed

  • When you click the "Sync" button it can take quite a while to update the submodule, in which time there's no indication that anything is happening except for the fact you can't click on anything. This is also a problem for the "Push" and "Pull" buttons but as these operations are usually quicker you don't tend to notice. We should probably address this for all 3 operations in a separate PR
  • When there are submodules to sync, the "Push" and "Pull" buttons are always visible (though disabled) even if there is nothing to push and pull:

image

Is this correct or should we just be showing the "Sync" button in this state? Personally I don't mind the fact that you see the other 2 disabled buttons.

@jcansdale
Copy link
Collaborator Author

When you click the "Sync" button it can take quite a while to update the submodule, in which time there's no indication that anything is happening except for the fact you can't click on anything.

Yes, I've noticed this as well. I'm hoping to add some incremental progress to give the user some idea of what's going on.

When there are submodules to sync, the "Push" and "Pull" buttons are always visible (though disabled) even if there is nothing to push and pull. Is this correct or should we just be showing the "Sync" button in this state?

This was intentional. The idea is that "Sync" is a peer of "Push" and "Pull", but only appears when there are submodules to sync (no point cluttering the interface for no reason).

@jcansdale
Copy link
Collaborator Author

@grokys,

This is also a problem for the "Push" and "Pull" buttons but as these operations are usually quicker you don't tend to notice. We should probably address this for all 3 operations in a separate PR

I've made some changes should should make reporting incremental progress easier. I agree we should probably address it in a separate PR and keep this one focused.

The issue that occurred when checking out #1415 has now been addressed. I checked it before updating and it successfully completed a git submodule update.

It now checks that Git.exe exists using WHERE and displays an error message (form a resource string) and aborts if it doesn't.

I think that's everything. 🤞

@jcansdale
Copy link
Collaborator Author

I intended to hide all sync related UI when there are no submodules to sync. It appears this isn't the case. Oops!

image

@jcansdale
Copy link
Collaborator Author

Here we go. Less clutter when there are no submodule changes:

image

Hide the icon and counter as well as the Sync button.
@meaghanlewis
Copy link
Contributor

This is looking good to me 🎉

I also added some test scenarios here: https://github.com/github/editor-tools/pull/268 can you take a 👀 @jcansdale?

grokys
grokys previously requested changes Feb 8, 2018
Copy link
Contributor

@grokys grokys left a comment

Choose a reason for hiding this comment

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

Nearly there I think!


using (var process = Process.Start(startInfo))
{
process.WaitForExit();
Copy link
Contributor

Choose a reason for hiding this comment

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

This will block the UI thread waiting for the process to exit, probably not a good idea...

{
throw new ApplicationException(progress.ToString());
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually a low-impact way for now to show that something is happening during this method would be to do:

        async Task DoSyncSubmodules(object unused)
        {
            try
            {
                IsBusy = true;
                usageTracker.IncrementCounter(x => x.NumberOfSyncSubmodules).Forget();

                var progress = new CaptureProgress();
                var complete = await pullRequestsService.SyncSubmodules(LocalRepository, progress);
                if (!complete)
                {
                    throw new ApplicationException(progress.ToString());
                }
            }
            finally
            {
                IsBusy = false;
            }
        }

What do you think?

@jcansdale
Copy link
Collaborator Author

I've stopped it from blocking the main thread and changed it to use the busy spinner.

I did a spike where it where it shows progress on the status bar, which works very well but isn't ready for prime time. I'll address this in a separate PR so as not to block this one!

What do you reckon?

Copy link
Contributor

@grokys grokys left a comment

Choose a reason for hiding this comment

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

Looks good to me!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants