Skip to content

Instantly share code, notes, and snippets.

@jw3126 jw3126/LibGit2.jl
Created Apr 27, 2019

Embed
What would you like to do?
LibGit2
using LibGit2
repo_path = "LibGit2TestRepo"
repo_url = "git@github.com:jw3126/LibGit2TestRepo.git"
rm(repo_path, recursive=true, force=true)
mkpath(path)
# init
repo = try
@info "Cloning repo"
LibGit2.clone(repo_url, repo_path, )
catch err
@error err
@info "cannot clone from $repo_url init new repo"
origin = LibGit2.GitRemote(repo, "origin", repo_url)
LibGit2.init(repo_path)
end
# commit
filename = "file1.txt"
filepath = joinpath(repo_path, filename)
write(filepath, "1")
LibGit2.add!(repo, filename)
LibGit2.commit(repo, "commit1")
# check repo clean and tidy
@assert !LibGit2.isdirty(repo)
@assert LibGit2.branch(repo) == "master"
# push
LibGit2.push(repo, force=true, remote="origin", refspecs=["refs/heads/master"])
# tagging
tl = LibGit2.tag_list(repo)
ts = map(tl) do t
parse(Int, t)
end
n = reduce(max, ts, init=0) + 1
LibGit2.tag_create(repo, string(n), "master")
LibGit2.push(repo, force=true, remote="origin", refspecs=["refs/tags/$n"])
@show LibGit2.tag_list(repo)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.