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/5] 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 00000000..ac955b4d --- /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/5] 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 ac955b4d..fb0865ff 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/5] 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 fb0865ff..4e405910 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/5] 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 4e405910..e66b5d68 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 { From fc4edb8259f73548360fb1fee96e38c6cf7c41d3 Mon Sep 17 00:00:00 2001 From: TK <61820360+TomKovac@users.noreply.github.com> Date: Thu, 12 Dec 2024 15:01:26 +0100 Subject: [PATCH 5/5] wip --- scripts/create_issue_branch.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/create_issue_branch.ps1 b/scripts/create_issue_branch.ps1 index e66b5d68..af5e1e3e 100644 --- a/scripts/create_issue_branch.ps1 +++ b/scripts/create_issue_branch.ps1 @@ -15,6 +15,7 @@ if ([int]::TryParse($value, [ref]$null)) { 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 "$selectedIssueTitle" --body "closes #$selectedIssueNumber" --draft + git add . git commit -m "Create draft PR for #$selectedIssueNumber" git push Write-Output "Sync local and remote branches"