mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-11-28 04:47:42 +03:00
fix: use relativePath and get project basePath on rust side
This commit is contained in:
parent
d14b6496b1
commit
e8bb66c151
@ -93,7 +93,7 @@
|
||||
const prTemplatePath = project.git_host.pullRequestTemplatePath;
|
||||
|
||||
if (prTemplatePath) {
|
||||
pullRequestTemplateBody = await $prService?.getPrTemplateContent(prTemplatePath);
|
||||
pullRequestTemplateBody = await $prService?.getPrTemplateContent(prTemplatePath, project.id);
|
||||
}
|
||||
|
||||
if (pullRequestTemplateBody) {
|
||||
|
@ -90,9 +90,12 @@ export class GitHubPrService implements GitHostPrService {
|
||||
return new GitHubPrMonitor(this, prNumber);
|
||||
}
|
||||
|
||||
async getPrTemplateContent(path: string) {
|
||||
async getPrTemplateContent(path: string, projectId: string) {
|
||||
try {
|
||||
const fileContents: string | undefined = await invoke('get_pr_template_contents', { path });
|
||||
const fileContents: string | undefined = await invoke('get_pr_template_contents', {
|
||||
relativePath: path,
|
||||
projectId
|
||||
});
|
||||
return fileContents;
|
||||
} catch (err) {
|
||||
console.error(`Error reading pull request template at path: ${path}`, err);
|
||||
|
@ -17,8 +17,8 @@ export interface GitHostPrService {
|
||||
baseBranchName,
|
||||
upstreamName
|
||||
}: CreatePullRequestArgs): Promise<PullRequest>;
|
||||
getAvailablePrTemplates(path?: string): Promise<string[] | undefined>;
|
||||
getPrTemplateContent(path?: string): Promise<string | undefined>;
|
||||
getAvailablePrTemplates(path: string): Promise<string[] | undefined>;
|
||||
getPrTemplateContent(path: string, projectId: string): Promise<string | undefined>;
|
||||
merge(method: MergeMethod, prNumber: number): Promise<void>;
|
||||
prMonitor(prNumber: number): GitHostPrMonitor;
|
||||
}
|
||||
|
@ -25,9 +25,10 @@
|
||||
$prService?.getAvailablePrTemplates(project.path).then((availableTemplates) => {
|
||||
if (availableTemplates) {
|
||||
allAvailableTemplates = availableTemplates.map((availableTemplate) => {
|
||||
const relativePath = availableTemplate.replace(`${project.path}/`, '');
|
||||
return {
|
||||
label: availableTemplate.replace(`${project.path}/`, ''),
|
||||
value: availableTemplate
|
||||
label: relativePath,
|
||||
value: relativePath
|
||||
};
|
||||
});
|
||||
}
|
||||
|
@ -99,9 +99,16 @@ pub mod commands {
|
||||
}
|
||||
|
||||
#[tauri::command(async)]
|
||||
#[instrument]
|
||||
pub fn get_pr_template_contents(path: &path::Path) -> Result<String, Error> {
|
||||
Ok(read_file_from_workspace(&path)?)
|
||||
#[instrument(skip(projects))]
|
||||
pub fn get_pr_template_contents(
|
||||
projects: State<'_, Controller>,
|
||||
relative_path: &path::Path,
|
||||
project_id: ProjectId,
|
||||
) -> Result<String, Error> {
|
||||
let project = projects.get(project_id)?;
|
||||
let template_path = project.path.join(relative_path);
|
||||
|
||||
Ok(read_file_from_workspace(&template_path.as_path())?)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user