Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 7ced025d97d657b7deb9b6e311fbbc78c2ee3351
Author: Whirlwind <[email protected]>
Date:   Tue Aug 17 12:10:15 2021 +0800

    [Optimize] Find repo by repo will not search package name
  • Loading branch information
liyao.ryan committed Aug 17, 2021
1 parent 1f55a64 commit 35db1c6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
5 changes: 4 additions & 1 deletion Native/MBoxWorkspace/CLI/Remove.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ extension MBCommander {
} else {
for name in self.names {
try UI.log(verbose: "[\(name)]") {
let repos = config.currentFeature.findRepo(name: name)
var repos = config.currentFeature.findRepo(name: name, searchPackageName: false)
if repos.count == 0 {
repos = config.currentFeature.findRepo(name: name, searchPackageName: true)
}
if repos.count == 0 {
UI.log(warn: "Could not find the repo `\(name)`")
return
Expand Down
2 changes: 1 addition & 1 deletion Native/MBoxWorkspaceCore/Model/MBConfig.Feature+Repo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ extension MBConfig.Feature {
return r
}
}
return findRepo(name: repo.name, owner: repo.owner).first
return findRepo(name: repo.name, owner: repo.owner, searchPackageName: false).first
}

@discardableResult
Expand Down
7 changes: 5 additions & 2 deletions Native/MBoxWorkspaceCore/Model/MBConfig.Repo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,11 @@ extension MBConfig.Repo {
guard let workRepo = self.workRepository else {
return
}
if let head = head {
try workRepo.git?.setHEAD(head)
if let head = head, let git = workRepo.git {
if head.isBranch, git.localBranch(named: head.value) == nil {
try git.createBranch(head.value, base: head)
}
try git.setHEAD(head)
}
let cachePath = self.worktreeCachePath
if cachePath.isDirectory {
Expand Down

0 comments on commit 35db1c6

Please sign in to comment.