From 19cb11bee4008cbb8c87bb8a55f515c8077cc44c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 7 Nov 2025 14:44:24 +0000 Subject: [PATCH 1/3] Initial plan From 989cff0fa0dcc56737b5a9ca4b7df7fb528639c0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 7 Nov 2025 14:49:08 +0000 Subject: [PATCH 2/3] refactor: replace requests with urllib for make-gitignore.py Co-authored-by: cdfmlr <45259230+cdfmlr@users.noreply.github.com> --- make-gitignore.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/make-gitignore.py b/make-gitignore.py index 386d705..64a4545 100755 --- a/make-gitignore.py +++ b/make-gitignore.py @@ -5,7 +5,8 @@ """ from typing import List -import requests +import urllib.request +import urllib.error import argparse @@ -47,14 +48,15 @@ def raw_url(self): return self._url(RAW_URL) def fetch_content(self): - resp = requests.get(self.raw_url()) - if resp.status_code != 200: + try: + with urllib.request.urlopen(self.raw_url()) as resp: + return resp.read().decode('utf-8') + except urllib.error.HTTPError as e: # common error: not such {lang}.gitignore - if resp.status_code == 404: + if e.code == 404: raise ValueError( f'No gitignore template regarding "{self.lang}": {self.hub_url()} responses 404 not found') - raise ValueError(f"{resp.status_code=}") - return resp.content.decode('utf-8') + raise ValueError(f"HTTP Error {e.code}: {e.reason}") class GlobalGitignore(Gitignore): From eecd0bf2863852a875fbc4db2c922df1224042cc Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 7 Nov 2025 14:50:29 +0000 Subject: [PATCH 3/3] Add URLError handling for network-related issues Co-authored-by: cdfmlr <45259230+cdfmlr@users.noreply.github.com> --- make-gitignore.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/make-gitignore.py b/make-gitignore.py index 64a4545..fc979c2 100755 --- a/make-gitignore.py +++ b/make-gitignore.py @@ -57,6 +57,8 @@ def fetch_content(self): raise ValueError( f'No gitignore template regarding "{self.lang}": {self.hub_url()} responses 404 not found') raise ValueError(f"HTTP Error {e.code}: {e.reason}") + except urllib.error.URLError as e: + raise ValueError(f"Network error: {e.reason}") class GlobalGitignore(Gitignore):