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

get branches? #130

Open
dgarozzo opened this issue Apr 26, 2019 · 1 comment
Open

get branches? #130

dgarozzo opened this issue Apr 26, 2019 · 1 comment

Comments

@dgarozzo
Copy link

dgarozzo commented Apr 26, 2019

I'm having difficulty in getting a list of branch names for a given repo.

for repo in stash.repos:

	pp.pprint( repo )

	pp.pprint( stash.repos[ repo[ 'slug' ] ].get_all_branches(items=5) )

	sys.exit("done")

TypeError: the JSON object must be str, not 'bytes'

for repo in stash.repos:

	pp.pprint( repo )

	pp.pprint( stash.repos[ repo[ 'slug' ] ].branches() )

	sys.exit("done")

<generator object ResourceBase.paginate at 0x110b18a98>

What am I doing wrong?

@rgronberg
Copy link

rgronberg commented May 22, 2019

http://example.com/rest/api/1.0/repos/{repoSlug}/branches is not a supported API endpoint. The only way I can see it possible for you to do what you want is to use the http://example.com/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/branches endpoint.

for project in stash.projects:
    for repo in stash.projects[project['key']].repos:
        pp.pprint(repo)
        pp.pprint(stash.projects[project['key']].repos[repo['slug']].get_all_branches(items=5))
        sys.exit("done")

This will iterate over repos within each project. It will also treat each user as a 'project'. That is, the endpoint http://example.com/rest/api/1.0/projects/~{userSlug}/repos/{repositorySlug}/branches is used to iterate over user repositories.

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

No branches or pull requests

2 participants