|
| 1 | +//===----------------------------------------------------------------------===// |
| 2 | +// |
| 3 | +// This source file is part of the swift-libgit2 open source project. |
| 4 | +// |
| 5 | +// Copyright (c) Margins Technologies LLC. |
| 6 | +// Licensed under the Apache License, Version 2.0. |
| 7 | +// |
| 8 | +//===----------------------------------------------------------------------===// |
| 9 | + |
| 10 | +import CLibgit2 |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | +/// The actions that a smart transport can ask a subtransport to perform. |
| 15 | +/// |
| 16 | +/// ## C Equivalent |
| 17 | +/// |
| 18 | +/// [`git_smart_service_t`](https://libgit2.org/docs/reference/main/sys/transport/git_smart_service_t.html) |
| 19 | +public enum GitSmartServiceT: UInt32, CEnum |
| 20 | +{ |
| 21 | + /// List the references available for fetching or cloning. |
| 22 | + /// |
| 23 | + /// ## Discussion |
| 24 | + /// |
| 25 | + /// This is equivalent to `git-upload-pack --advertise-refs` or |
| 26 | + /// `git-upload-pack --http-backend-info-refs`. |
| 27 | + case gitServiceUploadPackLS = 1 |
| 28 | + |
| 29 | + /// Fetch objects from the remote repository. |
| 30 | + /// |
| 31 | + /// ## Discussion |
| 32 | + /// |
| 33 | + /// This is equivalent to `git-upload-pack`. |
| 34 | + case gitServiceUploadPack = 2 |
| 35 | + |
| 36 | + /// List the references available for pushing. |
| 37 | + /// |
| 38 | + /// ## Discussion |
| 39 | + /// |
| 40 | + /// This is equivalent to `git-receive-pack --http-backend-info-refs`. |
| 41 | + case gitServiceReceivePackLS = 3 |
| 42 | + |
| 43 | + /// Push objects to the remote repository. |
| 44 | + /// |
| 45 | + /// ## Discussion |
| 46 | + /// |
| 47 | + /// This is equivalent to `git-receive-pack`. |
| 48 | + case gitServiceReceivePack = 4 |
| 49 | + |
| 50 | + |
| 51 | + |
| 52 | + /// Initializes a ``GitSmartServiceT`` instance from the given |
| 53 | + /// `git_smart_service_t` instance. |
| 54 | + /// - Parameter smartService: The `git_smart_service_t` instance to use. |
| 55 | + internal init?( |
| 56 | + cValue smartService: git_smart_service_t |
| 57 | + ) |
| 58 | + { |
| 59 | + switch smartService |
| 60 | + { |
| 61 | + case GIT_SERVICE_UPLOADPACK_LS : self = .gitServiceUploadPackLS |
| 62 | + case GIT_SERVICE_UPLOADPACK : self = .gitServiceUploadPack |
| 63 | + case GIT_SERVICE_RECEIVEPACK_LS : self = .gitServiceReceivePackLS |
| 64 | + case GIT_SERVICE_RECEIVEPACK : self = .gitServiceReceivePack |
| 65 | + default : return nil |
| 66 | + } |
| 67 | + } |
| 68 | + |
| 69 | + |
| 70 | + |
| 71 | + /// Converts the ``GitSmartServiceT`` instance into a `git_smart_service_t` |
| 72 | + /// instance. |
| 73 | + /// - Returns: The `git_smart_service_t` instance. |
| 74 | + internal func cValue() -> git_smart_service_t |
| 75 | + { |
| 76 | + switch self |
| 77 | + { |
| 78 | + case .gitServiceUploadPackLS : return GIT_SERVICE_UPLOADPACK_LS |
| 79 | + case .gitServiceUploadPack : return GIT_SERVICE_UPLOADPACK |
| 80 | + case .gitServiceReceivePackLS : return GIT_SERVICE_RECEIVEPACK_LS |
| 81 | + case .gitServiceReceivePack : return GIT_SERVICE_RECEIVEPACK |
| 82 | + } |
| 83 | + } |
| 84 | +} |
0 commit comments