Skip to content

Commit

Permalink
Merge feature/ignore-file-download
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunwood-ai-labs committed Feb 2, 2025
2 parents f2853ba + 838bee5 commit 0bb64b5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .SourceSageignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ output.md
test_output/
.SourceSageAssets/
.SourceSageAssetsDemo/
**/.SourceSageAssets/
sourcesage/config/
tests

# アセット
*.png
Expand Down
23 changes: 23 additions & 0 deletions sourcesage/modules/DocuSum/docusum.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from pathlib import Path
from loguru import logger
from art import *
import requests

try:
from .file_pattern_matcher import FilePatternMatcher
Expand Down Expand Up @@ -41,6 +42,9 @@ def __init__(self, folders=None, ignore_file='.SourceSageignore', language_map_f
self.ignore_file = ignore_file
self.output_file = output_file
self.git_path = git_path if git_path else os.path.join(self.folders[0], '.git')

# .SourceSageIgnoreファイルの初期化
self._init_ignore_file()

# language_map_fileが指定されていない場合、モジュールのディレクトリ内のファイルを使用
if not os.path.exists(language_map_file):
Expand Down Expand Up @@ -117,6 +121,25 @@ def generate_markdown(self):
logger.error(f"マークダウン生成エラー: {e}")
raise

def _init_ignore_file(self):
"""
.SourceSageIgnoreファイルの初期化を行う。
ファイルが存在しない場合、GitHubからデフォルトの設定をダウンロードして作成する。
"""
if not os.path.exists(self.ignore_file):
try:
url = "https://raw.githubusercontent.com/Sunwood-ai-labs/SourceSage/refs/heads/main/sourcesage/config/.SourceSageignore"
response = requests.get(url)
response.raise_for_status() # エラーチェック

with open(self.ignore_file, 'w', encoding='utf-8') as f:
f.write(response.text)

logger.success(f"{self.ignore_file}を作成しました")
except Exception as e:
logger.error(f"{self.ignore_file}の作成に失敗しました: {e}")
raise

def analyze_repository(self):
"""リポジトリの分析結果を生成する"""
analysis_results = []
Expand Down

0 comments on commit 0bb64b5

Please sign in to comment.