Skip to content

Commit a56346c

Browse files
committed
handle projects without default_branch correctly
1 parent 6ad9094 commit a56346c

File tree

5 files changed

+24
-13
lines changed

5 files changed

+24
-13
lines changed

api/src/model/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ pub mod test {
9999
id: 456,
100100
name: "name".to_string(),
101101
web_url: "web_url".to_string(),
102-
default_branch: "default_branch".to_string(),
102+
default_branch: Some("default_branch".to_string()),
103103
topics: vec!["topic".to_string()],
104104
}
105105
}

api/src/model/project.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pub struct Project {
77
pub id: u64,
88
pub name: String,
99
pub web_url: String,
10-
pub default_branch: String,
10+
pub default_branch: Option<String>,
1111
pub topics: Vec<String>,
1212
}
1313

api/src/project/pipeline_aggregator.rs

+15-8
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,14 @@ impl PipelineAggregator {
4444
projects: Vec<Project>,
4545
) -> Result<Vec<ProjectPipeline>, ApiError> {
4646
try_collect_with_buffer(projects, |project| async move {
47-
let pipeline = self
48-
.pipeline_service
49-
.get_latest_pipeline(project.id, project.default_branch.clone())
50-
.await?;
47+
let pipeline = if let Some(default_branch) = project.clone().default_branch {
48+
self.pipeline_service
49+
.get_latest_pipeline(project.id, default_branch)
50+
.await?
51+
} else {
52+
None
53+
};
54+
5155
Ok(ProjectPipeline {
5256
group_id,
5357
project,
@@ -75,10 +79,13 @@ impl PipelineAggregator {
7579
projects: Vec<Project>,
7680
) -> Result<Vec<ProjectPipelines>, ApiError> {
7781
try_collect_with_buffer(projects, |project| async move {
78-
let pipelines = self
79-
.pipeline_service
80-
.get_pipelines(project.id, None)
81-
.await?;
82+
let pipelines = if project.default_branch.is_some() {
83+
self.pipeline_service
84+
.get_pipelines(project.id, None)
85+
.await?
86+
} else {
87+
Vec::default()
88+
};
8289
Ok(ProjectPipelines {
8390
group_id,
8491
project,

api/src/schedule/pipeline_aggregator.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@ impl PipelineAggregator {
4949
projects: Vec<Project>,
5050
) -> Result<Vec<ScheduleProjectPipeline>, ApiError> {
5151
let result = try_collect_with_buffer(projects, |project| async move {
52-
let schedules = self.schedule_service.get_schedules(project.id).await?;
52+
let schedules = if project.default_branch.is_some() {
53+
self.schedule_service.get_schedules(project.id).await?
54+
} else {
55+
Vec::default()
56+
};
5357
let result = self
5458
.with_latest_pipeline(group_id, &project, schedules)
5559
.await?;

proxy.conf.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const target = 'https://gitlab-ci-dashboard.larscom.nl'
2-
// const target = 'http://localhost:8080'
1+
// const target = 'https://gitlab-ci-dashboard.larscom.nl'
2+
const target = 'http://localhost:8080'
33

44
module.exports = {
55
'/api/**': {

0 commit comments

Comments
 (0)