Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

[#56994] Fix git snippet for GitHub appear broken (although it isn't)

Judith Rotha0b38ba8ee7d
diff --git a/modules/github_integration/frontend/module/git-actions-menu/git-actions-menu.component.spec.ts b/modules/github_integration/frontend/module/git-actions-menu/git-actions-menu.component.spec.ts
index 20c6e56a4e9..4a893ed81d8 100644
--- a/modules/github_integration/frontend/module/git-actions-menu/git-actions-menu.component.spec.ts
+++ b/modules/github_integration/frontend/module/git-actions-menu/git-actions-menu.component.spec.ts
@@ -31,7 +31,7 @@ describe('GitActionsMenuComponent', () => {
}
beforeEach(async () => {
- const gitActionsServiceSpy = jasmine.createSpyObj('GitActionsService', ['gitCommand', 'commitMessage', 'branchName']);
+ const gitActionsServiceSpy = jasmine.createSpyObj('GitActionsService', ['gitCommand', 'commitMessage', 'commitMessageDisplayText', 'branchName']);
await TestBed
.configureTestingModule({
diff --git a/modules/github_integration/frontend/module/git-actions-menu/git-actions-menu.component.ts b/modules/github_integration/frontend/module/git-actions-menu/git-actions-menu.component.ts
index 8d3b5fc0f9b..8abc5207bbf 100644
--- a/modules/github_integration/frontend/module/git-actions-menu/git-actions-menu.component.ts
+++ b/modules/github_integration/frontend/module/git-actions-menu/git-actions-menu.component.ts
@@ -72,16 +72,19 @@ export class GitActionsMenuComponent extends OPContextMenuComponent {
{
id: 'branch',
name: this.I18n.t('js.github_integration.tab_header.git_actions.branch_name'),
+ textToDisplay: () => this.gitActions.branchName(this.workPackage),
textToCopy: () => this.gitActions.branchName(this.workPackage),
},
{
id: 'message',
name: this.I18n.t('js.github_integration.tab_header.git_actions.commit_message'),
+ textToDisplay: () => this.gitActions.commitMessageDisplayText(this.workPackage),
textToCopy: () => this.gitActions.commitMessage(this.workPackage),
},
{
id: 'command',
name: this.I18n.t('js.github_integration.tab_header.git_actions.cmd'),
+ textToDisplay: () => this.gitActions.gitCommand(this.workPackage),
textToCopy: () => this.gitActions.gitCommand(this.workPackage),
},
];
diff --git a/modules/github_integration/frontend/module/git-actions-menu/git-actions-menu.template.html b/modules/github_integration/frontend/module/git-actions-menu/git-actions-menu.template.html
index 637d24c85af..66ee11151ed 100644
--- a/modules/github_integration/frontend/module/git-actions-menu/git-actions-menu.template.html
+++ b/modules/github_integration/frontend/module/git-actions-menu/git-actions-menu.template.html
@@ -5,7 +5,7 @@
<label class="spot-form-field--label-wrap">
<div class="spot-form-field--label">{{ snippet.name }}</div>
<div class="spot-form-field--input">
- <input type="text" class="copy-content op-input" readonly="true" [value]="snippet.textToCopy()">
+ <input type="text" class="copy-content op-input" readonly="true" [value]="snippet.textToDisplay()">
<button
class="button copy-button"
type="button"
diff --git a/modules/github_integration/frontend/module/git-actions/git-actions.service.ts b/modules/github_integration/frontend/module/git-actions/git-actions.service.ts
index fd730d91980..21fdb96322c 100644
--- a/modules/github_integration/frontend/module/git-actions/git-actions.service.ts
+++ b/modules/github_integration/frontend/module/git-actions/git-actions.service.ts
@@ -78,6 +78,10 @@ ${url}
`.replace(/\n\n+/g, '\n\n');
}
+ public commitMessageDisplayText(workPackage:WorkPackageResource):string {
+ return this.commitMessage(workPackage).replace(/\n\n/g, ' ');
+ }
+
public gitCommand(workPackage:WorkPackageResource):string {
const branch = this.branchName(workPackage);
const commit = this.commitMessage(workPackage);
diff --git a/modules/github_integration/frontend/module/state/github-pull-request.model.ts b/modules/github_integration/frontend/module/state/github-pull-request.model.ts
index 780a76631e2..715aeff92c2 100644
--- a/modules/github_integration/frontend/module/state/github-pull-request.model.ts
+++ b/modules/github_integration/frontend/module/state/github-pull-request.model.ts
@@ -7,6 +7,7 @@ import { ID } from '@datorama/akita';
export interface ISnippet {
id:string;
name:string;
+ textToDisplay:() => string;
textToCopy:() => string
}