|
| 1 | +// |
| 2 | +// GTCheckoutOptions.h |
| 3 | +// ObjectiveGitFramework |
| 4 | +// |
| 5 | +// Created by Etienne on 10/04/2015. |
| 6 | +// Copyright (c) 2015 GitHub, Inc. All rights reserved. |
| 7 | +// |
| 8 | + |
| 9 | +#import <Foundation/Foundation.h> |
| 10 | +#import "git2/checkout.h" |
| 11 | + |
| 12 | +@class GTDiffFile; |
| 13 | + |
| 14 | +NS_ASSUME_NONNULL_BEGIN |
| 15 | + |
| 16 | +/// Checkout strategies used by the various -checkout... methods |
| 17 | +/// See git_checkout_strategy_t |
| 18 | +typedef NS_OPTIONS(NSInteger, GTCheckoutStrategyType) { |
| 19 | + GTCheckoutStrategyNone = GIT_CHECKOUT_NONE, |
| 20 | + GTCheckoutStrategySafe = GIT_CHECKOUT_SAFE, |
| 21 | + GTCheckoutStrategyForce = GIT_CHECKOUT_FORCE, |
| 22 | + GTCheckoutStrategyRecreateMissing = GIT_CHECKOUT_RECREATE_MISSING, |
| 23 | + GTCheckoutStrategyAllowConflicts = GIT_CHECKOUT_ALLOW_CONFLICTS, |
| 24 | + GTCheckoutStrategyRemoveUntracked = GIT_CHECKOUT_REMOVE_UNTRACKED, |
| 25 | + GTCheckoutStrategyRemoveIgnored = GIT_CHECKOUT_REMOVE_IGNORED, |
| 26 | + GTCheckoutStrategyUpdateOnly = GIT_CHECKOUT_UPDATE_ONLY, |
| 27 | + GTCheckoutStrategyDontUpdateIndex = GIT_CHECKOUT_DONT_UPDATE_INDEX, |
| 28 | + GTCheckoutStrategyNoRefresh = GIT_CHECKOUT_NO_REFRESH, |
| 29 | + GTCheckoutStrategySkipUnmerged = GIT_CHECKOUT_SKIP_UNMERGED, |
| 30 | + GTCheckoutStrategyUseOurs = GIT_CHECKOUT_USE_OURS, |
| 31 | + GTCheckoutStrategyUseTheirs = GIT_CHECKOUT_USE_THEIRS, |
| 32 | + GTCheckoutStrategyDisablePathspecMatch = GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH, |
| 33 | + GTCheckoutStrategySkipLockedDirectories = GIT_CHECKOUT_SKIP_LOCKED_DIRECTORIES, |
| 34 | + GTCheckoutStrategyDoNotOverwriteIgnored = GIT_CHECKOUT_DONT_OVERWRITE_IGNORED, |
| 35 | + GTCheckoutStrategyConflictStyleMerge = GIT_CHECKOUT_CONFLICT_STYLE_MERGE, |
| 36 | + GTCheckoutStrategyCoflictStyleDiff3 = GIT_CHECKOUT_CONFLICT_STYLE_DIFF3, |
| 37 | + GTCheckoutStrategyDoNotRemoveExisting = GIT_CHECKOUT_DONT_REMOVE_EXISTING, |
| 38 | + GTCheckoutStrategyDoNotWriteIndex = GIT_CHECKOUT_DONT_WRITE_INDEX, |
| 39 | +}; |
| 40 | + |
| 41 | +/// Checkout notification flags used by the various -checkout... methods |
| 42 | +/// See git_checkout_notify_t |
| 43 | +typedef NS_OPTIONS(NSInteger, GTCheckoutNotifyFlags) { |
| 44 | + GTCheckoutNotifyNone = GIT_CHECKOUT_NOTIFY_NONE, |
| 45 | + GTCheckoutNotifyConflict = GIT_CHECKOUT_NOTIFY_CONFLICT, |
| 46 | + GTCheckoutNotifyDirty = GIT_CHECKOUT_NOTIFY_DIRTY, |
| 47 | + GTCheckoutNotifyUpdated = GIT_CHECKOUT_NOTIFY_UPDATED, |
| 48 | + GTCheckoutNotifyUntracked = GIT_CHECKOUT_NOTIFY_UNTRACKED, |
| 49 | + GTCheckoutNotifyIgnored = GIT_CHECKOUT_NOTIFY_IGNORED, |
| 50 | + |
| 51 | + GTCheckoutNotifyAll = GIT_CHECKOUT_NOTIFY_ALL, |
| 52 | +}; |
| 53 | + |
| 54 | +@interface GTCheckoutOptions : NSObject |
| 55 | + |
| 56 | +/// Create a checkout options object. |
| 57 | +/// |
| 58 | +/// Since there are many places where we can checkout data, this object allow us |
| 59 | +/// to centralize all the various behaviors that checkout allow. |
| 60 | +/// |
| 61 | +/// @param strategy The checkout strategy to use. |
| 62 | +/// @param notifyFlags The checkout events that will be notified via `notifyBlock`. |
| 63 | +/// @param progressBlock A block that will be called for each checkout step. |
| 64 | +/// @param notifyBlock A block that will be called for each event, @see `notifyFlags`. |
| 65 | +/// |
| 66 | +/// @return A newly-initialized GTCheckoutOptions object. |
| 67 | ++ (instancetype)checkoutOptionsWithStrategy:(GTCheckoutStrategyType)strategy notifyFlags:(GTCheckoutNotifyFlags)notifyFlags progressBlock:(nullable void (^)(NSString *path, NSUInteger completedSteps, NSUInteger totalSteps))progressBlock notifyBlock:(nullable int (^)(GTCheckoutNotifyFlags why, NSString *path, GTDiffFile *baseline, GTDiffFile *target, GTDiffFile *workdir))notifyBlock; |
| 68 | + |
| 69 | +/// Create a checkout options object. |
| 70 | +/// @see +checkoutOptionsWithStrategy:notifyFlags:progressBlock:notifyBlock: |
| 71 | ++ (instancetype)checkoutOptionsWithStrategy:(GTCheckoutStrategyType)strategy notifyFlags:(GTCheckoutNotifyFlags)notifyFlags notifyBlock:(int (^)(GTCheckoutNotifyFlags why, NSString *path, GTDiffFile *baseline, GTDiffFile *target, GTDiffFile *workdir))notifyBlock; |
| 72 | + |
| 73 | +/// Create a checkout options object. |
| 74 | +/// @see +checkoutOptionsWithStrategy:notifyFlags:progressBlock:notifyBlock: |
| 75 | ++ (instancetype)checkoutOptionsWithStrategy:(GTCheckoutStrategyType)strategy progressBlock:(void (^)(NSString *path, NSUInteger completedSteps, NSUInteger totalSteps))progressBlock; |
| 76 | + |
| 77 | +/// Create a checkout options object. |
| 78 | +/// @see +checkoutOptionsWithStrategy:notifyFlags:progressBlock:notifyBlock: |
| 79 | ++ (instancetype)checkoutOptionsWithStrategy:(GTCheckoutStrategyType)strategy; |
| 80 | + |
| 81 | +/// Get the underlying git_checkout_options struct. |
| 82 | +/// |
| 83 | +/// @return <#return value description#> |
| 84 | +- (git_checkout_options *)git_checkoutOptions NS_RETURNS_INNER_POINTER; |
| 85 | + |
| 86 | +/// The checkout strategy to use. |
| 87 | +@property (assign) GTCheckoutStrategyType strategy; |
| 88 | + |
| 89 | +/// The checkout progress block that was passed in. |
| 90 | +@property (copy) void (^progressBlock)(NSString *path, NSUInteger completedSteps, NSUInteger totalSteps); |
| 91 | + |
| 92 | +/// The notification flags currently enabled. |
| 93 | +@property (assign) GTCheckoutNotifyFlags notifyFlags; |
| 94 | + |
| 95 | +/// The checkout notification block that was passed in. |
| 96 | +@property (copy) int (^notifyBlock)(GTCheckoutNotifyFlags why, NSString *path, GTDiffFile *baseline, GTDiffFile *target, GTDiffFile *workdir); |
| 97 | + |
| 98 | +/// An array of strings used to restrict what will be checked out. |
| 99 | +@property (copy) NSArray <NSString *> *pathSpecs; |
| 100 | + |
| 101 | +@end |
| 102 | + |
| 103 | +NS_ASSUME_NONNULL_END |
0 commit comments