Skip to content

Commit

Permalink
Changes from Tidepool (LoopKit#55)
Browse files Browse the repository at this point in the history
* Changes from Tidepool

* Update to dev

* Add merges for NightscoutRemoteCGM and G7SensorKit

* Fix tests
  • Loading branch information
ps2 authored May 6, 2023
1 parent 1803e01 commit 201ab79
Show file tree
Hide file tree
Showing 15 changed files with 173 additions and 12 deletions.
2 changes: 1 addition & 1 deletion G7SensorKit
1 change: 1 addition & 0 deletions InfoCustomizations.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TidepoolServiceClientId=diy-loop
2 changes: 1 addition & 1 deletion Loop
Submodule Loop updated 48 files
+11 −1 Common/FeatureFlags.swift
+58 −5 Loop.xcodeproj/project.pbxproj
+1 −1 Loop.xcodeproj/xcshareddata/xcschemes/DoseMathTests.xcscheme
+1 −1 Loop.xcodeproj/xcshareddata/xcschemes/Loop Intent Extension.xcscheme
+1 −1 Loop.xcodeproj/xcshareddata/xcschemes/Loop Status Extension.xcscheme
+1 −1 Loop.xcodeproj/xcshareddata/xcschemes/Loop.xcscheme
+1 −1 Loop.xcodeproj/xcshareddata/xcschemes/LoopTests.xcscheme
+1 −1 Loop.xcodeproj/xcshareddata/xcschemes/SmallStatusWidgetExtension.xcscheme
+1 −1 Loop.xcodeproj/xcshareddata/xcschemes/WatchApp.xcscheme
+2 −0 Loop/AppDelegate.swift
+42 −69 Loop/Base.lproj/Main.storyboard
+15 −3 Loop/Managers/AlertMuter.swift
+22 −2 Loop/Managers/Alerts/AlertManager.swift
+38 −23 Loop/Managers/DeviceDataManager.swift
+4 −4 Loop/Managers/ExtensionDataManager.swift
+6 −4 Loop/Managers/LocalTestingScenariosManager.swift
+29 −5 Loop/Managers/LoopAppManager.swift
+24 −22 Loop/Managers/LoopDataManager.swift
+10 −4 Loop/Managers/OnboardingManager.swift
+0 −2 Loop/Managers/Store Protocols/DoseStoreProtocol.swift
+32 −27 Loop/Managers/SupportManager.swift
+101 −18 Loop/Managers/TestingScenariosManager.swift
+21 −0 Loop/Models/AutomaticDosingStatus.swift
+0 −23 Loop/Models/ClosedLoopStatus.swift
+0 −1 Loop/Models/StoredLoopNotRunningNotification.swift
+3 −3 Loop/View Controllers/CarbAbsorptionViewController.swift
+140 −58 Loop/View Controllers/StatusTableViewController.swift
+21 −8 Loop/View Controllers/TestingScenariosTableViewController.swift
+52 −15 Loop/View Models/BolusEntryViewModel.swift
+4 −0 Loop/View Models/SettingsViewModel.swift
+2 −5 Loop/View Models/VersionUpdateViewModel.swift
+73 −24 Loop/Views/AlertManagementView.swift
+7 −23 Loop/Views/BolusEntryView.swift
+80 −0 Loop/Views/HowMuteAlertWorkView.swift
+7 −0 Loop/Views/SettingsView.swift
+6 −1 LoopCore/NSUserDefaults.swift
+4 −4 LoopTests/Managers/LoopDataManagerDosingTests.swift
+1 −1 LoopTests/Managers/LoopDataManagerTests.swift
+35 −22 LoopTests/Managers/SupportManagerTests.swift
+0 −4 LoopTests/Mock Stores/MockDoseStore.swift
+5 −5 LoopTests/ViewModels/BolusEntryViewModelTests.swift
+1 −1 LoopUI/StatusBarHUDView.xib
+12 −0 LoopUI/ViewModel/CGMStatusHUDViewModel.swift
+4 −0 LoopUI/Views/CGMStatusHUDView.swift
+61 −0 Scripts/apply-info-customizations.sh
+18 −0 Scripts/install-scenarios.sh
+7 −1 StatusWidget/StatusWidget.swift
+2 −2 WatchApp Extension/Views/Carb Entry & Bolus/BolusInput.swift
2 changes: 1 addition & 1 deletion LoopKit
Submodule LoopKit updated 39 files
+4 −0 LoopKit.xcodeproj/project.pbxproj
+1 −1 LoopKit.xcodeproj/xcshareddata/xcschemes/LoopKit Example.xcscheme
+1 −1 LoopKit.xcodeproj/xcshareddata/xcschemes/Shared-watchOS.xcscheme
+1 −1 LoopKit.xcodeproj/xcshareddata/xcschemes/Shared.xcscheme
+0 −6 LoopKit/CarbKit/CachedCarbObject+CoreDataClass.swift
+11 −0 LoopKit/DeviceManager/DeviceStatusHighlight.swift
+14 −0 LoopKit/DeviceManager/PumpManager.swift
+1 −1 LoopKit/InsulinKit/DoseStore.swift
+6 −6 LoopKit/VersionUpdate.swift
+1 −1 LoopKitTests/VersionCheckServiceTests.swift
+1 −1 LoopKitUI/CGMManagerUI.swift
+20 −3 LoopKitUI/CarbKit/DateAndDurationSteppableTableViewCell.swift
+7 −3 LoopKitUI/OnboardingUI.swift
+1 −1 LoopKitUI/PumpManagerUI.swift
+1 −0 LoopKitUI/ServiceUI.swift
+23 −7 LoopKitUI/SupportUI.swift
+2 −2 LoopKitUI/Views/FractionalQuantityPicker.swift
+12 −0 LoopKitUI/Views/HUDAssets.xcassets/reservoir/generic-reservoir-mask.imageset/Contents.json
+ LoopKitUI/Views/HUDAssets.xcassets/reservoir/generic-reservoir-mask.imageset/generic-reservoir-fill.png
+12 −0 LoopKitUI/Views/HUDAssets.xcassets/reservoir/generic-reservoir.imageset/Contents.json
+ LoopKitUI/Views/HUDAssets.xcassets/reservoir/generic-reservoir.imageset/generic-reservoir-outline.png
+14 −11 LoopKitUI/Views/ReservoirVolumeHUDView.xib
+14 −9 LoopKitUI/Views/Settings Editors/DeliveryLimitsEditor.swift
+15 −10 LoopKitUI/Views/Settings Editors/InsulinModelSelection.swift
+14 −9 LoopKitUI/Views/Settings Editors/SuspendThresholdEditor.swift
+2 −4 LoopKitUI/Views/Settings Editors/TherapySettingsView.swift
+1 −1 LoopTestingKit/DateRelativeBasalEntry.swift
+14 −0 LoopTestingKit/DeviceAction.swift
+1 −1 LoopTestingKit/TestingCGMManager.swift
+3 −0 LoopTestingKit/TestingDeviceManager.swift
+13 −3 LoopTestingKit/TestingScenario.swift
+12 −2 LoopTestingKit/TestingScenarioInstance.swift
+10 −3 MockKit/MockCGMManager.swift
+21 −2 MockKit/MockPumpManager.swift
+12 −2 MockKit/MockPumpManagerState.swift
+1 −1 MockKitUI/MockCGMManager+UI.swift
+1 −1 MockKitUI/MockPumpManager+UI.swift
+15 −3 MockKitUI/MockSupport.swift
+8 −2 MockKitUI/View Controllers/MockPumpManagerSettingsViewController.swift
3 changes: 3 additions & 0 deletions LoopWorkspace.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion MinimedKit
2 changes: 1 addition & 1 deletion NightscoutRemoteCGM
157 changes: 157 additions & 0 deletions Scripts/sync.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
#!/usr/bin/swift sh

// Depends on swift-sh. Install with: `brew install swift-sh`

import Foundation
import Cocoa

import AsyncSwiftGit // @bdewey
import OctoKit // /Users/pete/dev/octokit.swift

struct Project {
let project: String
let branch: String

init(_ project: String, _ branch: String) {
self.project = project
self.branch = branch
}
}

let projects = [
Project("Loop", "dev"),
Project("LoopKit", "dev"),
Project("CGMBLEKit", "dev"),
Project("dexcom-share-client-swift", "dev"),
//Project("RileyLinkKit", "dev"),
//Project("MKRingProgressView", "dev"),
Project("NightscoutService", "dev"),
//Project("Minizip", "dev"),
//Project("TrueTime.swift", "dev"),
Project("LoopOnboarding", "dev"),
Project("AmplitudeService", "dev"),
Project("LogglyService", "dev"),
Project("OmniBLE", "dev"),
Project("NightscoutRemoteCGM", "dev"),
Project("LoopSupport", "dev"),
Project("G7SensorKit", "dev"),
Project("TidepoolService", "dev"),
Project("TidepoolKit", "dev"),
Project("OmniKit", "main"),
Project("MinimedKit", "main")
]

let fm = FileManager.default
let loopkit = URL(string: "https://github.com/LoopKit")!
let tidepool = URL(string: "https://github.com/tidepool-org")!
let syncBranch = "tidepool-sync"
let incomingRemote = "tidepool"

enum EnvError: Error {
case missing(String)
}

func getEnv(_ name: String) throws -> String {
guard let value = ProcessInfo.processInfo.environment[name] else {
throw EnvError.missing(name)
}
return value
}

let ghUsername = try getEnv("GH_USERNAME")
let ghToken = try getEnv("GH_TOKEN")
let ghCommitterName = try getEnv("GH_COMMITTER_NAME")
let ghCommitterEmail = try getEnv("GH_COMMITTER_EMAIL")

let octokit = Octokit(TokenConfiguration(ghToken))

let credentials = Credentials.plaintext(username: ghUsername, password: ghToken)
let signature = try! Signature(name: ghCommitterName, email: ghCommitterEmail)

for project in projects {
let dest = URL(string: fm.currentDirectoryPath)!.appendingPathComponent(project.project)
let repository: AsyncSwiftGit.Repository
if !fm.fileExists(atPath: project.project) {
print("Cloning \(project.project)")
let url = loopkit.appendingPathComponent(project.project)
repository = try await Repository.clone(from: url, to: dest)
print("Cloned \(project.project)")
} else {
print("Already Exists: \(project.project)")
repository = try Repository(openAt: dest)
}

let incomingRemoteURL = tidepool.appendingPathComponent(project.project)

// Add remote if it doesn't exist, and fetch latest changes
if (try? repository.remoteURL(for: incomingRemote)) == nil {
try repository.addRemote(incomingRemote, url: incomingRemoteURL)
}
try await repository.fetch(remote: incomingRemote)

// Create and checkout the branch where sync changesets will go ("tidepool-sync")
if !(try repository.branchExists(named: syncBranch)) {
try repository.createBranch(named: syncBranch, target: project.branch)
}
try await repository.checkout(revspec: syncBranch)

// Merge changes from tidepool to diy
try await repository.merge(revisionSpecification: "\(incomingRemote)/\(project.branch)", signature: signature)

// Push changes up to origin
let refspec = "refs/heads/" + syncBranch + ":refs/heads/" + syncBranch
print("Pushing \(refspec) to \(project.project)")
try await repository.push(remoteName: "origin", refspecs: [refspec], credentials: credentials)

// Make sure a PR exists, or create it
let prs = try await octokit.listPullRequests(owner: "LoopKit", repo: project.project, base: project.branch, head:"LoopKit:tidepool-sync")
let pr: PullRequest
if prs.count == 0 {
pr = try await octokit.createPullRequest(owner: "LoopKit", repo: project.project, title: "Tidepool Sync", head: "LoopKit:" + syncBranch, base: project.branch, body: "")
print("PR = \(pr)")
} else {
pr = prs.first!
}
if let url = pr.htmlURL {
if NSWorkspace.shared.open(url) {
print("default browser was successfully opened")

}
}
}

extension Octokit {
func createPullRequest(owner: String,
repo: String,
title: String,
head: String,
headRepo: String? = nil,
base: String,
body: String? = nil,
maintainerCanModify: Bool? = nil,
draft: Bool? = nil) async throws -> PullRequest
{
return try await withCheckedThrowingContinuation { continuation in
octokit.pullRequest(owner: owner, repo: repo, title: title, head: head, headRepo: headRepo, base: base, body: body, maintainerCanModify: maintainerCanModify, draft: draft)
{ response in
continuation.resume(with: response)
}
}
}

func listPullRequests(owner: String,
repo: String,
base: String? = nil,
head: String? = nil,
state: Openness = .open,
sort: SortType = .created,
direction: SortDirection = .desc) async throws -> [PullRequest]
{
return try await withCheckedThrowingContinuation { continuation in
octokit.pullRequests(owner: owner, repository: repo, base: base, head: head, state: state, sort: sort, direction: direction)
{ response in
continuation.resume(with: response)
}
}
}
}
2 changes: 1 addition & 1 deletion Scripts/update_submodule_refs.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/zsh

projects=(LoopKit:AmplitudeService:dev LoopKit:CGMBLEKit:dev LoopKit:G7SensorKit:main LoopKit:LogglyService:dev LoopKit:Loop:dev LoopKit:LoopKit:dev LoopKit:LoopOnboarding:dev LoopKit:LoopSupport:dev LoopKit:NightscoutAPIClient:master ps2:NightscoutService:dev LoopKit:OmniBLE:dev LoopKit:TidepoolKit:dev LoopKit:TidepoolService:dev LoopKit:dexcom-share-client-swift:dev ps2:rileylink_ios:dev LoopKit:OmniKit:main LoopKit:MinimedKit:main)
projects=(LoopKit:AmplitudeService:dev LoopKit:CGMBLEKit:dev LoopKit:G7SensorKit:main LoopKit:LogglyService:dev LoopKit:Loop:dev LoopKit:LoopKit:dev LoopKit:LoopOnboarding:dev LoopKit:LoopSupport:dev LoopKit:NightscoutRemoteCGM:dev LoopKit:NightscoutService:dev LoopKit:OmniBLE:dev LoopKit:TidepoolKit:dev LoopKit:TidepoolService:dev LoopKit:dexcom-share-client-swift:dev ps2:RileyLinkKit:dev LoopKit:OmniKit:main LoopKit:MinimedKit:main)

for project in ${projects}; do
echo "Updating to $project"
Expand Down

0 comments on commit 201ab79

Please sign in to comment.