auto-coder-web 0.1.83__py3-none-any.whl → 0.1.85__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- auto_coder_web/init_project.py +1 -3
- auto_coder_web/routers/commit_router.py +70 -37
- auto_coder_web/version.py +1 -1
- auto_coder_web/web/assets/main-RHMBGd__.css +32 -0
- auto_coder_web/web/assets/main.js +337 -322
- auto_coder_web/web/index.html +1 -1
- {auto_coder_web-0.1.83.dist-info → auto_coder_web-0.1.85.dist-info}/METADATA +2 -2
- {auto_coder_web-0.1.83.dist-info → auto_coder_web-0.1.85.dist-info}/RECORD +11 -11
- auto_coder_web/web/assets/main-B3_hzhoO.css +0 -32
- {auto_coder_web-0.1.83.dist-info → auto_coder_web-0.1.85.dist-info}/WHEEL +0 -0
- {auto_coder_web-0.1.83.dist-info → auto_coder_web-0.1.85.dist-info}/entry_points.txt +0 -0
- {auto_coder_web-0.1.83.dist-info → auto_coder_web-0.1.85.dist-info}/top_level.txt +0 -0
    
        auto_coder_web/init_project.py
    CHANGED
    
    | @@ -23,9 +23,7 @@ def init_project(project_path: str): | |
| 23 23 |  | 
| 24 24 | 
             
                # 生成 .autocoderignore 文件,采用 .gitignore 格式
         | 
| 25 25 | 
             
                autocoderignore_path = os.path.join(source_dir, ".autocoderignore")
         | 
| 26 | 
            -
                autocoderignore_content =  | 
| 27 | 
            -
                    "target\n"        
         | 
| 28 | 
            -
                )
         | 
| 26 | 
            +
                autocoderignore_content = "target\n"            
         | 
| 29 27 | 
             
                with open(autocoderignore_path, "w", encoding="utf-8") as f:
         | 
| 30 28 | 
             
                    f.write(autocoderignore_content)    
         | 
| 31 29 |  | 
| @@ -328,7 +328,8 @@ async def get_file_diff( | |
| 328 328 | 
             
                            return {
         | 
| 329 329 | 
             
                                "before_content": "",  # 初始提交前没有内容
         | 
| 330 330 | 
             
                                "after_content": file_content,
         | 
| 331 | 
            -
                                "diff_content": repo.git.show(f"{commit.hexsha} -- {file_path}")
         | 
| 331 | 
            +
                                "diff_content": repo.git.show(f"{commit.hexsha} -- {file_path}"),
         | 
| 332 | 
            +
                                "file_status": "added"
         | 
| 332 333 | 
             
                            }
         | 
| 333 334 | 
             
                        else:
         | 
| 334 335 | 
             
                            raise HTTPException(status_code=404, detail=f"File {file_path} not found in commit {commit_hash}")
         | 
| @@ -336,51 +337,61 @@ async def get_file_diff( | |
| 336 337 | 
             
                    # 获取父提交
         | 
| 337 338 | 
             
                    parent = commit.parents[0]
         | 
| 338 339 |  | 
| 339 | 
            -
                    #  | 
| 340 | 
            -
                     | 
| 341 | 
            -
                     | 
| 342 | 
            -
             | 
| 343 | 
            -
             | 
| 344 | 
            -
                     | 
| 345 | 
            -
             | 
| 346 | 
            -
                    
         | 
| 347 | 
            -
                     | 
| 348 | 
            -
                     | 
| 349 | 
            -
                     | 
| 350 | 
            -
             | 
| 351 | 
            -
                         | 
| 352 | 
            -
             | 
| 353 | 
            -
             | 
| 354 | 
            -
             | 
| 355 | 
            -
             | 
| 356 | 
            -
             | 
| 357 | 
            -
             | 
| 358 | 
            -
             | 
| 359 | 
            -
             | 
| 360 | 
            -
             | 
| 361 | 
            -
             | 
| 362 | 
            -
             | 
| 363 | 
            -
             | 
| 364 | 
            -
             | 
| 365 | 
            -
             | 
| 366 | 
            -
             | 
| 340 | 
            +
                    # 获取提交的差异索引
         | 
| 341 | 
            +
                    diff_index = parent.diff(commit)
         | 
| 342 | 
            +
                    
         | 
| 343 | 
            +
                    # 初始化变量
         | 
| 344 | 
            +
                    before_content = ""
         | 
| 345 | 
            +
                    after_content = ""
         | 
| 346 | 
            +
                    diff_content = ""
         | 
| 347 | 
            +
                    file_status = "unknown"
         | 
| 348 | 
            +
                    found_file = False
         | 
| 349 | 
            +
                    
         | 
| 350 | 
            +
                    # 查找匹配的文件差异
         | 
| 351 | 
            +
                    for diff_item in diff_index:
         | 
| 352 | 
            +
                        # 检查文件路径是否匹配当前或重命名后的文件
         | 
| 353 | 
            +
                        if diff_item.a_path == file_path or diff_item.b_path == file_path:
         | 
| 354 | 
            +
                            found_file = True
         | 
| 355 | 
            +
                            # 根据diff_item确定文件状态
         | 
| 356 | 
            +
                            file_status = get_file_status_from_diff(diff_item)
         | 
| 357 | 
            +
                            
         | 
| 358 | 
            +
                            # 根据文件状态获取内容
         | 
| 359 | 
            +
                            if file_status == "added":
         | 
| 360 | 
            +
                                # 新增文件
         | 
| 361 | 
            +
                                after_content = repo.git.show(f"{commit.hexsha}:{file_path}")
         | 
| 362 | 
            +
                                diff_content = repo.git.diff(f"{parent.hexsha}..{commit.hexsha}", "--", file_path)
         | 
| 363 | 
            +
                            elif file_status == "deleted":
         | 
| 364 | 
            +
                                # 删除文件
         | 
| 365 | 
            +
                                before_content = repo.git.show(f"{parent.hexsha}:{file_path}")
         | 
| 366 | 
            +
                                diff_content = repo.git.diff(f"{parent.hexsha}..{commit.hexsha}", "--", file_path)
         | 
| 367 | 
            +
                            elif file_status == "renamed":
         | 
| 368 | 
            +
                                # 重命名文件
         | 
| 369 | 
            +
                                if diff_item.a_path == file_path:
         | 
| 370 | 
            +
                                    # 查询的是原文件名
         | 
| 367 371 | 
             
                                    before_content = repo.git.show(f"{parent.hexsha}:{diff_item.a_path}")
         | 
| 368 | 
            -
                                    diff_content = repo.git.diff(f"{parent.hexsha}..{commit.hexsha}", "--", diff_item.a_path, file_path)
         | 
| 369 | 
            -
                                    break
         | 
| 370 | 
            -
                                elif diff_item.a_path == file_path:  # 重命名前的路径匹配
         | 
| 371 372 | 
             
                                    after_content = repo.git.show(f"{commit.hexsha}:{diff_item.b_path}")
         | 
| 372 | 
            -
             | 
| 373 | 
            -
                                     | 
| 373 | 
            +
                                else:
         | 
| 374 | 
            +
                                    # 查询的是新文件名
         | 
| 375 | 
            +
                                    before_content = repo.git.show(f"{parent.hexsha}:{diff_item.a_path}")
         | 
| 376 | 
            +
                                    after_content = repo.git.show(f"{commit.hexsha}:{diff_item.b_path}")
         | 
| 377 | 
            +
                                diff_content = repo.git.diff(f"{parent.hexsha}..{commit.hexsha}", "--", diff_item.a_path, diff_item.b_path)
         | 
| 378 | 
            +
                            else:
         | 
| 379 | 
            +
                                # 修改文件
         | 
| 380 | 
            +
                                before_content = repo.git.show(f"{parent.hexsha}:{file_path}")
         | 
| 381 | 
            +
                                after_content = repo.git.show(f"{commit.hexsha}:{file_path}")
         | 
| 382 | 
            +
                                diff_content = repo.git.diff(f"{parent.hexsha}..{commit.hexsha}", "--", file_path)
         | 
| 383 | 
            +
                            
         | 
| 384 | 
            +
                            break
         | 
| 374 385 |  | 
| 375 | 
            -
                    #  | 
| 376 | 
            -
                    if not  | 
| 386 | 
            +
                    # 如果没有找到匹配的文件
         | 
| 387 | 
            +
                    if not found_file:
         | 
| 377 388 | 
             
                        raise HTTPException(status_code=404, detail=f"File {file_path} not found in commit {commit_hash} or its parent")
         | 
| 378 389 |  | 
| 379 390 | 
             
                    return {
         | 
| 380 391 | 
             
                        "before_content": before_content,
         | 
| 381 392 | 
             
                        "after_content": after_content,
         | 
| 382 393 | 
             
                        "diff_content": diff_content,
         | 
| 383 | 
            -
                        "file_status":  | 
| 394 | 
            +
                        "file_status": file_status
         | 
| 384 395 | 
             
                    }
         | 
| 385 396 |  | 
| 386 397 | 
             
                except HTTPException:
         | 
| @@ -393,6 +404,28 @@ async def get_file_diff( | |
| 393 404 | 
             
                    )
         | 
| 394 405 |  | 
| 395 406 |  | 
| 407 | 
            +
            def get_file_status_from_diff(diff_item) -> str:
         | 
| 408 | 
            +
                """
         | 
| 409 | 
            +
                根据Git diff对象确定文件变更类型
         | 
| 410 | 
            +
                
         | 
| 411 | 
            +
                Args:
         | 
| 412 | 
            +
                    diff_item: Git diff对象
         | 
| 413 | 
            +
                    
         | 
| 414 | 
            +
                Returns:
         | 
| 415 | 
            +
                    文件状态: added(新增), deleted(删除), renamed(重命名), copied(复制) 或 modified(修改)
         | 
| 416 | 
            +
                """
         | 
| 417 | 
            +
                if diff_item.new_file:
         | 
| 418 | 
            +
                    return "added"
         | 
| 419 | 
            +
                elif diff_item.deleted_file:
         | 
| 420 | 
            +
                    return "deleted"
         | 
| 421 | 
            +
                elif diff_item.renamed:
         | 
| 422 | 
            +
                    return "renamed"
         | 
| 423 | 
            +
                elif diff_item.copied:
         | 
| 424 | 
            +
                    return "copied"
         | 
| 425 | 
            +
                else:
         | 
| 426 | 
            +
                    return "modified"
         | 
| 427 | 
            +
             | 
| 428 | 
            +
             | 
| 396 429 | 
             
            @router.get("/api/current-changes")
         | 
| 397 430 | 
             
            async def get_current_changes(
         | 
| 398 431 | 
             
                limit: int = 3, 
         | 
    
        auto_coder_web/version.py
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            __version__ = "0.1. | 
| 1 | 
            +
            __version__ = "0.1.85"
         |