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

add commands to manage Git refs #296

Merged
merged 29 commits into from
Feb 27, 2019
Merged

Conversation

vbossica
Copy link
Contributor

This changeset adds methods to manage Git refs:

  • list of references
  • create/update/delete a single reference

azure-devops/azext_devops/dev/repos/ref.py Outdated Show resolved Hide resolved
azure-devops/azext_devops/dev/repos/ref.py Outdated Show resolved Hide resolved
azure-devops/azext_devops/dev/repos/ref.py Show resolved Hide resolved
azure-devops/azext_devops/dev/repos/ref.py Outdated Show resolved Hide resolved
"""Create a reference.
:param str name: Name of the reference to create (example: heads/my_branch or tags/my_tag).
:param str object_id: id of the object to create the reference from.
:param bool locked: If the reference is locked (default False)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I tried the command with --locked and still got

{
"customMessage": null,
"isLocked": false,
"name": "refs/heads/NewBranchCreationLocked1",
"newObjectId": "ffb155f085e36281514672fe8d31983e8ec6d640",
"oldObjectId": "0000000000000000000000000000000000000000",
"rejectedBy": null,
"repositoryId": "89c5139b-34e7-4c45-8d40-d23353e22014",
"success": true,
"updateStatus": "succeeded"
}

Will need to check this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right. I think the problem is in the serialization/deserialization of boolean values (which is strange if accurate.)
When retrieving the list of all refs, the isLocked value is null:

"isLocked": null,
"isLockedBy": null,
"name": "refs/tags/tag_4",
"objectId": "4f20eea9a98c52b75e8264634ca63b662d6fa55a",

when a boolean value should be true/false.

Suggestion is to remove the --locked parameter to unblock this PR and open an issue for further investigation.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Go ahead with the suggestion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the issue lies somewhere between the vsts-python-api and the rest endpoint: microsoft/azure-devops-python-api#174

doc/authoring_tests.md Show resolved Hide resolved
tests/reposRefTest.py Outdated Show resolved Hide resolved
tests/reposRefTest.py Outdated Show resolved Hide resolved
azure-devops/azext_devops/test/repos/test_ref.py Outdated Show resolved Hide resolved
@gauravsaralMs gauravsaralMs changed the base branch from azuredevopscli-dev to master January 22, 2019 10:29
@gauravsaralMs gauravsaralMs reopened this Jan 22, 2019
azure-devops/azext_devops/dev/repos/_format.py Outdated Show resolved Hide resolved

class TestRefMethods(unittest.TestCase):

_TEST_DEVOPS_ORGANIZATION = 'https://AzureDevOpsCliTest.visualstudio.com'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Put an invalid url here like.. https://some-invalid-org.visualstudio.com.

This will fail the test since the "client = get_git_client(organization)" call in each of the commands makes a network call. You will need to mock it, in your case to return a GitClient object.

We discovered this recently and I am fixing other tests.

This one is implemented correctly.
https://github.com/Microsoft/azure-devops-cli-extension/blob/master/azure-devops/azext_devops/test/pipelines/test_pipelines_build.py

check - self.get_client = patch('vsts.vss_connection.VssConnection.get_client')

tests/recordings/test_ref_createListDelete.yaml Outdated Show resolved Hide resolved
Copy link
Collaborator

@atbagga atbagga left a comment

Choose a reason for hiding this comment

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

I guess besides the comment on tests rest looks good.
Do you need any help with the remaining changes?

Copy link
Contributor

@gauravsaralMs gauravsaralMs left a comment

Choose a reason for hiding this comment

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

If possible please add examples for the commands
something similar to
#417

@atbagga atbagga merged commit 773bcc8 into Azure:master Feb 27, 2019
@atbagga
Copy link
Collaborator

atbagga commented Feb 27, 2019

Thank you @vbossica for your contribution! 👍

@vbossica vbossica deleted the azext/manage_refs branch February 27, 2019 10:55
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.

4 participants