Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

fix Repository.ResolveRevision for branch and tag #660

Merged
merged 9 commits into from
Dec 1, 2017
Merged

fix Repository.ResolveRevision for branch and tag #660

merged 9 commits into from
Dec 1, 2017

Conversation

antham
Copy link
Contributor

@antham antham commented Nov 26, 2017

Branch and tag revision are properly parsed by revision lexer but not properly solved into references.

#599

if c == nil {
return &plumbing.ZeroHash, fmt.Errorf(`No commit exists prior to date "%s"`, date.String())
}

Copy link
Contributor Author

@antham antham Nov 28, 2017

Choose a reason for hiding this comment

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

I removed this part because it's a bad implementation,I misread the spec, it must follows this : This suffix may only be used immediately following a ref name and the ref must have an existing log ($GIT_DIR/logs/<ref>).

repository.go Outdated
"refs/tags/%s",
"refs/heads/%s",
"refs/remotes/%s",
"refs/remotes/%s/HEAD",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This part exists already in plumbing, I was wondering if it would be possible to move all this code related to revision in plumbing ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can make this public:

// refRevParseRules are a set of rules to parse references into short names.
// These are the same rules as used by git in shorten_unambiguous_ref.
// See: https://github.com/git/git/blob/e0aaa1b6532cfce93d87af9bc813fb2e7a7ce9d7/refs.c#L417
var refRevParseRules = []string{
"refs/%s",
"refs/tags/%s",
"refs/heads/%s",
"refs/remotes/%s",
"refs/remotes/%s/HEAD",
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't you think we could replace those litteral strings with constants defined just right above to avoid duplication ?

@antham antham changed the title [WIP] Fix revision solver for branch and tag Fix revision solver for branch and tag Nov 28, 2017
example_test.go Outdated
fmt.Printf("%s %s\n", h.String(), revision)
}

// Output:
Copy link
Contributor Author

@antham antham Nov 28, 2017

Choose a reason for hiding this comment

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

I saw in other examples, you have // Example Output instead of // Output, so examples are not tested, is it a mistake or something you explicitly did ?

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 examples are in _examples folder are tested in a different way. But if is a example in other folder is an error

@antham antham changed the title Fix revision solver for branch and tag [WIP] Fix revision solver for branch and tag Nov 28, 2017
"HEAD~^{/!-some}": "1669dce138d9b841a518c64b10914d88f5e488ea",
"master": "6ecf0ef2c2dffb796033e5a02219af86ec6584e5",
"branch": "e8d3ffab552895c19b9fcf7aa264d277cde33881",
"v1.0.0": "6ecf0ef2c2dffb796033e5a02219af86ec6584e5",
Copy link
Contributor Author

@antham antham Nov 28, 2017

Choose a reason for hiding this comment

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

This tag exists here but I can't find it on https://github.com/git-fixtures/basic.git

Copy link
Contributor

Choose a reason for hiding this comment

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

Extrange... but trust on the fixture.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

maybe you could add it to the original repository ? It's convenient when you need to test on the repository and it will fit what is defined in fixtures.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe, I will check it.

@antham antham changed the title [WIP] Fix revision solver for branch and tag Fix revision solver for branch and tag Nov 28, 2017
@antham
Copy link
Contributor Author

antham commented Nov 28, 2017

@mcuadros can you review this PR pls ?

example_test.go Outdated
@@ -85,6 +85,36 @@ func ExampleRepository_References() {

}

func ExampleRepository_ResolveRevision() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I prefer having this example on the _examples folder, following the format.

repository.go Outdated
"refs/tags/%s",
"refs/heads/%s",
"refs/remotes/%s",
"refs/remotes/%s/HEAD",
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can make this public:

// refRevParseRules are a set of rules to parse references into short names.
// These are the same rules as used by git in shorten_unambiguous_ref.
// See: https://github.com/git/git/blob/e0aaa1b6532cfce93d87af9bc813fb2e7a7ce9d7/refs.c#L417
var refRevParseRules = []string{
"refs/%s",
"refs/tags/%s",
"refs/heads/%s",
"refs/remotes/%s",
"refs/remotes/%s/HEAD",
}

"HEAD~^{/!-some}": "1669dce138d9b841a518c64b10914d88f5e488ea",
"master": "6ecf0ef2c2dffb796033e5a02219af86ec6584e5",
"branch": "e8d3ffab552895c19b9fcf7aa264d277cde33881",
"v1.0.0": "6ecf0ef2c2dffb796033e5a02219af86ec6584e5",
Copy link
Contributor

Choose a reason for hiding this comment

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

Extrange... but trust on the fixture.

@mcuadros
Copy link
Contributor

@antham ping

antham added 7 commits December 1, 2017 15:26
Branch and tag were parsed properly by internal revision parser but
not resolved correctly into a git hash cause actual reference parser
is based on "absolute path" like for instance to reach a branch named
test1 it would be refs/heads/test1, the canonical way of resolving
such a revision was not implemented
@antham
Copy link
Contributor Author

antham commented Dec 1, 2017

@mcuadros you can come back, AppVeyor crashs but it doesn't seem related to my changes

@antham
Copy link
Contributor Author

antham commented Dec 1, 2017

Now AppVeyor works but there is an error with one of the build with travis....

@mcuadros mcuadros changed the title Fix revision solver for branch and tag fix Repository.ResolveRevision for branch and tag Dec 1, 2017
@mcuadros mcuadros merged commit 44c364f into src-d:master Dec 1, 2017
@antham
Copy link
Contributor Author

antham commented Dec 1, 2017

@mcuadros did you see my last comments in this PR about RefRevParseRules and the tag on basic repository ?

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.

2 participants