From 03a1f9ea5ae48df811c7834000aeba6b635822cd Mon Sep 17 00:00:00 2001 From: TK <61820360+TomKovac@users.noreply.github.com> Date: Thu, 12 Dec 2024 14:30:53 +0100 Subject: [PATCH 1/4] cib --- scripts/create_issue_branch.ps1 | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 scripts/create_issue_branch.ps1 diff --git a/scripts/create_issue_branch.ps1 b/scripts/create_issue_branch.ps1 new file mode 100644 index 000000000..ac955b4da --- /dev/null +++ b/scripts/create_issue_branch.ps1 @@ -0,0 +1,22 @@ +gh issue lists --assignee "@me" --state "open" +$issueIDs = gh issue list --state "open" --assignee "@me" --json number | ConvertFrom-Json | ForEach-Object { $_.number } +$value = Read-Host "Please enter an ID value of the issue." + +if ([int]::TryParse($value, [ref]$null)) { + if ($issueIDs -contains [int]$value) { + Write-Output "Creating branch for the issue with ID: '$value'" + gh issue develop $value --base dev --checkout + Write-Output "Pushing the branch to remote" + git push -u origin $(git branch --show-current) + Write-Output "Creating a draft pull request into 'dev'" + gh pr create --base dev --head $(git branch --show-current) --title "closes $value" --body "Create draft PR for #$value" --draft + Write-Output "Sync local and remote branches" + git pull origin $(git branch --show-current) + } else { + Write-Output "Error: The issue ID '$value' does not exist in the list of open issues." + exit 1 + } +} else { + Write-Output "Error: The value '$value' is not a valid numeric value." + exit 1 +} \ No newline at end of file From a57acd3134d9e411317472f342baeb7f2cab45f1 Mon Sep 17 00:00:00 2001 From: TK <61820360+TomKovac@users.noreply.github.com> Date: Thu, 12 Dec 2024 14:34:30 +0100 Subject: [PATCH 2/4] wip --- scripts/create_issue_branch.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/create_issue_branch.ps1 b/scripts/create_issue_branch.ps1 index ac955b4da..fb0865ff5 100644 --- a/scripts/create_issue_branch.ps1 +++ b/scripts/create_issue_branch.ps1 @@ -1,4 +1,4 @@ -gh issue lists --assignee "@me" --state "open" +gh issue list --assignee "@me" --state "open" $issueIDs = gh issue list --state "open" --assignee "@me" --json number | ConvertFrom-Json | ForEach-Object { $_.number } $value = Read-Host "Please enter an ID value of the issue." From 4b65b22901557527f8406d0aeefc300bc4c85600 Mon Sep 17 00:00:00 2001 From: TK <61820360+TomKovac@users.noreply.github.com> Date: Thu, 12 Dec 2024 14:51:08 +0100 Subject: [PATCH 3/4] wip --- scripts/create_issue_branch.ps1 | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/scripts/create_issue_branch.ps1 b/scripts/create_issue_branch.ps1 index fb0865ff5..4e4059102 100644 --- a/scripts/create_issue_branch.ps1 +++ b/scripts/create_issue_branch.ps1 @@ -1,15 +1,21 @@ gh issue list --assignee "@me" --state "open" -$issueIDs = gh issue list --state "open" --assignee "@me" --json number | ConvertFrom-Json | ForEach-Object { $_.number } +$issues = gh issue list --state "open" --assignee "@me" --json number,title | ConvertFrom-Json +$issueIDs = $issues | ForEach-Object { $_.number } + $value = Read-Host "Please enter an ID value of the issue." if ([int]::TryParse($value, [ref]$null)) { if ($issueIDs -contains [int]$value) { - Write-Output "Creating branch for the issue with ID: '$value'" + $selectedIssue = $issues | Where-Object { $_.number -eq [int]$value } + $selectedIssueNumber = $selectedIssue.number + $selectedIssueTitle = $selectedIssue.title + Write-Output "Creating branch for the issue number: '$selectedIssueNumber', title: '$selectedIssueTitle'" gh issue develop $value --base dev --checkout Write-Output "Pushing the branch to remote" git push -u origin $(git branch --show-current) Write-Output "Creating a draft pull request into 'dev'" - gh pr create --base dev --head $(git branch --show-current) --title "closes $value" --body "Create draft PR for #$value" --draft + gh pr create --base dev --head $(git branch --show-current) --title "closes $selectedIssueTitle" --body "closes #$selectedIssueNumber" --draft + git commit -m "Create draft PR for #$selectedIssueNumber" Write-Output "Sync local and remote branches" git pull origin $(git branch --show-current) } else { From c0090b0267ab2514a2bf58df1fc6fd60ba4cfd60 Mon Sep 17 00:00:00 2001 From: TK <61820360+TomKovac@users.noreply.github.com> Date: Thu, 12 Dec 2024 14:59:45 +0100 Subject: [PATCH 4/4] wip --- scripts/create_issue_branch.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/create_issue_branch.ps1 b/scripts/create_issue_branch.ps1 index 4e4059102..e66b5d688 100644 --- a/scripts/create_issue_branch.ps1 +++ b/scripts/create_issue_branch.ps1 @@ -14,8 +14,9 @@ if ([int]::TryParse($value, [ref]$null)) { Write-Output "Pushing the branch to remote" git push -u origin $(git branch --show-current) Write-Output "Creating a draft pull request into 'dev'" - gh pr create --base dev --head $(git branch --show-current) --title "closes $selectedIssueTitle" --body "closes #$selectedIssueNumber" --draft + gh pr create --base dev --head $(git branch --show-current) --title "$selectedIssueTitle" --body "closes #$selectedIssueNumber" --draft git commit -m "Create draft PR for #$selectedIssueNumber" + git push Write-Output "Sync local and remote branches" git pull origin $(git branch --show-current) } else {