mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2026-12-07 06:12:53 +11:00
chore(gh): repo prettifying (#5260)
* chore(gh): repo prettifying * Fine, that makes sense Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * This commit is generated by Copilot, I do understand that it can't be a slop, please do not scream at me, I ahave uwutism * This another PR was also done by Copilot to satisfy CodeRabbit * chore: remove docs from release drafter Approved by @seanh1995. Kinda * chore: bug report prettify * chore: freaking tabbed markdown, sadistic way to structurize * chore: exclude automated PRs from labeling and release list * MAN OUTTA THE BOARD, MAN OUTTA THE BOARD * fix(ci): handle merged PRs without discussion references * fix(ci): preserve manual labels and narrow changelog exclusions * Revert "fix(ci): preserve manual labels and narrow changelog exclusions" This reverts commitca07eda58e. * Revert "fix(ci): handle merged PRs without discussion references" This reverts commit766a57e52f. --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Chris Titus <7896101+ChrisTitusTech@users.noreply.github.com>
This commit is contained in:
12 files changed
+293
-151
No files matched your search
@@ -114,5 +114,6 @@ Open PowerShell as Administrator.
|
||||
|
||||
### Making a PR
|
||||
* To make a PR on your repo under a new branch linking to the main branch, a button will show and say Preview and Create pull request. Click that button and fill in all the information that is provided on the template. Once all the information is filled in correctly, check your PR to make sure there is no WinUtil.ps1 file attached to the PR. Once everything is good, make the PR and wait for Chris (the maintainer) to accept or deny your PR. Once it is accepted by Chris, you will be able to see your changes in the "/windev" build.
|
||||
* Pay attention to comments that are present in template, some of them tell about proper presentation of your PR, which allows Github to properly label it
|
||||
* If you do not see your feature in the main "/win" build, that is fine. All new changes go into the /windev build to make sure everything is working OK before going fully public.
|
||||
* Congratulations! You just submitted your first PR. Thank you so much for contributing to WinUtil.
|
||||
@@ -60,6 +60,12 @@ body:
|
||||
- type: textarea
|
||||
id: error_output
|
||||
attributes:
|
||||
label: Paste the full error output (if available) or Screenshot or Video.
|
||||
description: "If you're willing to share the whole log, please provide an external link to text-sharing service, i.e. Pastebin"
|
||||
label: Error logs
|
||||
description: "Paste the full error output (if available) or replace pre-filled text with a screenshot or video clip."
|
||||
placeholder: "Include any relevant logs or error messages. Keep any sensitive info out of the presented log"
|
||||
value: |
|
||||
<details>
|
||||
<summary>Click to expand</summary>
|
||||
<!--Place your log under this tag-->
|
||||
|
||||
</details>
|
||||
@@ -1,14 +1,18 @@
|
||||
<!--Before you make this PR have you followed the docs here? - https://winutil.christitus.com/contributing/ -->
|
||||
<!--Documentation is auto-generated from configs - no manual documentation updates needed -->
|
||||
<!--The generated code-reference pages (tweaks and features) need no manual updates. Other code-reference pages are hand-written; update them when your change affects them. -->
|
||||
|
||||
## Type of Change
|
||||
- [ ] New feature
|
||||
- [ ] Bug fix
|
||||
- [ ] Documentation update
|
||||
- [ ] Refactor
|
||||
- [ ] UI/UX improvement
|
||||
<!--
|
||||
For proper labeling on each PR better use next title strategy:
|
||||
fix(section): Some bug fix for that section
|
||||
feat(section): Providing a new feature on that section/major refactoring of present code
|
||||
chore(section): Some chores - code clearing, typo fixes etc
|
||||
docs: Documentation update
|
||||
ui-ux(section): Bare UI/UX updates with no major feature implementation
|
||||
|
||||
<!-- This automatically adds labels to your PR based on the selections above. -->
|
||||
Brackets part is optional, title "tag: added a thing" still results in feature labeling
|
||||
The mapped type labels are managed by the title workflow, even when added manually.
|
||||
Retitling a PR removes mapped labels that no longer match; an unrecognized title removes all of them.
|
||||
|
||||
-->
|
||||
|
||||
## Description
|
||||
<!--[What does this PR do? Provide Screenshots when possible.]-->
|
||||
@@ -16,3 +20,7 @@
|
||||
## Issue related to PR
|
||||
<!--[List any ISSUES this is related to as it AUTO-CLOSES Them!]-->
|
||||
- Resolves #
|
||||
|
||||
## PR human checks
|
||||
- [ ] This PR is not a blind result of a prompt 'make this project better, no mistakes'
|
||||
- [ ] I've read the [contributing guidelines](https://winutil.christitus.com/contributing/)
|
||||
@@ -1,105 +0,0 @@
|
||||
# Chris Titus Tech's Windows Utility
|
||||
|
||||
[](https://github.com/ChrisTitusTech/winutil/releases/latest)
|
||||

|
||||
[](https://discord.gg/RUbZUZyByQ)
|
||||
[](https://winutil.christitus.com/)
|
||||
|
||||
Questa utility è una raccolta di attività Windows che eseguo personalmente su ogni sistema che utilizzo. È progettata per snellire le *installazioni*, rimuovere i componenti superflui tramite *ottimizzazioni*, risolvere problemi tramite la *configurazione*, e riparare *aggiornamenti* di Windows. Sono estremamente selettivo riguardo ai contributi per mantenere questo progetto pulito ed efficiente.
|
||||
|
||||

|
||||
|
||||
## 💡 Come usarlo
|
||||
|
||||
Winutil deve essere eseguito con privilegi di amministratore, poiché apporta modifiche all'intero sistema. Per farlo, avvia PowerShell come amministratore. Ecco alcuni modi per procedere:
|
||||
|
||||
1. **Metodo del menu di Start:**
|
||||
- Fai clic con il tasto destro sul menu Start.
|
||||
- Scegli "Windows PowerShell (esegui come Amministratore)" (per Windows 10) o "Terminale (esegui come Amministratore)" (per Windows 11).
|
||||
|
||||
2. **Metodo tramite ricerca:**
|
||||
- Premi il tasto Windows.
|
||||
- Digita "PowerShell" o "Terminal" (per Windows 11).
|
||||
- Premi `Ctrl + Shift + Invio` oppure fai clic con il tasto destro e seleziona "Esegui come amministratore" per avviarlo con privilegi elevati.
|
||||
|
||||
### Comando di avvio
|
||||
|
||||
#### Branch stabile (Consigliato)
|
||||
|
||||
```ps1
|
||||
irm "https://christitus.com/win" | iex
|
||||
```
|
||||
#### Branch Sviluppatore
|
||||
|
||||
```ps1
|
||||
irm "https://christitus.com/windev" | iex
|
||||
```
|
||||
|
||||
### Automazione
|
||||
|
||||
Winutil supporta anche preset predefiniti che applicano automaticamente configurazioni comuni:
|
||||
|
||||
- `Standard`
|
||||
- `Minimal`
|
||||
- `Advanced`
|
||||
|
||||
Esempio:
|
||||
|
||||
```powershell
|
||||
& ([ScriptBlock]::Create((irm "https://christitus.com/win"))) -Preset Standard
|
||||
```
|
||||
|
||||
Per vedere esattamente cosa fa ogni preset, consulta:
|
||||
https://github.com/ChrisTitusTech/winutil/blob/main/config/preset.json
|
||||
|
||||
In caso di problemi, consulta i [Problemi noti](https://winutil.christitus.com/knownissues/) o [Apri una segnalazione](https://github.com/ChrisTitusTech/winutil/issues)
|
||||
|
||||
## 🎓 Documentazione
|
||||
|
||||
### [Documentazione ufficiale di WinUtil](https://winutil.christitus.com/)
|
||||
|
||||
### [Tutorial su YouTube](https://www.youtube.com/watch?v=6UQZ5oQg8XA)
|
||||
|
||||
### [Articolo su ChrisTitus.com](https://christitus.com/windows-tool/)
|
||||
|
||||
## 🛠️ Build & Sviluppo
|
||||
|
||||
> [!NOTE]
|
||||
> Winutil è uno script piuttosto esteso, per questo è suddiviso in più file che vengono combinati in un unico file `.ps1` tramite un compilatore personalizzato. Questo rende la manutenzione del progetto molto più semplice.
|
||||
|
||||
Ottieni una copia del codice sorgente. Puoi farlo tramite l'interfaccia di GitHub (**Code** > **Download ZIP**), oppure clonando (scaricando) la repo tramite git.
|
||||
|
||||
Se git è installato, esegui i seguenti comandi in una finestra PowerShell per clonare e accedere alla directory del progetto:
|
||||
```ps1
|
||||
git clone --depth 1 "https://github.com/ChrisTitusTech/winutil.git"
|
||||
cd winutil
|
||||
```
|
||||
|
||||
Per compilare il progetto, esegui lo script di compilazione in una finestra PowerShell (i permessi di amministratore NON sono richiesti):
|
||||
```ps1
|
||||
.\Compile.ps1
|
||||
```
|
||||
|
||||
Troverai un nuovo file chiamato `winutil.ps1`, creato dallo script `Compile.ps1`. Ora puoi eseguirlo come amministratore e apparirà una nuova finestra. Goditi la tua versione compilata di WinUtil :)
|
||||
|
||||
> [!TIP]
|
||||
> Per ulteriori informazioni sull'utilizzo di WinUtil e su come contribuire allo sviluppo, ti invitiamo a leggere le [Linee guida per i contributi](https://winutil.christitus.com/contributing/). Se non sai da dove iniziare o hai domande, puoi chiedere sul nostro [Server Discord della community](https://discord.gg/RUbZUZyByQ); i membri attivi del progetto risponderanno appena possibile.
|
||||
|
||||
## 💖 Supporto
|
||||
- Per sostenere il progetto moralmente e mentalmente, non dimenticare di lasciare una ⭐️!
|
||||
- Wrapper EXE a 10$ su https://www.cttstore.com/windows-toolbox
|
||||
|
||||
## 💖 Sponsor
|
||||
|
||||
Questi sono gli sponsor che aiutano a mantenere vivo il progetto con contributi mensili.
|
||||
|
||||
<!-- sponsors --><a href="https://github.com/dwelfusius"><img src="https://github.com/dwelfusius.png" width="60px" alt="Avatar utente: " /></a><a href="https://github.com/mews-se"><img src="https://github.com/mews-se.png" width="60px" alt="Avatar utente: Martin Stockzell" /></a><a href="https://github.com/jdiegmueller"><img src="https://github.com/jdiegmueller.png" width="60px" alt="Avatar utente: Jason A. Diegmueller" /></a><a href="https://github.com/robertsandrock"><img src="https://github.com/robertsandrock.png" width="60px" alt="Avatar utente: RMS" /></a><a href="https://github.com/paulsheets"><img src="https://github.com/paulsheets.png" width="60px" alt="Avatar utente: Paul" /></a><a href="https://github.com/djones369"><img src="https://github.com/djones369.png" width="60px" alt="Avatar utente: Dave J (WhamGeek)" /></a><a href="https://github.com/anthonymendez"><img src="https://github.com/anthonymendez.png" width="60px" alt="Avatar utente: Anthony Mendez" /></a><a href="https://github.com/FatBastard0"><img src="https://github.com/FatBastard0.png" width="60px" alt="Avatar utente: " /></a><a href="https://github.com/DursleyGuy"><img src="https://github.com/DursleyGuy.png" width="60px" alt="Avatar utente: DursleyGuy" /></a><a href="https://github.com/DwayneTheRockLobster1"><img src="https://github.com/DwayneTheRockLobster1.png" width="60px" alt="Avatar utente: " /></a><a href="https://github.com/KieraKujisawa"><img src="https://github.com/KieraKujisawa.png" width="60px" alt="Avatar utente: Kiera Meredith" /></a><a href="https://github.com/andrewpayne68"><img src="https://github.com/andrewpayne68.png" width="60px" alt="Avatar utente: Andrew P" /></a><!-- sponsors -->
|
||||
|
||||
## 🏅 Grazie a tutti i collaboratori
|
||||
Un ringraziamento speciale per aver dedicato il vostro tempo ad aiutare Winutil a crescere. Grazie mille! Continuate così 🍻.
|
||||
|
||||
[](https://github.com/ChrisTitusTech/winutil/graphs/contributors)
|
||||
|
||||
## 📊 Statistiche GitHub
|
||||
|
||||

|
||||
@@ -10,10 +10,12 @@ categories:
|
||||
- 'hotfix'
|
||||
- 'bugfix'
|
||||
- 'bug'
|
||||
- title: 'Documentation'
|
||||
label: 'documentation'
|
||||
- title: 'UI/UX Improvements'
|
||||
label: 'ui update'
|
||||
labels:
|
||||
- 'ui update'
|
||||
- 'ui-ux'
|
||||
- title: 'Slop cleaning'
|
||||
label: 'chore'
|
||||
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
|
||||
template: |
|
||||
## Changes
|
||||
@@ -48,5 +50,6 @@ replacers:
|
||||
replace: ''
|
||||
exclude-labels:
|
||||
- 'skip-changelog'
|
||||
- 'automated'
|
||||
|
||||
filter-by-commitish: true
|
||||
@@ -0,0 +1,84 @@
|
||||
const assert = require('node:assert/strict');
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
const { spawnSync } = require('node:child_process');
|
||||
const test = require('node:test');
|
||||
|
||||
const workflow = fs.readFileSync(path.join(__dirname, '../workflows/close-discussion-on-pr.yaml'), 'utf8');
|
||||
const script = workflow.split(' run: |\n')[1]
|
||||
.split(' shell: bash')[0]
|
||||
.split('\n')
|
||||
.map(line => line.slice(10))
|
||||
.join('\n');
|
||||
|
||||
function run(lookup, close) {
|
||||
const mockCurl = `
|
||||
curl() {
|
||||
local payload='' token='' endpoint=''
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case "$1" in
|
||||
--data) payload="$2"; shift 2 ;;
|
||||
-H) [ "$2" = "Authorization: token $GITHUB_TOKEN" ] && token=present; shift 2 ;;
|
||||
-X) shift 2 ;;
|
||||
http*) endpoint="$1"; shift ;;
|
||||
*) shift ;;
|
||||
esac
|
||||
done
|
||||
[ "$token" = present ] && [ "$endpoint" = "$GITHUB_API_URL/graphql" ] || return 1
|
||||
printf 'REQUEST:%s\\n' "$payload" >&2
|
||||
if [[ "$(jq -r '.query' <<< "$payload")" == mutation* ]]; then
|
||||
printf '%s\\n' "$MOCK_CLOSE"
|
||||
else
|
||||
printf '%s\\n' "$MOCK_LOOKUP"
|
||||
fi
|
||||
}
|
||||
`;
|
||||
const result = spawnSync('bash', ['-eo', 'pipefail', '-c', mockCurl + script], {
|
||||
encoding: 'utf8',
|
||||
env: {
|
||||
...process.env,
|
||||
PR_BODY: 'Resolves #123',
|
||||
GITHUB_REPOSITORY: 'owner/repo',
|
||||
GITHUB_API_URL: 'https://api.github.example',
|
||||
GITHUB_TOKEN: 'test-token',
|
||||
MOCK_LOOKUP: JSON.stringify(lookup),
|
||||
MOCK_CLOSE: JSON.stringify(close)
|
||||
}
|
||||
});
|
||||
assert.equal(result.status, 0, result.stderr);
|
||||
return {
|
||||
output: result.stdout,
|
||||
requests: result.stderr.trim().split('\n')
|
||||
.filter(line => line.startsWith('REQUEST:'))
|
||||
.map(line => JSON.parse(line.slice('REQUEST:'.length)))
|
||||
};
|
||||
}
|
||||
|
||||
test('looks up the discussion number and closes the returned node ID', () => {
|
||||
const result = run(
|
||||
{ data: { repository: { discussion: { id: 'D_node' } } } },
|
||||
{ data: { closeDiscussion: { discussion: { closed: true } } } }
|
||||
);
|
||||
assert.equal(result.requests.length, 2);
|
||||
assert.match(result.requests[0].query, /discussion\(number: \$number\)/);
|
||||
assert.deepEqual(result.requests[0].variables, { owner: 'owner', name: 'repo', number: 123 });
|
||||
assert.match(result.requests[1].query, /closeDiscussion\(input: \{discussionId: \$id\}\)/);
|
||||
assert.deepEqual(result.requests[1].variables, { id: 'D_node' });
|
||||
assert.match(result.output, /Successfully closed discussion #123/);
|
||||
});
|
||||
|
||||
test('does not close when the GraphQL lookup fails', () => {
|
||||
const result = run({ errors: [{ message: 'Not found' }] }, {});
|
||||
assert.equal(result.requests.length, 1);
|
||||
assert.match(result.output, /Warning: Failed to look up discussion #123/);
|
||||
});
|
||||
|
||||
test('reports GraphQL mutation failures instead of claiming success', () => {
|
||||
const result = run(
|
||||
{ data: { repository: { discussion: { id: 'D_node' } } } },
|
||||
{ errors: [{ message: 'Not authorized' }] }
|
||||
);
|
||||
assert.equal(result.requests.length, 2);
|
||||
assert.match(result.output, /Warning: Failed to close discussion #123/);
|
||||
assert.doesNotMatch(result.output, /Successfully closed/);
|
||||
});
|
||||
@@ -0,0 +1,74 @@
|
||||
const assert = require('node:assert/strict');
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
const test = require('node:test');
|
||||
|
||||
const workflow = fs.readFileSync(path.join(__dirname, '../workflows/label-pr.yaml'), 'utf8').replace(/\r\n/g, '\n');
|
||||
const script = workflow.split(' script: |\n')[1]
|
||||
.split('\n')
|
||||
.map(line => line.slice(12))
|
||||
.join('\n');
|
||||
const AsyncFunction = Object.getPrototypeOf(async function () {}).constructor;
|
||||
const runWorkflow = new AsyncFunction('github', 'context', script);
|
||||
|
||||
async function labelChanges(title, labels, files = [{ filename: 'functions/example.ps1' }], eventLabels = []) {
|
||||
const calls = [];
|
||||
const github = {
|
||||
paginate: async () => files,
|
||||
rest: {
|
||||
pulls: {
|
||||
get: async () => ({ data: { number: 42, title, labels: labels.map(name => ({ name })) } }),
|
||||
listFiles: () => {}
|
||||
},
|
||||
issues: {
|
||||
addLabels: async ({ labels: added }) => calls.push(['add', ...added]),
|
||||
removeLabel: async ({ name }) => calls.push(['remove', name])
|
||||
}
|
||||
}
|
||||
};
|
||||
const context = {
|
||||
repo: { owner: 'owner', repo: 'repo' },
|
||||
payload: { pull_request: { number: 42, title: 'feat: stale event', labels: eventLabels.map(name => ({ name })) } }
|
||||
};
|
||||
await runWorkflow(github, context);
|
||||
return calls;
|
||||
}
|
||||
|
||||
test('retitling removes obsolete mapped labels before adding the current label', async () => {
|
||||
assert.deepEqual(await labelChanges('Fix(ui): corrected', ['new feature', 'documentation', 'custom']), [
|
||||
['remove', 'new feature'],
|
||||
['remove', 'documentation'],
|
||||
['add', 'bug']
|
||||
]);
|
||||
});
|
||||
|
||||
test('an unrecognized title removes mapped labels but preserves unrelated labels', async () => {
|
||||
assert.deepEqual(await labelChanges('Updated description', ['bug', 'custom']), [['remove', 'bug']]);
|
||||
});
|
||||
|
||||
test('an already matching type label is retained', async () => {
|
||||
assert.deepEqual(await labelChanges('docs: update', ['documentation', 'custom']), []);
|
||||
});
|
||||
|
||||
test('skip-changelog reconciliation uses current labels and current files', async () => {
|
||||
const code = [{ filename: 'functions/example.ps1' }];
|
||||
const docs = [{ filename: 'docs/example.mdx' }];
|
||||
assert.deepEqual(await labelChanges('Update', ['skip-changelog'], code), [['remove', 'skip-changelog']]);
|
||||
assert.deepEqual(await labelChanges('Update', [], docs, ['skip-changelog']), [['add', 'skip-changelog']]);
|
||||
assert.deepEqual(await labelChanges('Update', [], code, ['skip-changelog']), []);
|
||||
assert.deepEqual(await labelChanges('Update', ['skip-changelog'], docs), []);
|
||||
});
|
||||
|
||||
test('the embedded unattended XML is classified as a code change', async () => {
|
||||
const files = [{ filename: 'tools/autounattend.xml' }];
|
||||
assert.deepEqual(await labelChanges('Update', [], files), []);
|
||||
assert.deepEqual(await labelChanges('Update', ['skip-changelog'], files), [['remove', 'skip-changelog']]);
|
||||
assert.deepEqual(
|
||||
await labelChanges('Update', ['skip-changelog'], [{ filename: 'docs/old.xml', previous_filename: 'tools/autounattend.xml' }]),
|
||||
[['remove', 'skip-changelog']]
|
||||
);
|
||||
assert.deepEqual(
|
||||
await labelChanges('Update', [], [{ filename: 'tools/autounattend.xml.backup' }]),
|
||||
[['add', 'skip-changelog']]
|
||||
);
|
||||
});
|
||||
@@ -1,16 +1,17 @@
|
||||
name: Close Discussion on PR Merge
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
pull_request_target:
|
||||
types: [closed]
|
||||
|
||||
|
||||
jobs:
|
||||
closeDiscussion:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
discussions: write
|
||||
contents: read
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v7
|
||||
|
||||
- name: Check if PR was merged
|
||||
if: github.event.pull_request.merged == true
|
||||
run: echo "PR was merged"
|
||||
@@ -32,17 +33,32 @@ jobs:
|
||||
|
||||
for discussion_id in $discussion_ids; do
|
||||
echo "Attempting to close discussion #$discussion_id"
|
||||
response=$(curl -s -X PATCH -H "Authorization: token $GITHUB_TOKEN" \
|
||||
-H "Accept: application/vnd.github.v3+json" \
|
||||
-d '{"state": "closed"}' \
|
||||
"https://api.github.com/repos/${{ github.repository }}/discussions/$discussion_id")
|
||||
lookup_payload=$(jq -nc \
|
||||
--arg owner "${GITHUB_REPOSITORY%/*}" \
|
||||
--arg name "${GITHUB_REPOSITORY#*/}" \
|
||||
--argjson number "$discussion_id" \
|
||||
'{query: "query($owner: String!, $name: String!, $number: Int!) { repository(owner: $owner, name: $name) { discussion(number: $number) { id } } }", variables: {owner: $owner, name: $name, number: $number}}')
|
||||
if ! response=$(curl --fail-with-body -sS -X POST -H "Authorization: token $GITHUB_TOKEN" \
|
||||
-H "Content-Type: application/json" --data "$lookup_payload" "$GITHUB_API_URL/graphql"); then
|
||||
echo "Warning: Failed to look up discussion #$discussion_id. Response: $response"
|
||||
continue
|
||||
fi
|
||||
if ! discussion_node_id=$(echo "$response" | jq -er 'select(.errors == null) | .data.repository.discussion.id | select(type == "string" and length > 0)'); then
|
||||
echo "Warning: Failed to look up discussion #$discussion_id. Response: $response"
|
||||
continue
|
||||
fi
|
||||
|
||||
if echo "$response" | jq -e '.id' > /dev/null; then
|
||||
close_payload=$(jq -nc --arg id "$discussion_node_id" \
|
||||
'{query: "mutation($id: ID!) { closeDiscussion(input: {discussionId: $id}) { discussion { closed } } }", variables: {id: $id}}')
|
||||
if ! response=$(curl --fail-with-body -sS -X POST -H "Authorization: token $GITHUB_TOKEN" \
|
||||
-H "Content-Type: application/json" --data "$close_payload" "$GITHUB_API_URL/graphql"); then
|
||||
echo "Warning: Failed to close discussion #$discussion_id. Response: $response"
|
||||
continue
|
||||
fi
|
||||
if echo "$response" | jq -e '.errors == null and .data.closeDiscussion.discussion.closed == true' > /dev/null; then
|
||||
echo "Successfully closed discussion #$discussion_id"
|
||||
else
|
||||
error_message=$(echo "$response" | jq -r '.message // "Unknown error"')
|
||||
echo "Warning: Failed to close discussion #$discussion_id. Error: $error_message"
|
||||
echo "Full response: $response"
|
||||
echo "Warning: Failed to close discussion #$discussion_id. Response: $response"
|
||||
fi
|
||||
done
|
||||
shell: bash
|
||||
|
||||
@@ -6,40 +6,88 @@ on:
|
||||
|
||||
jobs:
|
||||
label-pr:
|
||||
if: github.event.pull_request.head.repo.full_name != github.repository || github.event.pull_request.head.ref != 'docs-update'
|
||||
runs-on: ubuntu-latest
|
||||
concurrency:
|
||||
group: label-pr-${{ github.event.pull_request.number }}
|
||||
cancel-in-progress: true
|
||||
permissions:
|
||||
pull-requests: write
|
||||
issues: write
|
||||
contents: read # Often needed for github-script
|
||||
steps:
|
||||
- name: Check PR body for Type of Change
|
||||
- name: Check PR Title for Type of Change
|
||||
uses: actions/github-script@v9
|
||||
with:
|
||||
script: |
|
||||
const prBody = context.payload.pull_request.body || '';
|
||||
const labelsToAdd = [];
|
||||
const { data: pr } = await github.rest.pulls.get({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
pull_number: context.payload.pull_request.number
|
||||
});
|
||||
const title = pr.title || '';
|
||||
const labelsByTag = {
|
||||
'feat': 'new feature',
|
||||
'fix': 'bug',
|
||||
'chore': 'chore',
|
||||
'docs': 'documentation',
|
||||
'ui-ux': 'ui update'
|
||||
};
|
||||
|
||||
if (/\[x\]\s*New feature/i.test(prBody)) {
|
||||
labelsToAdd.push('new feature');
|
||||
}
|
||||
if (/\[x\]\s*Bug fix/i.test(prBody)) {
|
||||
labelsToAdd.push('bug');
|
||||
}
|
||||
if (/\[x\]\s*Documentation update/i.test(prBody)) {
|
||||
labelsToAdd.push('documentation');
|
||||
}
|
||||
if (/\[x\]\s*Hotfix/i.test(prBody)) {
|
||||
labelsToAdd.push('hotfix');
|
||||
}
|
||||
if (/\[x\]\s*UI\/UX improvement/i.test(prBody)) {
|
||||
labelsToAdd.push('ui update');
|
||||
// Title format from the PR template: "tag(section): description" or "docs: description"
|
||||
const match = title.match(/^\s*(feat|fix|chore|docs|ui-ux)(?:\([^)]*\))?:/i);
|
||||
const typeLabel = match && labelsByTag[match[1].toLowerCase()];
|
||||
const managedLabels = Object.values(labelsByTag);
|
||||
|
||||
for (const label of pr.labels) {
|
||||
if (managedLabels.includes(label.name) && label.name !== typeLabel) {
|
||||
await github.rest.issues.removeLabel({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: pr.number,
|
||||
name: label.name
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (labelsToAdd.length > 0) {
|
||||
if (typeLabel && !pr.labels.some(label => label.name === typeLabel)) {
|
||||
await github.rest.issues.addLabels({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: pr.number,
|
||||
labels: [typeLabel]
|
||||
});
|
||||
}
|
||||
|
||||
const files = await github.paginate(github.rest.pulls.listFiles, {
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
pull_number: context.payload.pull_request.number,
|
||||
per_page: 100
|
||||
});
|
||||
const codePaths = ['functions/', 'scripts/', 'config/', 'xaml/'];
|
||||
const codeFiles = ['Compile.ps1', 'tools/autounattend.xml'];
|
||||
const hasCodeChanges = files.some(file =>
|
||||
[file.filename, file.previous_filename].some(path =>
|
||||
path && (codeFiles.includes(path) || codePaths.some(prefix => path.startsWith(prefix)))
|
||||
)
|
||||
);
|
||||
const hasSkipChangelog = pr.labels.some(
|
||||
label => label.name === 'skip-changelog'
|
||||
);
|
||||
|
||||
if (hasCodeChanges && hasSkipChangelog) {
|
||||
await github.rest.issues.removeLabel({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: context.payload.pull_request.number,
|
||||
name: 'skip-changelog'
|
||||
});
|
||||
} else if (!hasCodeChanges && !hasSkipChangelog) {
|
||||
await github.rest.issues.addLabels({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: context.payload.pull_request.number,
|
||||
labels: labelsToAdd
|
||||
labels: ['skip-changelog']
|
||||
});
|
||||
}
|
||||
@@ -25,7 +25,8 @@ jobs:
|
||||
121827219, // MyDrift-user
|
||||
17331812, // Callum
|
||||
101426328, // CodingWonders
|
||||
70659536 // og-mrk
|
||||
70659536, // og-mrk
|
||||
36518683 // ANGRYxScotsman
|
||||
];
|
||||
|
||||
if (context.payload.issue.pull_request) {
|
||||
|
||||
@@ -9,6 +9,8 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- name: Test discussion closing
|
||||
run: node --test .github/tests/close-discussion.test.cjs
|
||||
- name: Install PSScriptAnalyzer
|
||||
run: |
|
||||
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
|
||||
@@ -32,6 +34,9 @@ jobs:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v7
|
||||
|
||||
- name: Test PR labeling
|
||||
run: node --test .github/tests/label-pr.test.cjs
|
||||
|
||||
- name: Install Pester
|
||||
run: |
|
||||
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process
|
||||
|
||||
@@ -120,5 +120,6 @@ While you can make your changes directly through the Web, we recommend cloning t
|
||||
|
||||
### Making a PR
|
||||
* To make a PR on your repo under a new branch linking to the main branch, a button will show and say Preview and Create pull request. Click that button and fill in all the information that is provided on the template. Once all the information is filled in correctly, check your PR to make sure there is no WinUtil.ps1 file attached to the PR. Once everything is good, make the PR and wait for Chris (the maintainer) to accept or deny your PR. Once it is accepted by Chris, you will be able to see your changes in the "/windev" build.
|
||||
* Pay attention to comments that are present in template, some of them tell about proper presentation of your PR, which allows Github to properly label it
|
||||
* If you do not see your feature in the main "/win" build, that is fine. All new changes go into the /windev build to make sure everything is working OK before going fully public.
|
||||
* Congratulations! You just submitted your first PR. Thank you so much for contributing to WinUtil.
|
||||
Reference in new issue
Block a user