Skip to content

Commit e88f8d6

Browse files
committed
Fix some issues with 'user'
1 parent f539c15 commit e88f8d6

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

pullman.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def _get_ghstack_message(ref: str) -> tuple[str, list[str]]:
159159
if not urls:
160160
raise PullError("not a ghstack pull request")
161161
if len(urls) > 1:
162-
raise PullError("Malformed ghstack pull requst")
162+
raise PullError(f"Malformed ghstack pull request {urls=}")
163163

164164
end = next((i for i, s in enumerate(lines) if s.startswith(_GHSTACK_SOURCE)), -1)
165165
lines = lines[:end]
@@ -193,7 +193,8 @@ def pulls(self) -> dict[str, list[PullRequest]]:
193193
for branch in _run("git branch -r"):
194194
pr = PullRequest(branch.strip())
195195
with suppress(PullError):
196-
result.setdefault(pr.user, []).append(pr)
196+
if pr.user == self.user:
197+
result.setdefault(pr.user, []).append(pr)
197198
return result
198199

199200
def __call__(self) -> None:
@@ -213,7 +214,11 @@ def __call__(self) -> None:
213214
try:
214215
getattr(self, "_" + self.args.command, self._url_command)()
215216
except PullError as e:
216-
arg = getattr(self.args, "pull", None) or getattr(self.args, "search", None)
217+
arg = " ".join(
218+
getattr(self.args, "pull", None)
219+
or getattr(self.args, "search", None)
220+
or ()
221+
)
217222
msg = e.args[0]
218223
if arg and not arg in msg:
219224
msg = f"{msg} for {arg}"
@@ -362,7 +367,7 @@ def remotes(self):
362367

363368
@cached_property
364369
def user(self) -> str:
365-
if self.args.user:
370+
if user := getattr(self.args, "user", None):
366371
return self.args.user
367372
if len(self.remotes) != 1:
368373
return self.remotes["origin"]
@@ -640,7 +645,7 @@ def main():
640645
try:
641646
PullRequests()()
642647
except PullError as e:
643-
if DEBUG:
648+
if DEBUG or VERBOSE:
644649
raise
645650
error(e.args[0])
646651

0 commit comments

Comments
 (0)