Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sl pr s problems with non-origin remote #916

Open
thcipriani opened this issue Jul 5, 2024 · 1 comment
Open

sl pr s problems with non-origin remote #916

thcipriani opened this issue Jul 5, 2024 · 1 comment

Comments

@thcipriani
Copy link

It suspect there is an assumption that path.default will always be origin and that origin will always exist.

I suspect this is the cause of two bugs:

  1. Confusing error output when github.com/github enterprise is a non-origin remote.
  2. Empty PRs for repos without origin remote.

Confusing errors for github.com as non-origin

Problem: If I add github.com as a non-origin remote, I get the error message abort: either None is not a GitHub (Enterprise) hostname or you are not logged in.

The None in this output is confusing.

Flags tried:

  • --verbose provides no more information.
  • --debug provides irrelevant information about watchman.
  • --traceback showed me the place in the code where I could use the SL_TEST_GH_URL environment variable to override the default behavior (which seems to be intended only for testing).

I suspected adding a remote would fail, but also expected error output would help me fix it.

$ git remote -vv
github  https://github.com/thcipriani/dumb-todo.git (fetch)
github  https://github.com/thcipriani/dumb-todo.git (push)
origin  [email protected]:thcipriani/dumb-todos.git (fetch)
origin  [email protected]:thcipriani/dumb-todos.git (push)
$ git branch --set-upstream-to=github/main
branch 'main' set up to track 'github/main'.
$ echo 'Hello world' > README
$ sl add README 
$ sl commit -m 'Update README'
$ sl
  @  b468cd27e  5 seconds ago  tyler
╭─╯  Update README
│
o  dd9d12001  Sunday at 16:23  tyler  origin/main
│  Add LICENSE
~
$ sl pr s
abort: either None is not a GitHub (Enterprise) hostname or you are not logged in.
Authenticate using the GitHub CLI: `gh auth login --git-protocol https --hostname None`
$ sl path
default = /tmp/dumb-todo/[email protected]:thcipriani/dumb-todos.git
github = https://github.com/thcipriani/dumb-todo.git

I'm unsure where hostname None is coming from, other than somewhere in python.

Suggestions

  • Show the path.default instead of None -- that gives me more information.
  • Bonus: If hostname is None, show path.default is not GitHub, abort, and add a pointer to sl help path/sl help urls
  • Possible feature: It may be helpful to specify the path for commands which use the path (i.e. sl pr submit github analogous to git push <refspec>).

Empty PRs for repos without origin

Problem: sl pr s creates an empty pull request after sl add and sl commit.

I suspect this is due to not having a origin remote for this repository. I found this while fiddling with the above problem.

$ git init
Initialized empty Git repository in /tmp/dumb-todos/.git/
$ git remote add github  https://github.com/thcipriani/dumb-todo.git
$ git fetch github
remote: Enumerating objects: 27, done.
remote: Counting objects: 100% (27/27), done.
remote: Compressing objects: 100% (15/15), done.
remote: Total 27 (delta 8), reused 24 (delta 7), pack-reused 0
Unpacking objects: 100% (27/27), 17.16 KiB | 428.00 KiB/s, done.
From https://github.com/thcipriani/dumb-todo
 * [new branch]      main                          -> github/main
$ git checkout main
branch 'main' set up to track 'github/main'.
Already on 'main'
$ ls
app.py  LICENSE  requirements.txt  static  templates
$ echo 'Hello world' > README
$ sl add README
$ sl commit -m 'Update README'
$ sl pr s
abort: could not read paths.default
$ sl path --add default https://github.com/thcipriani/dumb-todo.git
$ sl path
default = https://github.com/thcipriani/dumb-todo.git
github = https://github.com/thcipriani/dumb-todo.git
$ sl pr s
pushing 3 to https://github.com/thcipriani/dumb-todo.git
abort: error creating pull request for <sha1>: {
 "message": "Validation Failed",
 "errors": [
  {
   "resource": "PullRequest",
   "code": "custom",
   "message": "No commits between main and pr4"
  }
 ],
 "documentation_url": "https://docs.github.com/rest/pulls/pulls#create-a-pull-request",
 "status": "422"
}
$ git diff github/main..HEAD
diff --git a/README b/README
new file mode 100644
index 0000000..802992c
--- /dev/null
+++ b/README
@@ -0,0 +1 @@
+Hello world
@arduano
Copy link

arduano commented Aug 23, 2024

I just got the same issue, I think the culprit is your default = /tmp/dumb-todo/[email protected]:thcipriani/dumb-todos.git.

Try running sl path --add default [email protected]:thcipriani/dumb-todos.git, fixed it for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants