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

Conversation

@paladique
Copy link
Contributor

Fixes #343
Continuation of #510

return null;

var sha = HeadSha;
var sha = await GitService.GitServiceHelper.GetLatestPushedSha(path);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this the path where the repository is? The GenerateUrl method takes a path argument that represents the file to generate the url for, not the path to the repository where the file is.


public static IGitService GitServiceHelper => VisualStudio.Services.DefaultExportProvider.GetExportedValueOrDefault<IGitService>() ?? new GitService();

public Task<string> GetLatestPushedSha(string path)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this argument allowed to be null? If yes, it needs to be documented as such, and code that relies on it needs null checks. If no, it needs a null check at the start of the method.

Copy link
Contributor

@shana shana left a comment

Choose a reason for hiding this comment

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

Items to fix before merging:

  • path needs to be checked for nullness in GetLatestPushedSha
  • Document method

/// Finds the latest pushed commit of a file and returns the sha of that commit. Returns null when no commits have
/// been found in any remote branches or the current local branch.
/// </summary>
/// <param name="path">The local path of the file. This cannot be null.</param>
Copy link
Contributor

@shana shana Sep 15, 2016

Choose a reason for hiding this comment

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

I think The local path of a repository or a file inside a repository. This cannot be null. will be clearer.

public Task<string> GetLatestPushedSha(string path)
{
Guard.ArgumentNotNull(path, nameof(path));
var repo = GetRepository(path);
Copy link
Contributor

Choose a reason for hiding this comment

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

If the path points to a file or a directory that's not inside a repository, this will return null, so you need to check that before using the variable, and likely return early.

/// <returns></returns>
UriString GetRemoteUri(IRepository repo, string remote = "origin");

Task<string> GetLatestPushedSha(string path);
Copy link
Contributor

Choose a reason for hiding this comment

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

You'll need to copy the documentation added to the method to here. Classes and interfaces don't share docs, unfortunately.

@paladique paladique force-pushed the fixes/343-latest-remote-commit branch from be53ecc to 1b8e445 Compare September 15, 2016 20:42
@shana shana merged commit 5a3f114 into master Sep 15, 2016
@shana shana deleted the fixes/343-latest-remote-commit branch September 15, 2016 20:51
@shana
Copy link
Contributor

shana commented Sep 15, 2016

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants