class Object
Public Instance Methods
gitinit()
click to toggle source
# File bin/gitmagic, line 94 def gitinit `git init #{$dir}` # Fix the git confi file gitconftxt = "[remote \"origin\"]\n" gitconftxt += "\turl = git@github.com:#{$user}/#{$repo}.git\n" gitconftxt += "\tfetch = +refs/heads/*:refs/remotes/origin/*\n" gitconftxt += "[branch \"master\"]\n" gitconftxt += "\tremote = origin\n" gitconftxt += "\tmerge = refs/heads/master" File.write("#{$dir}/.git/config", gitconftxt, mode: 'a') # Upload the repo to Github jsontxt = "{\"name\": \"#{$repo}\", \"description\": \"#{$desc}\", \"private\": #{$priv}, \"has_issues\": #{$issues}, \"has_downloads\": #{$downloads}, \"has_wiki\": #{$wiki}}" cmd = %Q[curl -u #{$user} https://api.github.com/user/repos -d '#{jsontxt}'] out = %x[ #{cmd} ] end
gitpres()
click to toggle source
# File bin/gitmagic, line 114 def gitpres $dir = $repodir + "/" + $repo Dir.mkdir($dir) presdir = $pres_templ + "/." FileUtils.cp_r(presdir, $dir) gitdir = $dir + "/.git" FileUtils.remove_dir(gitdir) end
gitupdate()
click to toggle source
# File bin/gitmagic, line 110 def gitupdate %x[ cd #{$dir} && git add . && git commit -m '#{$message}' && git push ] end
help()
click to toggle source
# File bin/gitmagic, line 25 def help puts <<HELPTEXT NAME "gitmagic" is a swiss army knife of git tools SYNOPSIS gitmagic [-idDpusvh] [long-options] DESCRIPTION gitmagic makes initiating a project easy, also from a local template project. It also simplifies updating git projects. It will do more in due time. OPTIONS -c, --clone Simply clones a repo, just like 'git clone'. -i, --init Initialize a new github project. Requires a name for the repo as argument You may supply --desc (-d) for a description of the repo, or else a description will be added in the form "Project_2018-09-13" You may supply a dir path "--dir" (-D), or else the current dir is used EXAMPLE: gimagic -i "My new repo!" -d "Really cool stuff" -D ~/projects/124 -d, --desc Add description to a new repo Used in combination with --init or --slides -D, --dir Specify the directory for a new initiated repo Used in combination with --init or --update If no directory is specified, the program will use the current directory -p, --priv Make the Github repo private -u, --update Update a github project Takes the commit message as argument You may supply a dir path "--dir" (-D), or else the current dir is used EXAMPLE: gimagic -u "Bug fix" -D ~/projects/159 -s, --slides Create a presentation project with slides written in simple Markdown text. See Fredrik Eilertsen's neat work that makes it possible to create presentations using Jekyll (https://github.com/fredeil/gh-presentation) This option will use '$pres_templ' to find the cloned "gh-presentation" It will create the presentation under your '$repodir' You must supply a name for your repo/presentation as the argument EXAMPLE: gimagic -s "Presentation23" -v, --version Show the version of this program -h, --help Show this help text COPYRIGHT: Copyright 2018, Geir Isene (https://isene.org) This program is released under the WTFPL license (Full license text here: http://www.wtfpl.net/about/) HELPTEXT end