Commit graph

922 commits

Author SHA1 Message Date
Paul Gauthier
6dececea84 tweaked layout 2023-05-19 09:04:01 -07:00
Paul Gauthier
73fadbf2f8 wip: Added import statement for get_tags_map function from aider.ctags module. 2023-05-19 08:58:20 -07:00
Paul Gauthier
d4845dfb43 wip: Changed the prompt messages and added a function to show messages. 2023-05-19 08:57:56 -07:00
Paul Gauthier
e4d38f89bb return string 2023-05-19 08:51:49 -07:00
Paul Gauthier
f8d8a3528b include files with no tags 2023-05-19 08:47:17 -07:00
Paul Gauthier
dfd2c495ea move import 2023-05-19 08:42:28 -07:00
Paul Gauthier
f5c6667de3 aider: Modified get_tags to run ctags command and capture JSON output.
# Context:
USER: in get_tags, run `ctags --fields=+S --output-format=json $f` on the filename and collect the json output instead of reading json from filename. use that json data for the rest of the func
ASSISTANT: To modify the `get_tags` function in `aider/ctags.py` to run `ctags --fields=+S --output-format=json $f` on the filename and collect the JSON output, we will need to use the `subprocess` module to run the command and capture the output. Here are the changes:

```python
aider/ctags.py
<<<<<<< ORIGINAL
def get_tags(filename):
    with open(filename, "r") as tags_file:
        for line in tags_file:
            tag = json.loads(line)
=======
import subprocess

def get_tags(filename):
    cmd = ["ctags", "--fields=+S", "--output-format=json", filename]
    output = subprocess.check_output(cmd).decode("utf-8")
    for line in output.splitlines():
        tag = json.loads(line)
>>>>>>> UPDATED
```

This change imports the `subprocess` module, replaces the `with open(filename, "r")` block with a `subprocess.check_output` call to run the `ctags` command, and iterates over the output lines instead of the file lines.
2023-05-19 08:42:09 -07:00
Paul Gauthier
efe05b6d8a path 2023-05-19 08:39:04 -07:00
Paul Gauthier
06a33bc1b1 aider: Added path_components variable to store the split path.
# Context:
USER: after relpath, split path into a list of its components
ASSISTANT: ```python
aider/ctags.py
<<<<<<< ORIGINAL
            path = os.path.relpath(path, os.getcwd())
=======
            path = os.path.relpath(path, os.getcwd())
            path_components = path.split(os.sep)
>>>>>>> UPDATED
```
2023-05-19 08:31:26 -07:00
Paul Gauthier
cceb7c3bef Refactor ctags.py to print tags with indentation. 2023-05-19 08:31:00 -07:00
Paul Gauthier
7d45b918fc cleanup 2023-05-19 07:14:45 -07:00
Paul Gauthier
95221d58c9 closer 2023-05-19 07:00:12 -07:00
Paul Gauthier
a61d29a552 Added new files to the git repo: desired.txt, current.txt 2023-05-19 06:45:27 -07:00
Paul Gauthier
36bbf879b5 tabbed for brevity 2023-05-19 06:38:19 -07:00
Paul Gauthier
cf63fd31d5 no n/a 2023-05-19 06:24:49 -07:00
Paul Gauthier
4bb0dc72cd aider: Modified ctags.py to accept command line arguments and call print_tags_info on each file provided.
# Context:
USER: take filenames from the cmd line, call print_tags_info on each
ASSISTANT: To achieve this, we will modify the `aider/ctags.py` file to accept command line arguments and call `print_tags_info` on each file provided.

1. Import the `sys` module to access command line arguments.
2. Modify the `print_tags_info` function to accept a filename parameter.
3. Update the `with open` statement to use the provided filename.
4. Update the `if __name__ == "__main__":` block to iterate over command line arguments and call `print_tags_info` for each file.

Here are the changes:

```python
aider/ctags.py
<<<<<<< ORIGINAL
import json

def print_tags_info():
    with open("tags.jsonl", "r") as tags_file:
=======
import json
import sys

def print_tags_info(filename):
    with open(filename, "r") as tags_file:
>>>>>>> UPDATED
```

```python
aider/ctags.py
<<<<<<< ORIGINAL
if __name__ == "__main__":
    print_tags_info()
=======
if __name__ == "__main__":
    for filename in sys.argv[1:]:
        print_tags_info(filename)
>>>>>>> UPDATED
```
2023-05-18 18:30:40 -07:00
Paul Gauthier
6e68120acb wip: Changed print statement to remove f-string. 2023-05-18 18:29:37 -07:00
Paul Gauthier
1b3a4084be aider: Added function to load and iterate through tags file and print desired fields.
# Context:
USER: load the tags file and iterate through the records, print scope,kind,name,signature
ASSISTANT: To load the tags file and iterate through the records, you can use the following code:

1. Import the `json` module.
2. Open the `tags.jsonl` file.
3. Iterate through the lines in the file, loading each JSON object.
4. Print the desired fields: scope, kind, name, and signature.

Here's the code:

```python
import json

with open("tags.jsonl", "
^C KeyboardInterrupt
USER: put it in ctags.py
ASSISTANT: Here's the updated `aider/ctags.py` file with the code to load the tags file and iterate through the records, printing scope, kind, name, and signature:

```python
aider/ctags.py
<<<<<<< ORIGINAL
=======
import json

def print_tags_info():
    with open("tags.jsonl", "r") as tags_file:
        for line in tags_file:
            tag = json.loads(line)
            scope = tag.get("scope", "N/A")
            kind = tag.get("kind", "N/A")
            name = tag.get("name", "N/A")
            signature = tag.get("signature", "N/A")
            print(f"Scope: {scope}, Kind: {kind}, Name: {name}, Signature: {signature}")

if __name__ == "__main__":
    print_tags_info()
>>>>>>> UPDATED
```

This code defines a function `print_tags_info()` that reads the `tags.jsonl` file, iterates through the records, and prints the desired fields. The `if __name__ == "__main__":` block allows the script to be run directly.
2023-05-18 18:28:21 -07:00
Paul Gauthier
5e010422e2 Added new files to the git repo: tags.jsonl, aider/ctags.py 2023-05-18 18:26:24 -07:00
Paul Gauthier
ba9307374e cleanup Coder params 2023-05-18 18:21:44 -07:00
Paul Gauthier
a59575fa4b wip: Removed unused import from test_commands.py. 2023-05-18 18:17:38 -07:00
Paul Gauthier
78af36ffda cleanup 2023-05-18 18:17:02 -07:00
Paul Gauthier
7fc02ccd66 wip 2023-05-18 18:15:41 -07:00
Paul Gauthier
b2846fa73a aider: Created and added foo.txt to git. 2023-05-18 18:13:07 -07:00
Paul Gauthier
ad865fe0f4 removed yes 2023-05-18 18:12:27 -07:00
Paul Gauthier
59c3fef150 aider: Updated test_cmd_add method in tests/test_commands.py to pass yes=True when creating a Coder instance.
# Context:
USER: call Coder with yes=True
ASSISTANT: I will update the `test_cmd_add` method in the `tests/test_commands.py` file to pass `yes=True` when creating a `Coder` instance.

```python
tests/test_commands.py
<<<<<<< ORIGINAL
            coder = Coder(main_model="gpt-3.5-turbo", fnames=[], pretty=False, show_diffs=False, auto_commits=False, io=io, dry_run=False)
=======
            coder = Coder(main_model="gpt-3.5-turbo", fnames=[], pretty=False, show_diffs=False, auto_commits=False, io=io, dry_run=False, yes=True)
>>>>>>> UPDATED
```
2023-05-18 18:10:30 -07:00
Paul Gauthier
7e6c6b3b92 initialize cur_ and done_messages 2023-05-18 18:09:37 -07:00
Paul Gauthier
97a5e696d8 aider: Created and added bar.txt to git. 2023-05-18 18:07:30 -07:00
Paul Gauthier
240bdf03df aider: Fixed call to Coder class in tests/test_commands.py.
# Context:
USER: I ran this command:

 pytest tests/test_commands.py

Which produced this output:

============================= test session starts ==============================
platform darwin -- Python 3.11.3, pytest-7.3.1, pluggy-1.0.0
rootdir: /Users/gauthier/Projects/aider
collected 1 item

tests/test_commands.py F                                                 [100%]

=================================== FAILURES ===================================
__________________________ TestCommands.test_cmd_add ___________________________

self = <tests.test_commands.TestCommands testMethod=test_cmd_add>

    def test_cmd_add(self):
        with tempfile.TemporaryDirectory() as tmpdir:
            io = IO(pretty=False, yes=True)
>           coder = Coder(root=tmpdir)
E           TypeError: Coder.__init__() got an unexpected keyword argument 'root'

tests/test_commands.py:13: TypeError
=========================== short test summary info ============================
FAILED tests/test_commands.py::TestCommands::test_cmd_add - TypeError: Coder....
============================== 1 failed in 0.52s ===============================

ASSISTANT: It seems like the `Coder` class in `aider/coder.py` does not accept a `root` keyword argument in its `__init__` method. To fix this issue, we need to modify the `__init__` method of the `Coder` class to accept the `root` keyword argument and set it as an instance variable
^C KeyboardInterrupt
USER: no, fix the call
ASSISTANT: To fix the call to the `Coder` class in `tests/test_commands.py`, we need to remove the `root` keyword argument and pass the required arguments according to the `__init__` method of the `Coder` class.

Here's the change you need to make in `tests/test_commands.py`:

```python
tests/test_commands.py
<<<<<<< ORIGINAL
            coder = Coder(root=tmpdir)
=======
            coder = Coder(main_model="gpt-3.5-turbo", fnames=[], pretty=False, show_diffs=False, auto_commits=False, io=io, dry_run=False)
>>>>>>> UPDATED
```

This change removes the `root` keyword argument and provides the required arguments for the `Coder` class.
2023-05-18 18:07:21 -07:00
Paul Gauthier
01778be259 fixed indent 2023-05-18 17:33:11 -07:00
Paul Gauthier
1814638c1a aider: Fixed indentation error in aider/io.py.
# Context:
USER: I ran this command:

 pytest tests/test_commands.py

Which produced this output:

============================= test session starts ==============================
platform darwin -- Python 3.11.3, pytest-7.3.1, pluggy-1.0.0
rootdir: /Users/gauthier/Projects/aider
collected 0 items / 1 error

==================================== ERRORS ====================================
___________________ ERROR collecting tests/test_commands.py ____________________
.venv/lib/python3.11/site-packages/_pytest/python.py:617: in _importtestmodule
    mod = import_path(self.path, mode=importmode, root=self.config.rootpath)
.venv/lib/python3.11/site-packages/_pytest/pathlib.py:564: in import_path
    importlib.import_module(module_name)
/usr/local/Cellar/python@3.11/3.11.3/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
<frozen importlib._bootstrap>:1206: in _gcd_import
    ???
<frozen importlib._bootstrap>:1178: in _find_and_load
    ???
<frozen importlib._bootstrap>:1149: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:690: in _load_unlocked
    ???
.venv/lib/python3.11/site-packages/_pytest/assertion/rewrite.py:172: in exec_module
    exec(co, module.__dict__)
tests/test_commands.py:6: in <module>
    from aider.io import InputOutput as IO
E     File "/Users/gauthier/Projects/aider/aider/io.py", line 117
E       line = session.prompt()
E   IndentationError: unexpected indent
=========================== short test summary info ============================
ERROR tests/test_commands.py
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
=============================== 1 error in 0.32s ===============================

ASSISTANT: It seems there is an indentation error in the `aider/io.py` file. Please provide the content of the `aider/io.py` file so I can identify the issue and suggest a fix.
USER: Please note that I shared content of these additional files: aider/io.py
ASSISTANT: Apologies for the oversight. I see the indentation error in the `aider/io.py` file. Here's the fix:

```python
aider/io.py
<<<<<<< ORIGINAL
        session_kwargs = {
            "message": show,
            "completer": completer_instance,
            "style": style,
            "reserve_space_for_menu": 4,
            "complete_style": CompleteStyle.MULTI_COLUMN,
            "input": self.input,
            "output": self.output,
        }
        if self.input_history_file is not None:
            session_kwargs["history"] = FileHistory(self.input_history_file)
        session = PromptSession(**session_kwargs)
            line = session.prompt()
=======
        session_kwargs = {
            "message": show,
            "completer": completer_instance,
            "style": style,
            "reserve_space_for_menu": 4,
            "complete_style": CompleteStyle.MULTI_COLUMN,
            "input": self.input,
            "output": self.output,
        }
        if self.input_history_file is not None:
            session_kwargs["history"] = FileHistory(self.input_history_file)
        session = PromptSession(**session_kwargs)
        line = session.prompt()
>>>>>>> UPDATED
```

This should fix the indentation error. Please apply the change and run the tests again.
2023-05-18 17:32:33 -07:00
Paul Gauthier
b0f573bde3 Refactor IO instantiation in test_commands.py. 2023-05-18 17:31:00 -07:00
Paul Gauthier
aa8ead2f2e aider: Made the two history files optional.
# Context:
USER: make the two history files optional
ASSISTANT: To make the two history files optional, we will modify the `__init__` method of the `InputOutput` class in the `aider/io.py` file. We will set the default values of `input_history_file` and `chat_history_file` to `None`. Then, we will add conditions to check if these variables are not `None` before using them.

```python
aider/io.py
<<<<<<< ORIGINAL
    def __init__(self, pretty, yes, input_history_file, chat_history_file, input=None, output=None):
=======
    def __init__(self, pretty, yes, input_history_file=None, chat_history_file=None, input=None, output=None):
>>>>>>> UPDATED
```

```python
aider/io.py
<<<<<<< ORIGINAL
        session = PromptSession(
            message=show,
            completer=completer_instance,
            history=FileHistory(self.input_history_file),
            style=style,
            reserve_space_for_menu=4,
            complete_style=CompleteStyle.MULTI_COLUMN,
            input=self.input,
            output=self.output,
        )
=======
        session_kwargs = {
            "message": show,
            "completer": completer_instance,
            "style": style,
            "reserve_space_for_menu": 4,
            "complete_style": CompleteStyle.MULTI_COLUMN,
            "input": self.input,
            "output": self.output,
        }
        if self.input_history_file is not None:
            session_kwargs["history"] = FileHistory(self.input_history_file)
        session = PromptSession(**session_kwargs)
>>>>>>> UPDATED
```

```python
aider/io.py
<<<<<<< ORIGINAL
        self.chat_history_file = Path(chat_history_file)
=======
        if chat_history_file is not None:
            self.chat_history_file = Path(chat_history_file)
        else:
            self.chat_history_file = None
>>>>>>> UPDATED
```

```python
aider/io.py
<<<<<<< ORIGINAL
        with self.chat_history_file.open("a") as f:
            f.write(text)
=======
        if self.chat_history_file is not None:
            with self.chat_history_file.open("a") as f:
                f.write(text)
>>>>>>> UPDATED
```

These changes will make the history files optional.
2023-05-18 17:30:34 -07:00
Paul Gauthier
a33c1d3478 aider: Fixed TypeError when initializing IO class in test_cmd_add.
# Context:
USER: I ran this command:

 pytest tests/test_commands.py

Which produced this output:

============================= test session starts ==============================
platform darwin -- Python 3.11.3, pytest-7.3.1, pluggy-1.0.0
rootdir: /Users/gauthier/Projects/aider
collected 1 item

tests/test_commands.py F                                                 [100%]

=================================== FAILURES ===================================
__________________________ TestCommands.test_cmd_add ___________________________

self = <tests.test_commands.TestCommands testMethod=test_cmd_add>

    def test_cmd_add(self):
        with tempfile.TemporaryDirectory() as tmpdir:
>           io = IO(pretty=False, yes=True, input_history_file=None, chat_history_file=None)

tests/test_commands.py:12:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
aider/io.py:60: in __init__
    self.chat_history_file = Path(chat_history_file)
/usr/local/Cellar/python@3.11/3.11.3/Frameworks/Python.framework/Versions/3.11/lib/python3.11/pathlib.py:871: in __new__
    self = cls._from_parts(args)
/usr/local/Cellar/python@3.11/3.11.3/Frameworks/Python.framework/Versions/3.11/lib/python3.11/pathlib.py:509: in _from_parts
    drv, root, parts = self._parse_args(args)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

cls = <class 'pathlib.PosixPath'>, args = (None,)

    @classmethod
    def _parse_args(cls, args):
        # This is useful when you don't want to create an instance, just
        # canonicalize some constructor arguments.
        parts = []
        for a in args:
            if isinstance(a, PurePath):
                parts += a._parts
            else:
>               a = os.fspath(a)
E               TypeError: expected str, bytes or os.PathLike object, not NoneType

/usr/local/Cellar/python@3.11/3.11.3/Frameworks/Python.framework/Versions/3.11/lib/python3.11/pathlib.py:493: TypeError
=========================== short test summary info ============================
FAILED tests/test_commands.py::TestCommands::test_cmd_add - TypeError: expect...
============================== 1 failed in 0.53s ===============================

ASSISTANT: I apologize for the oversight. The `Path` class from `pathlib` does not accept `None` as an argument. We can use an empty string instead of `None` for `input_history_file` and `chat_history_file` when initializing the `IO` class in the test.

```python
tests/test_commands.py
<<<<<<< ORIGINAL
io = IO(pretty=False, yes=True, input_history_file=None, chat_history_file=None)
=======
io = IO(pretty=False, yes=True, input_history_file="", chat_history_file="")
>>>>>>> UPDATED
```

This change should fix the `TypeError` when initializing the `IO` class in the test.
2023-05-18 17:28:03 -07:00
Paul Gauthier
9d74924067 aider: Fixed IO class initialization in test_cmd_add.
# Context:
USER: I ran this command:

 pytest tests/test_commands.py

Which produced this output:

============================= test session starts ==============================
platform darwin -- Python 3.11.3, pytest-7.3.1, pluggy-1.0.0
rootdir: /Users/gauthier/Projects/aider
collected 1 item

tests/test_commands.py F                                                 [100%]

=================================== FAILURES ===================================
__________________________ TestCommands.test_cmd_add ___________________________

self = <tests.test_commands.TestCommands testMethod=test_cmd_add>

    def test_cmd_add(self):
        with tempfile.TemporaryDirectory() as tmpdir:
>           io = IO()
E           TypeError: InputOutput.__init__() missing 4 required positional arguments: 'pretty', 'yes', 'input_history_file', and 'chat_history_file'

tests/test_commands.py:12: TypeError
=========================== short test summary info ============================
FAILED tests/test_commands.py::TestCommands::test_cmd_add - TypeError: InputO...
============================== 1 failed in 0.47s ===============================

ASSISTANT: I apologize for the oversight. The `InputOutput` class requires four arguments during initialization. Let's update the test to provide the required arguments.

```python
tests/test_commands.py
<<<<<<< ORIGINAL
io = IO()
=======
io = IO(pretty=False, yes=True, input_history_file=None, chat_history_file=None)
>>>>>>> UPDATED
```

This change should fix the `TypeError` when initializing the `IO` class in the test.
2023-05-18 17:27:19 -07:00
Paul Gauthier
68d8306c78 aider: Updated import statement for IO class in tests/test_commands.py to use InputOutput instead, fixing ImportError.
# Context:
USER: I ran this command:

 pytest tests/test_commands.py

Which produced this output:

============================= test session starts ==============================
platform darwin -- Python 3.11.3, pytest-7.3.1, pluggy-1.0.0
rootdir: /Users/gauthier/Projects/aider
collected 0 items / 1 error

==================================== ERRORS ====================================
___________________ ERROR collecting tests/test_commands.py ____________________
ImportError while importing test module '/Users/gauthier/Projects/aider/tests/test_commands.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/local/Cellar/python@3.11/3.11.3/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/test_commands.py:6: in <module>
    from aider.io import IO
E   ImportError: cannot import name 'IO' from 'aider.io' (/Users/gauthier/Projects/aider/aider/io.py)
=========================== short test summary info ============================
ERROR tests/test_commands.py
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
=============================== 1 error in 0.33s ===============================

ASSISTANT: It seems like there is an issue with importing the `IO` class from `aider.io`. Please provide the content of the `aider/io.py` file so I can help you resolve the issue.
USER: Please note that I shared content of these additional files: aider/io.py
ASSISTANT: Apologies for the oversight. I see the issue now. The class name in `aider/io.py` is `InputOutput`, not `IO`. Let's update the import statement in the `tests/test_commands.py` file.

```python
tests/test_commands.py
<<<<<<< ORIGINAL
from aider.io import IO
=======
from aider.io import InputOutput as IO
>>>>>>> UPDATED
```

This change should fix the ImportError when running the tests.
2023-05-18 17:26:46 -07:00
Paul Gauthier
65c708b0c4 aider: Added a test function for cmd_add that tests the method with 'foo.txt' and 'bar.txt' as input, runs the test in a temporary directory, and ensures that both files have been created after the test.
# Context:
USER: add a test for cmd_add that passes in 'foo.txt' and 'bar.txt' and ensures they have both been created after the test. run the test in a tmp dir.
ASSISTANT: To add the test for `cmd_add`, we need to modify the `tests/test_commands.py` file. Please provide the content of the `tests/test_commands.py` file so I can suggest the necessary changes.
USER: it's empty
ASSISTANT: In that case, I will create a new test function for `cmd_add` in the `tests/test_commands.py` file. Here's the suggested change:

```python
tests/test_commands.py
<<<<<<< ORIGINAL
=======
import os
import tempfile
import unittest
from unittest.mock import MagicMock
from aider.commands import Commands
from aider.io import IO
from aider.coder import Coder

class TestCommands(unittest.TestCase):
    def test_cmd_add(self):
        with tempfile.TemporaryDirectory() as tmpdir:
            io = IO()
            coder = Coder(root=tmpdir)
            commands = Commands(io, coder)

            # Mock the Confirm.ask method to return True for creating files
            with unittest.mock.patch("rich.prompt.Confirm.ask", return_value=True):
                commands.cmd_add("foo.txt bar.txt")

            foo_path = os.path.join(tmpdir, "foo.txt")
            bar_path = os.path.join(tmpdir, "bar.txt")

            self.assertTrue(os.path.exists(foo_path), "foo.txt should be created")
            self.assertTrue(os.path.exists(bar_path), "bar.txt should be created")

if __name__ == "__main__":
    unittest.main()
>>>>>>> UPDATED
```

This will create a new test function `test_cmd_add` in the `tests/test_commands.py` file that tests the `cmd_add` method with 'foo.txt' and 'bar.txt' as input. The test will run in a temporary directory and ensure that both files have been created after the test.
2023-05-18 17:25:48 -07:00
Paul Gauthier
fa5799f06a Added new files to the git repo: tests/test_commands.py 2023-05-18 17:23:08 -07:00
Paul Gauthier
f94db8c43f copy 2023-05-18 17:18:07 -07:00
Paul Gauthier
8ecdfbd459 copy 2023-05-18 17:17:08 -07:00
Paul Gauthier
4bb37c902a Merge remote-tracking branch 'origin/main' 2023-05-18 17:13:55 -07:00
Paul Gauthier
bfed1a7295 Updated screenshot 2023-05-18 17:13:24 -07:00
Paul Gauthier
e8b041af96 aider: Added check to ensure remote head is only fetched when there is a remote origin.
# Context:
USER: the /undo command is throwing this error when the repo has no remote origin: Error: Unable to get the remote 'origin/scratch'.
ASSISTANT: I see the issue. The code is trying to get the remote head even when there is no remote origin. I will add a check to ensure that the remote head is only fetched when there is a remote origin. Here's the change:

```python
aider/commands.py
<<<<<<< ORIGINAL
        if has_origin:
            current_branch = self.coder.repo.active_branch.name
            try:
                remote_head = self.coder.repo.git.rev_parse(f"origin/{current_branch}")
            except git.exc.GitCommandError:
                self.io.tool_error(f"Error: Unable to get the remote 'origin/{current_branch}'.")
                return
            if local_head == remote_head:
                self.io.tool_error(
                    "The last commit has already been pushed to the origin. Undoing is not"
                    " possible."
                )
                return
=======
        if has_origin:
            current_branch = self.coder.repo.active_branch.name
            try:
                remote_head = self.coder.repo.git.rev_parse(f"origin/{current_branch}")
                if local_head == remote_head:
                    self.io.tool_error(
                        "The last commit has already been pushed to the origin. Undoing is not"
                        " possible."
                    )
                    return
            except git.exc.GitCommandError
^C KeyboardInterrupt
USER: no, has_origin needs to check if the *current branch* has an origin.
ASSISTANT: I understand now. I will modify the `has_origin` check to verify if the current branch has an origin. Here's the updated change:

```python
aider/commands.py
<<<<<<< ORIGINAL
        has_origin = any(remote.name == "origin" for remote in self.coder.repo.remotes)

        if has_origin:
            current_branch = self.coder.repo.active_branch.name
            try:
                remote_head = self.coder.repo.git.rev_parse(f"origin/{current_branch}")
            except git.exc.GitCommandError:
                self.io.tool_error(f"Error: Unable to get the remote 'origin/{current_branch}'.")
                return
            if local_head == remote_head:
                self.io.tool_error(
                    "The last commit has already been pushed to the origin. Undoing is not"
                    " possible."
                )
                return
=======
        current_branch = self.coder.repo.active_branch.name
        try:
            remote_head = self.coder.repo.git.rev_parse(f"origin/{current_branch}")
            has_origin = True
        except git.exc.GitCommandError:
            has_origin = False

        if has_origin:
            if local_head == remote_head:
                self.io.tool_error(
                    "The last commit has already been pushed to the origin. Undoing is not"
                    " possible."
                )
                return
>>>>>>> UPDATED
```

This change will set `has_origin` to `True` only if the current branch has an origin, and it will handle the error accordingly.
2023-05-18 14:25:23 -07:00
paul-gauthier
576437dd20
Merge pull request #3 from mobyvb/update-readme
Add instructions for installing from source to README
2023-05-18 13:58:16 -07:00
Moby von Briesen
c8158d96ee README: add instructions for installing from source 2023-05-18 15:50:57 -04:00
Paul Gauthier
c9e35ebf83 moved Using git repo print to proper location 2023-05-18 12:26:26 -07:00
Paul Gauthier
4244eefb4a aider: Changed set_repo function to print git repo name relative to cwd.
# Context:
USER: when printing the git repo name, print it relative to cwd
ASSISTANT: To print the git repo name relative to the current working directory, you can modify the `set_repo` function in the `aider/coder.py` file. Here's the change:

```python
aider/coder.py
<<<<<<< ORIGINAL
        if num_repos == 0:
            self.io.tool_error("Files are not in a git repo.")
            return
        if num_repos > 1:
            self.io.tool_error("Files are in different git repos.")
            return

        # https://github.com/gitpython-developers/GitPython/issues/427
        repo = git.Repo(repo_paths.pop(), odbt=git.GitDB)

        self.root = repo.working_tree_dir

        self.io.tool("Using git repo:", self.repo.git_dir)
=======
        if num_repos == 0:
            self.io.tool_error("Files are not in a git repo.")
            return
        if num_repos > 1:
            self.io.tool_error("Files are in different git repos.")
            return

        # https://github.com/gitpython-developers/GitPython/issues/427
        repo = git.Repo(repo_paths.pop(), odbt=git.GitDB)

        self.root = repo.working_tree_dir

        rel_repo_dir = os.path.relpath(self.repo.git_dir, os.getcwd())
        self.io.tool("Using git repo:", rel_repo_dir)
>>>>>>> UPDATED
```

This change replaces `self.repo.git_dir` with `os.path.relpath(self.repo.git_dir, os.getcwd())` to display the git repo path relative to the current working directory.
2023-05-18 12:11:29 -07:00
Paul Gauthier
f28fc5b2b1 Changed command description for cmd_run. 2023-05-18 10:15:18 -07:00
Paul Gauthier
a525a1b543 Ask to add /run output to the chat 2023-05-18 10:13:50 -07:00
Paul Gauthier
0ade98dfff removed line numbers 2023-05-18 10:07:56 -07:00