@@ -59,24 +59,39 @@ export class BitbucketRepositoryProvider implements RepositoryProvider {
59
59
async getBranches ( user : User , owner : string , repo : string ) : Promise < Branch [ ] > {
60
60
const branches : Branch [ ] = [ ] ;
61
61
const api = await this . apiFactory . create ( user ) ;
62
- const response = await api . repositories . listBranches ( {
63
- workspace : owner ,
64
- repo_slug : repo ,
65
- sort : "target.date" ,
66
- } ) ;
67
62
68
- for ( const branch of response . data . values ! ) {
69
- branches . push ( {
70
- htmlUrl : branch . links ?. html ?. href ! ,
71
- name : branch . name ! ,
72
- commit : {
73
- sha : branch . target ?. hash ! ,
74
- author : branch . target ?. author ?. user ?. display_name ! ,
75
- authorAvatarUrl : branch . target ?. author ?. user ?. links ?. avatar ?. href ,
76
- authorDate : branch . target ?. date ! ,
77
- commitMessage : branch . target ?. message || "missing commit message" ,
78
- } ,
63
+ // Handle pagination.
64
+ let nextPage : number | undefined = 1 ;
65
+ let isMoreDataAvailable : boolean = true ;
66
+
67
+ while ( isMoreDataAvailable ) {
68
+ const response = await api . repositories . listBranches ( {
69
+ workspace : owner ,
70
+ repo_slug : repo ,
71
+ sort : "target.date" ,
72
+ page : String ( nextPage ) ,
79
73
} ) ;
74
+
75
+ for ( const branch of response . data . values ! ) {
76
+ branches . push ( {
77
+ htmlUrl : branch . links ?. html ?. href ! ,
78
+ name : branch . name ! ,
79
+ commit : {
80
+ sha : branch . target ?. hash ! ,
81
+ author : branch . target ?. author ?. user ?. display_name ! ,
82
+ authorAvatarUrl : branch . target ?. author ?. user ?. links ?. avatar ?. href ,
83
+ authorDate : branch . target ?. date ! ,
84
+ commitMessage : branch . target ?. message || "missing commit message" ,
85
+ } ,
86
+ } ) ;
87
+ }
88
+
89
+ // If the response has a "next" property, it indicates there are more pages.
90
+ if ( response . data . next ) {
91
+ nextPage ++ ;
92
+ } else {
93
+ isMoreDataAvailable = false ;
94
+ }
80
95
}
81
96
82
97
return branches ;
0 commit comments