Skip to content

Commit d587b64

Browse files
authored
Link to allocator tech and issue in pr desc (#279)
1 parent 8979f23 commit d587b64

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

fplus-lib/src/config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ pub fn default_env_vars() -> &'static HashMap<&'static str, &'static str> {
4646
m.insert("AUTOALLOCATION_AMOUNT", "1099511627776"); // 1099511627776 B == 1 TiB
4747
m.insert("TFIDF_THRESHOLD", "0.4");
4848
m.insert("LEVENSHTEIN_THRESHOLD", "8");
49+
m.insert("ALLOCATOR_TECH_URL", "https://allocator.tech");
4950
m
5051
})
5152
}

fplus-lib/src/core/mod.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -874,12 +874,14 @@ impl LDNApplication {
874874
file_content.clone(),
875875
info.owner.clone(),
876876
info.repo.clone(),
877+
application_id.clone(),
877878
)
878879
.await?;
879880
Self::issue_waiting_for_gov_review(
880881
issue_number.clone(),
881882
info.owner.clone(),
882883
info.repo.clone(),
884+
app_id.clone(),
883885
)
884886
.await?;
885887
Self::update_issue_labels(
@@ -3402,12 +3404,14 @@ impl LDNApplication {
34023404
issue_number: String,
34033405
owner: String,
34043406
repo: String,
3407+
application_id: String,
34053408
) -> Result<bool, LDNError> {
3409+
let allocator_tech_url = get_env_var_or_default("ALLOCATOR_TECH_URL");
34063410
Self::add_comment_to_issue(
34073411
issue_number,
3408-
owner,
3409-
repo,
3410-
"Application is waiting for allocator review".to_string(),
3412+
owner.clone(),
3413+
repo.clone(),
3414+
format!("Application is waiting for allocator review.\n[Link to application on Allocator.tech]({}/application/{}/{}/{})", allocator_tech_url, owner, repo, application_id ),
34113415
)
34123416
.await?;
34133417

@@ -4846,6 +4850,7 @@ pub struct LDNPullRequest {
48464850
}
48474851

48484852
impl LDNPullRequest {
4853+
#[allow(clippy::too_many_arguments)]
48494854
async fn create_pr_for_new_application(
48504855
issue_number: String,
48514856
owner_name: String,
@@ -4854,6 +4859,7 @@ impl LDNPullRequest {
48544859
file_content: String,
48554860
owner: String,
48564861
repo: String,
4862+
application_id: String,
48574863
) -> Result<String, LDNError> {
48584864
let initial_commit = Self::application_initial_commit(&owner_name, &issue_number);
48594865
let gh: GithubWrapper = github_async_new(owner.to_string(), repo.to_string()).await?;
@@ -4884,6 +4890,7 @@ impl LDNPullRequest {
48844890
ref_request: create_ref_request,
48854891
file_content,
48864892
commit: initial_commit,
4893+
application_id,
48874894
})
48884895
.await
48894896
.map_err(|e| {
@@ -4937,6 +4944,7 @@ impl LDNPullRequest {
49374944
branch_name,
49384945
file_content: file_content.clone(),
49394946
commit: pr_title,
4947+
application_id: application_id.clone(),
49404948
})
49414949
.await
49424950
.map_err(|e| LDNError::Load(format!("Failed to get list of pull requests: {}", e)))?;

fplus-lib/src/external_services/github.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ pub struct CreateRefillMergeRequestData {
5353
pub branch_name: String,
5454
pub commit: String,
5555
pub file_sha: String,
56+
pub application_id: String,
5657
}
5758

5859
#[derive(Debug)]
@@ -64,6 +65,7 @@ pub struct CreateMergeRequestData {
6465
pub file_name: String,
6566
pub branch_name: String,
6667
pub commit: String,
68+
pub application_id: String,
6769
}
6870

6971
#[derive(Debug)]
@@ -626,12 +628,15 @@ impl GithubWrapper {
626628
branch_name,
627629
commit,
628630
file_sha,
631+
application_id,
629632
} = data;
630633
let _create_branch_res = self.create_branch(ref_request).await?;
631634
self.update_file_content(&file_name, &commit, &file_content, &branch_name, &file_sha)
632635
.await?;
636+
let allocator_tech_url = get_env_var_or_default("ALLOCATOR_TECH_URL");
637+
let pr_body = format!("[Link to related GitHub issue]({})\n[Link to your application on Allocator.tech]({}/application/{}/{}/{})",issue_link, allocator_tech_url, self.owner, self.repo, application_id);
633638
let pr = self
634-
.create_pull_request(&commit, &branch_name, &issue_link.to_string())
639+
.create_pull_request(&commit, &branch_name, &pr_body.to_string())
635640
.await?;
636641

637642
Ok((pr, file_sha))
@@ -649,17 +654,20 @@ impl GithubWrapper {
649654
file_name,
650655
branch_name,
651656
commit,
657+
application_id,
652658
} = data;
653659
let _create_branch_res = self.create_branch(ref_request).await?;
654660
let add_file_res = self
655661
.add_file(&file_name, &file_content, &commit, &branch_name)
656662
.await?;
657663
let file_sha = add_file_res.content.sha;
664+
let allocator_tech_url = get_env_var_or_default("ALLOCATOR_TECH_URL");
665+
let pr_body = format!("[Link to related GitHub issue]({})\n[Link to application on Allocator.tech]({}/application/{}/{}/{})",issue_link, allocator_tech_url, self.owner, self.repo, application_id);
658666
let pr = self
659667
.create_pull_request(
660668
&format!("Datacap for {}", owner_name),
661669
&branch_name,
662-
&issue_link.to_string(),
670+
pr_body,
663671
)
664672
.await?;
665673

0 commit comments

Comments
 (0)