Skip to content

Commit

Permalink
it works!
Browse files Browse the repository at this point in the history
  • Loading branch information
joehinkle11 committed Dec 22, 2020
1 parent b9fd101 commit 4611af4
Showing 1 changed file with 48 additions and 36 deletions.
84 changes: 48 additions & 36 deletions SwiftGit2/Repository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,33 +105,15 @@ private func pushOptions(credentials: Credentials = .default,

options.callbacks.payload = credentials.toPointer()
options.callbacks.credentials = credentialsCallback
func pushTransferProgressCallback(
current: UInt32,
total: UInt32,
bytes: size_t,
payload: UnsafeMutableRawPointer? ) -> Int32 {
let result: Int32 = 1
return result
}
options.callbacks.push_transfer_progress = pushTransferProgressCallback


// /** Push network progress notification function */
// typedef int (*git_push_transfer_progress)(
// unsigned int current,
// unsigned int total,
// size_t bytes,
// void* payload);
// /**

// */
// typedef int (*git_cred_acquire_cb)(
// git_cred **cred,
// const char *url,
// const char *username_from_url,
// unsigned int allowed_types,
// void *payload);

// func pushTransferProgressCallback(
// current: UInt32,
// total: UInt32,
// bytes: size_t,
// payload: UnsafeMutableRawPointer? ) -> Int32 {
// let result: Int32 = 1
// return result
// }
// options.callbacks.push_transfer_progress = pushTransferProgressCallback

return options
}
Expand All @@ -148,20 +130,50 @@ public final class Repository {

let repository: OpaquePointer = repo.pointer
var remote: OpaquePointer? = nil
let callbacks: UnsafePointer<git_remote_callbacks>? = nil
let proxy_opts: UnsafePointer<git_proxy_options>? = nil
let headers: UnsafePointer<git_strarray>? = nil
git_remote_lookup(&remote, repository, "origin" )
let result_git_remote_lookup = git_remote_lookup(&remote, repository, "origin" )
print(result_git_remote_lookup)

// connect to remote
git_remote_connect(remote, GIT_DIRECTION_PUSH, callbacks, proxy_opts, headers)
// callbacks.payload = credentials.toPointer()
// callbacks.credentials = credentialsCallback
// callbacks.
// git_remote_init_callbacks(&options.callbacks, UInt32(GIT_REMOTE_CALLBACKS_VERSION))

// add a push refspec
git_remote_add_push(repository, "origin", "refs/heads/master:refs/heads/master" );
// let result_git_remote_connect = git_remote_connect(remote, GIT_DIRECTION_PUSH, &options.callbacks, &options.proxy_opts, &options.custom_headers)
// print(result_git_remote_connect)

// add a push refspec
// let result_git_remote_add_push = git_remote_add_push(repository, "origin", "refs/heads/master:refs/heads/master" );
// print(result_git_remote_add_push)




let master = "refs/heads/master"
// let master = "refs/master"
// let origin = "origin"
// var originPtr = origin.cString(using: .utf8)
// var masterPtr = master.cString(using: .utf8)
// var arr: UnsafeMutablePointer<UnsafeMutablePointer<CChar>?> = .allocate(capacity: 1)
let strings: UnsafeMutablePointer<UnsafeMutablePointer<CChar>?> = [master].withUnsafeBufferPointer {
let buffer = UnsafeMutablePointer<UnsafeMutablePointer<CChar>?>.allocate(capacity: $0.count + 1)
let val = $0.map
{ $0.withCString(strdup) }
buffer.initialize(from: val, count: 1)
buffer[$0.count] = nil
return buffer
}
var gitstr = git_strarray()
gitstr.strings = strings
gitstr.count = 1

let push_result = git_remote_push(remote, &gitstr, &options)
print(push_result)


// do the push
let result = git_remote_upload(remote, nil, &options)
print(result)
// let result = git_remote_upload(remote, nil, &options)
// print(result)
git_remote_free(remote)
}

Expand Down

0 comments on commit 4611af4

Please sign in to comment.