@@ -139,6 +139,21 @@ so retain the results by pull request ID to avoid duplicates.
139139 See ``examples/bitbucket/bitbucket_server_release_report.py `` for a complete
140140environment-variable-based script.
141141
142+ Commits belonging to an open pull request may not be reachable from the
143+ repository ref used by ``get_commits ``. To retrieve the commits that belong to
144+ a specific pull request on Server/Data Center, query the pull-request commits
145+ endpoint instead:
146+
147+ .. code-block :: python
148+
149+ for commit in bitbucket.get_pull_requests_commits(" PROJ" , " repository" , pull_request_id):
150+ print (commit[" id" ])
151+
152+ The Cloud object model provides the equivalent operation as
153+ ``repository.pullrequests.get(pull_request_id).commits ``. Use
154+ ``get_pull_requests_contain_commit `` when starting from an individual commit
155+ and looking up its associated pull requests.
156+
142157Manage projects
143158---------------
144159
@@ -558,6 +573,20 @@ July 2026, so new integrations must use API tokens.
558573 # Get a repository
559574 repository = workspace.repositories.get(repository_slug)
560575
576+ # Commit history supports include/exclude refs and a file-path filter.
577+ commits = repository.commits.each(
578+ include = " main" ,
579+ exclude = " release" ,
580+ path = " src/app.py" ,
581+ )
582+ for commit in commits:
583+ print (commit.hash)
584+
585+ The Cloud commits endpoint does not support arbitrary ``q `` expressions for
586+ filtering by author or date. Filter those fields in the returned commits, or
587+ use ``include ``, ``exclude `` and ``path `` when those server-side filters fit
588+ the use case.
589+
561590 # Read raw bytes from a file at a branch, tag, or commit SHA
562591 readme = repository.get_source_file("main", "README.md")
563592
@@ -567,20 +596,26 @@ July 2026, so new integrations must use API tokens.
567596 # Get a list of deployment environments from a repository
568597 repository.deployment_environments.each()
569598
570- # Get a single deployment environment from a repository by deployment environment key
599+ # Get a deployment environment by key
571600 deployment_environment = repository.deployment_environments.get(deployment_environment_key)
572601
573- # Get a list of deployment environment variables from a deployment environment
602+ # Get deployment environment variables from an environment
574603 deployment_environment_variables = deployment_environment.deployment_environment_variables.each()
575604
576- # Create a new deployment environment variable with a name of 'KEY', value of 'VALUE' and is not secured.
577- new_deployment_environment_variable = deployment_environment.deployment_environment_variables.create(" KEY" , " VALUE" , False )
605+ # Create a non-secured deployment environment variable.
606+ new_deployment_environment_variable = deployment_environment.deployment_environment_variables.create(
607+ "KEY", "VALUE", False
608+ )
578609
579610 # Update the 'key' field of repository_variable
580- updated_deployment_environment_variable = new_deployment_environment_variable.update(key = " UPDATED_DEPLOYMENT_ENVIRONMENT_VARIABLE_KEY" )
611+ updated_deployment_environment_variable = new_deployment_environment_variable.update(
612+ key="UPDATED_DEPLOYMENT_ENVIRONMENT_VARIABLE_KEY"
613+ )
581614
582615 # Update the 'value' field of repository_variable
583- updated_deployment_environment_variable = new_deployment_environment_variable.update(value = " UPDATED_DEPLOYMENT_ENVIRONMENT_VARIABLE_VALUE" )
616+ updated_deployment_environment_variable = new_deployment_environment_variable.update(
617+ value="UPDATED_DEPLOYMENT_ENVIRONMENT_VARIABLE_VALUE"
618+ )
584619
585620 # Delete deployment environment variable
586621 updated_deployment_environment_variable.delete()
@@ -594,17 +629,25 @@ July 2026, so new integrations must use API tokens.
594629 # Get a list of repository variables from a repository
595630 repository.repository_variables.each()
596631
597- # Get a single repository variable from a repository by repository variable key
598- repository_variable = repository.repository_variables.get(repository_variable_key)
632+ # Get a repository variable by key
633+ repository_variable = repository.repository_variables.get(
634+ repository_variable_key
635+ )
599636
600- # Create a new repository variable with a name of 'KEY', value of 'VALUE' and is not secured.
601- new_repository_variable = repository.repository_variables.create(" KEY" , " VALUE" , False )
637+ # Create a non-secured repository variable.
638+ new_repository_variable = repository.repository_variables.create(
639+ "KEY", "VALUE", False
640+ )
602641
603642 # Update the 'key' field of repository_variable
604- updated_repository_variable = repository_variable.update(key = " UPDATED_REPOSITORY_VARIABLE_KEY" )
643+ updated_repository_variable = repository_variable.update(
644+ key="UPDATED_REPOSITORY_VARIABLE_KEY"
645+ )
605646
606647 # Update the 'value' field of repository_variable
607- updated_repository_variable = repository_variable.update(value = " UPDATED_REPOSITORY_VARIABLE_VALUE" )
648+ updated_repository_variable = repository_variable.update(
649+ value="UPDATED_REPOSITORY_VARIABLE_VALUE"
650+ )
608651
609652 # Delete repository_variable
610653 repository_variable.delete()
@@ -613,13 +656,19 @@ July 2026, so new integrations must use API tokens.
613656 repository.hooks.each()
614657
615658 # Create a hook for a repository
616- hook = repo.hooks.create(url = " endpoint-url" , description = " description" , active = True , events = [" a-repository-event" ])
659+ hook = repo.hooks.create(
660+ url="endpoint-url", description="description", active=True,
661+ events=["a-repository-event"]
662+ )
617663
618664 # Get a single hook for a repository
619665 hook = repo.hooks.get("a-webhook-id")
620666
621667 # Update a specific hook for a repository
622- hook.update(url = " endpoint-url" , description = " description" , active = True , events = [" a-repository-event" ])
668+ hook.update(
669+ url="endpoint-url", description="description", active=True,
670+ events=["a-repository-event"]
671+ )
623672
624673 # Delete a speicifc hook for a repository
625674 hook.delete()
0 commit comments