diff --git a/.gitignore b/.gitignore index a2b9290..3e2e84b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,2 @@ build/ node_modules/ -lib/gitteh.js -lib/args.js \ No newline at end of file diff --git a/.gitmodules b/.gitmodules index d64f3d7..87fe6f0 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "deps/libgit2"] path = deps/libgit2 - url = git://github.com/libgit2/libgit2.git + url = https://github.com/libgit2/libgit2 diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 17c8c7b..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,22 +0,0 @@ -## v0.1.0 - 03/04/11 -* Heavy refactors to bring gitteh up to date with libgit2 0.11.0. -* Commits no longer have methods to retrieve tree/parents. Instead, they are just sha1 string properties on the object. -* Trees no longer have getEntry() method, all tree entries are added to an array in the tree.entries property. -* Tree writing is currently unsupported (as it's been broken in libgit2), next version will allow writing an index as a tree. -* Ref deletion is now supported. -* Ref packing is supported. This is a fairly advanced feature and required more work than it was worth. Any issues reported on this will be followed up ASAP. -* Full documentation written for the bindings. Huzzah. - -## v0.0.4 - 29/03/11 -* Added support for working with git indexes. -* Fixed issues that could cause asynchronous retrieval of objects to fail miserably. - -## v0.0.3 - 20/03/11 -* Fixed up some pretty serious memory leaks stemming from how git_oid and git_signatures were being handled. - -## v0.0.2 - 20/03/11 -* Minor fix to support 64-bit compiles (thanks TooTallNate). -* Improved build system, will now automatically checkout libgit2 and build it if it's not already present on system. - -## v0.0.1 - 18/03/11 -* Initial release. diff --git a/Cakefile b/Cakefile deleted file mode 100644 index 0b7b590..0000000 --- a/Cakefile +++ /dev/null @@ -1,30 +0,0 @@ -{spawn} = require 'child_process' - -showinfo = (args) -> console.info("Spawn: ", args.join(" ")) - -module.exports = - passthru: (args...) -> - callback = -> - callback = args.pop() if "function" == typeof args[args.length-1] - showinfo(args) - proc = spawn '/usr/bin/env', args - proc.stdout.pipe process.stdout - proc.stderr.pipe process.stderr - proc.on 'exit', (code) -> - console.info("Exited with status: " + code) if code - callback(code) - -task 'build', 'Compile CoffeeScript to JavaScript.', -> - module.exports.passthru 'coffee', '-o', 'lib/', '-c', 'src/' - -task 'test', 'Run the unit tests.', -> - module.exports.passthru './node_modules/.bin/mocha' # or your test runner - -# exec 'mv NPM-index.js index.js; npm publish; mv index.js NPM-index.js' -task 'publish', 'Publish the NPM module.', -> - module.exports.passthru 'mv', 'NPM-index.js', 'index.js', (code) -> - module.exports.passthru 'npm', 'publish', '.', (code) -> - module.exports.passthru 'mv', 'index.js', 'NPM-index.js' - -task "watch", "Watch coffee/ for changes and compile them to lib/", -> - module.exports.passthru "coffee", "-o", "lib/", "-w", "-c", "src/" diff --git a/LIBGIT2_BUGS.md b/LIBGIT2_BUGS.md deleted file mode 100644 index 1d2f0db..0000000 --- a/LIBGIT2_BUGS.md +++ /dev/null @@ -1,3 +0,0 @@ -* Saving a commit with an unsaved tree segfaults. - -* calling git_remote_download without first calling git_remote_connect segfaults \ No newline at end of file diff --git a/README.md b/README.md index 7429a8b..834fddd 100644 --- a/README.md +++ b/README.md @@ -34,19 +34,13 @@ Contributions are very welcome. Please feel free to fork this project and hack o ### Building -In order to build Gitteh, you first need to install coffee-script. -[Coffee-script](http://coffeescript.org/) is not needed to use the library, only to -work with the source. - - npm install -g coffee-script - -Next, you need to install gitteh's dependencies. In gitteh's root directory, run: +Next, you need to install gitteh's dependencies and build it. In gitteh's root directory, run: npm install + node preinstall.js + node install.js -Lastly, you need to compile and build gitteh - - cake build - -It should generate `lib/gitteh.js` for you to use. Happy hacking! +### Installing Manually +Copy the parent directory of the now built module to the node_modules directory of your project. Include the module using: + gitteh = require('gitteh'); diff --git a/TODO.md b/TODO.md deleted file mode 100644 index fac575c..0000000 --- a/TODO.md +++ /dev/null @@ -1,22 +0,0 @@ -TODO: - -* Improve install system. Should probably at least try and check system for a - valid libgit2 system - however unlikely. Should also be downloading a tarball - of release rather than heavyweight git subdirectory checkout. -* Lookup lightweight/annotated tag by name. -* V8 AdjustForMemoryByCompensatingWithAReallyLongMethodName when we allocate libgit2 stuff - -# (Old) TODO - probably still relevant - -* Integrity tests, make sure bindings don't choke or segfault on really bad data. -* Possibly implement custom backend support, allowing JS callbacks to provide a custom git backend. -* Check for memory leaks -* Cache raw objects properly, so two requests for the same oid don't result in different objects. -* Maybe add convenience methods to all existing wrapped objects to get the raw object equivalent of them. -* Error handling in the EIO initialization stuff for objects. Not sure if something can go wrong there, but better safe than sorry. -* Tests for initializing a new repository, bare or workingdir. -* Stress test suite. -* Perf tests. -* See if we can remove the lock on repository for some serious speed. -* Make sure all create/get stuff in repo is returning local copies of handles. -* Update Index to not use getters/setters for index modification. Instead, work with an array like tree entries. \ No newline at end of file diff --git a/docs/.gitignore b/docs/.gitignore deleted file mode 100644 index 69fa449..0000000 --- a/docs/.gitignore +++ /dev/null @@ -1 +0,0 @@ -_build/ diff --git a/docs/Makefile b/docs/Makefile deleted file mode 100644 index 23e2573..0000000 --- a/docs/Makefile +++ /dev/null @@ -1,177 +0,0 @@ -# Makefile for Sphinx documentation -# - -# You can set these variables from the command line. -SPHINXOPTS = -SPHINXBUILD = sphinx-build -PAPER = -BUILDDIR = _build - -# User-friendly check for sphinx-build -ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) -$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) -endif - -# Internal variables. -PAPEROPT_a4 = -D latex_paper_size=a4 -PAPEROPT_letter = -D latex_paper_size=letter -ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . -# the i18n builder cannot share the environment and doctrees with the others -I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . - -.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext - -help: - @echo "Please use \`make ' where is one of" - @echo " html to make standalone HTML files" - @echo " dirhtml to make HTML files named index.html in directories" - @echo " singlehtml to make a single large HTML file" - @echo " pickle to make pickle files" - @echo " json to make JSON files" - @echo " htmlhelp to make HTML files and a HTML help project" - @echo " qthelp to make HTML files and a qthelp project" - @echo " devhelp to make HTML files and a Devhelp project" - @echo " epub to make an epub" - @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" - @echo " latexpdf to make LaTeX files and run them through pdflatex" - @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" - @echo " text to make text files" - @echo " man to make manual pages" - @echo " texinfo to make Texinfo files" - @echo " info to make Texinfo files and run them through makeinfo" - @echo " gettext to make PO message catalogs" - @echo " changes to make an overview of all changed/added/deprecated items" - @echo " xml to make Docutils-native XML files" - @echo " pseudoxml to make pseudoxml-XML files for display purposes" - @echo " linkcheck to check all external links for integrity" - @echo " doctest to run all doctests embedded in the documentation (if enabled)" - -clean: - rm -rf $(BUILDDIR)/* - -html: - $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html - @echo - @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." - -dirhtml: - $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml - @echo - @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." - -singlehtml: - $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml - @echo - @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." - -pickle: - $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle - @echo - @echo "Build finished; now you can process the pickle files." - -json: - $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json - @echo - @echo "Build finished; now you can process the JSON files." - -htmlhelp: - $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp - @echo - @echo "Build finished; now you can run HTML Help Workshop with the" \ - ".hhp project file in $(BUILDDIR)/htmlhelp." - -qthelp: - $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp - @echo - @echo "Build finished; now you can run "qcollectiongenerator" with the" \ - ".qhcp project file in $(BUILDDIR)/qthelp, like this:" - @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/node-gitteh.qhcp" - @echo "To view the help file:" - @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/node-gitteh.qhc" - -devhelp: - $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp - @echo - @echo "Build finished." - @echo "To view the help file:" - @echo "# mkdir -p $$HOME/.local/share/devhelp/node-gitteh" - @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/node-gitteh" - @echo "# devhelp" - -epub: - $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub - @echo - @echo "Build finished. The epub file is in $(BUILDDIR)/epub." - -latex: - $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex - @echo - @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." - @echo "Run \`make' in that directory to run these through (pdf)latex" \ - "(use \`make latexpdf' here to do that automatically)." - -latexpdf: - $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex - @echo "Running LaTeX files through pdflatex..." - $(MAKE) -C $(BUILDDIR)/latex all-pdf - @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." - -latexpdfja: - $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex - @echo "Running LaTeX files through platex and dvipdfmx..." - $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja - @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." - -text: - $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text - @echo - @echo "Build finished. The text files are in $(BUILDDIR)/text." - -man: - $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man - @echo - @echo "Build finished. The manual pages are in $(BUILDDIR)/man." - -texinfo: - $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo - @echo - @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." - @echo "Run \`make' in that directory to run these through makeinfo" \ - "(use \`make info' here to do that automatically)." - -info: - $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo - @echo "Running Texinfo files through makeinfo..." - make -C $(BUILDDIR)/texinfo info - @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." - -gettext: - $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale - @echo - @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." - -changes: - $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes - @echo - @echo "The overview file is in $(BUILDDIR)/changes." - -linkcheck: - $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck - @echo - @echo "Link check complete; look for any errors in the above output " \ - "or in $(BUILDDIR)/linkcheck/output.txt." - -doctest: - $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest - @echo "Testing of doctests in the sources finished, look at the " \ - "results in $(BUILDDIR)/doctest/output.txt." - -xml: - $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml - @echo - @echo "Build finished. The XML files are in $(BUILDDIR)/xml." - -pseudoxml: - $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml - @echo - @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." diff --git a/docs/api.rst b/docs/api.rst deleted file mode 100644 index c0b4a01..0000000 --- a/docs/api.rst +++ /dev/null @@ -1,16 +0,0 @@ -API -=== - -.. toctree:: - :maxdepth: 2 - - blob - commit - gitindex - reference - refspec - remote - repository - signature - tag - tree diff --git a/docs/blob.rst b/docs/blob.rst deleted file mode 100644 index e769ea4..0000000 --- a/docs/blob.rst +++ /dev/null @@ -1,4 +0,0 @@ -Blob -==== - -.. autoclass:: gitteh::Blob \ No newline at end of file diff --git a/docs/commit.rst b/docs/commit.rst deleted file mode 100644 index 3fdf375..0000000 --- a/docs/commit.rst +++ /dev/null @@ -1,4 +0,0 @@ -Commit -====== - -.. autoclass:: gitteh::Commit diff --git a/docs/conf.py b/docs/conf.py deleted file mode 100644 index 20a17e8..0000000 --- a/docs/conf.py +++ /dev/null @@ -1,253 +0,0 @@ -# -*- coding: utf-8 -*- -# -# node-gitteh documentation build configuration file, created by -# sphinx-quickstart on Tue Jul 23 14:08:21 2013. -# -# This file is execfile()d with the current directory set to its containing dir. -# -# Note that not all possible configuration values are present in this -# autogenerated file. -# -# All configuration values have a default; values that are commented out -# serve to show the default. - -import sys, os - -# If extensions (or modules to document with autodoc) are in another directory, -# add these directories to sys.path here. If the directory is relative to the -# documentation root, use os.path.abspath to make it absolute, like shown here. -#sys.path.insert(0, os.path.abspath('.')) - -# -- General configuration ----------------------------------------------------- - -# If your documentation needs a minimal Sphinx version, state it here. -#needs_sphinx = '1.0' - -# Add any Sphinx extension module names here, as strings. They can be extensions -# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. -extensions = ["sphinx.ext.autodoc", "sphinxcontrib.coffeedomain"] - -coffee_src_dir = os.path.abspath('../src') - -# Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] - -# The suffix of source filenames. -source_suffix = '.rst' - -# The encoding of source files. -#source_encoding = 'utf-8-sig' - -# The master toctree document. -master_doc = 'index' - -# General information about the project. -project = u'node-gitteh' -copyright = u'2013, Sam Day' - -# The version info for the project you're documenting, acts as replacement for -# |version| and |release|, also used in various other places throughout the -# built documents. -# -# The short X.Y version. -version = '0.17.2' -# The full version, including alpha/beta/rc tags. -release = '0.17.2' - -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -#language = None - -# There are two options for replacing |today|: either, you set today to some -# non-false value, then it is used: -#today = '' -# Else, today_fmt is used as the format for a strftime call. -#today_fmt = '%B %d, %Y' - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -exclude_patterns = ['_build'] - -# The reST default role (used for this markup: `text`) to use for all documents. -#default_role = None - -# If true, '()' will be appended to :func: etc. cross-reference text. -#add_function_parentheses = True - -# If true, the current module name will be prepended to all description -# unit titles (such as .. function::). -#add_module_names = True - -# If true, sectionauthor and moduleauthor directives will be shown in the -# output. They are ignored by default. -#show_authors = False - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' - -# A list of ignored prefixes for module index sorting. -#modindex_common_prefix = [] - -# If true, keep warnings as "system message" paragraphs in the built documents. -#keep_warnings = False - - -# -- Options for HTML output --------------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -html_theme = 'default' - -# Theme options are theme-specific and customize the look and feel of a theme -# further. For a list of options available for each theme, see the -# documentation. -#html_theme_options = {} - -# Add any paths that contain custom themes here, relative to this directory. -#html_theme_path = [] - -# The name for this set of Sphinx documents. If None, it defaults to -# " v documentation". -#html_title = None - -# A shorter title for the navigation bar. Default is the same as html_title. -#html_short_title = None - -# The name of an image file (relative to this directory) to place at the top -# of the sidebar. -#html_logo = None - -# The name of an image file (within the static path) to use as favicon of the -# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 -# pixels large. -#html_favicon = None - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] - -# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, -# using the given strftime format. -#html_last_updated_fmt = '%b %d, %Y' - -# If true, SmartyPants will be used to convert quotes and dashes to -# typographically correct entities. -#html_use_smartypants = True - -# Custom sidebar templates, maps document names to template names. -#html_sidebars = {} - -# Additional templates that should be rendered to pages, maps page names to -# template names. -#html_additional_pages = {} - -# If false, no module index is generated. -#html_domain_indices = True - -# If false, no index is generated. -#html_use_index = True - -# If true, the index is split into individual pages for each letter. -#html_split_index = False - -# If true, links to the reST sources are added to the pages. -#html_show_sourcelink = True - -# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -#html_show_sphinx = True - -# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -#html_show_copyright = True - -# If true, an OpenSearch description file will be output, and all pages will -# contain a tag referring to it. The value of this option must be the -# base URL from which the finished HTML is served. -#html_use_opensearch = '' - -# This is the file name suffix for HTML files (e.g. ".xhtml"). -#html_file_suffix = None - -# Output file base name for HTML help builder. -htmlhelp_basename = 'node-gittehdoc' - - -# -- Options for LaTeX output -------------------------------------------------- - -latex_elements = { -# The paper size ('letterpaper' or 'a4paper'). -#'papersize': 'letterpaper', - -# The font size ('10pt', '11pt' or '12pt'). -#'pointsize': '10pt', - -# Additional stuff for the LaTeX preamble. -#'preamble': '', -} - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, author, documentclass [howto/manual]). -latex_documents = [ - ('index', 'node-gitteh.tex', u'node-gitteh Documentation', - u'Sam Day', 'manual'), -] - -# The name of an image file (relative to this directory) to place at the top of -# the title page. -#latex_logo = None - -# For "manual" documents, if this is true, then toplevel headings are parts, -# not chapters. -#latex_use_parts = False - -# If true, show page references after internal links. -#latex_show_pagerefs = False - -# If true, show URL addresses after external links. -#latex_show_urls = False - -# Documents to append as an appendix to all manuals. -#latex_appendices = [] - -# If false, no module index is generated. -#latex_domain_indices = True - - -# -- Options for manual page output -------------------------------------------- - -# One entry per manual page. List of tuples -# (source start file, name, description, authors, manual section). -man_pages = [ - ('index', 'node-gitteh', u'node-gitteh Documentation', - [u'Sam Day'], 1) -] - -# If true, show URL addresses after external links. -#man_show_urls = False - - -# -- Options for Texinfo output ------------------------------------------------ - -# Grouping the document tree into Texinfo files. List of tuples -# (source start file, target name, title, author, -# dir menu entry, description, category) -texinfo_documents = [ - ('index', 'node-gitteh', u'node-gitteh Documentation', - u'Sam Day', 'node-gitteh', 'One line description of project.', - 'Miscellaneous'), -] - -# Documents to append as an appendix to all manuals. -#texinfo_appendices = [] - -# If false, no module index is generated. -#texinfo_domain_indices = True - -# How to display URL addresses: 'footnote', 'no', or 'inline'. -#texinfo_show_urls = 'footnote' - -# If true, do not generate a @detailmenu in the "Top" node's menu. -#texinfo_no_detailmenu = False - - -primary_domain = 'coffee' \ No newline at end of file diff --git a/docs/gitindex.rst b/docs/gitindex.rst deleted file mode 100644 index 5f8982a..0000000 --- a/docs/gitindex.rst +++ /dev/null @@ -1,4 +0,0 @@ -Index -===== - -.. autoclass:: gitteh::Index diff --git a/docs/index.html b/docs/index.html deleted file mode 100644 index 57f2a20..0000000 --- a/docs/index.html +++ /dev/null @@ -1,87 +0,0 @@ - - - - - - - CoffeeDoc - - - - - -
-

CoffeeDoc — Module Index

-
-
- -
- -
- -
- - -

Classes

- - - -

Functions

- - -
-
- -
-
- - diff --git a/docs/index.rst b/docs/index.rst deleted file mode 100644 index 06e9c74..0000000 --- a/docs/index.rst +++ /dev/null @@ -1,22 +0,0 @@ -.. node-gitteh documentation master file, created by - sphinx-quickstart on Tue Jul 23 14:08:21 2013. - You can adapt this file completely to your liking, but it should at least - contain the root `toctree` directive. - -Welcome to node-gitteh's documentation! -======================================= - -Contents: - -.. toctree:: - :maxdepth: 2 - - api - -Indices and tables -================== - -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` - diff --git a/docs/reference.rst b/docs/reference.rst deleted file mode 100644 index 4e0a4dc..0000000 --- a/docs/reference.rst +++ /dev/null @@ -1,4 +0,0 @@ -Reference -========= - -.. autoclass:: gitteh::Reference diff --git a/docs/refspec.rst b/docs/refspec.rst deleted file mode 100644 index 0ed64f4..0000000 --- a/docs/refspec.rst +++ /dev/null @@ -1,4 +0,0 @@ -Refspec -======= - -.. autoclass:: gitteh::Refspec diff --git a/docs/remote.rst b/docs/remote.rst deleted file mode 100644 index a0a1d54..0000000 --- a/docs/remote.rst +++ /dev/null @@ -1,4 +0,0 @@ -Remote -====== - -.. autoclass:: gitteh::Remote diff --git a/docs/repository.rst b/docs/repository.rst deleted file mode 100644 index 05e2b44..0000000 --- a/docs/repository.rst +++ /dev/null @@ -1,4 +0,0 @@ -Repository -========== - -.. autoclass:: gitteh::Repository diff --git a/docs/resources/base.css b/docs/resources/base.css deleted file mode 100644 index a362b1b..0000000 --- a/docs/resources/base.css +++ /dev/null @@ -1,396 +0,0 @@ -/* - * Skeleton V1.1 - * Copyright 2011, Dave Gamache - * www.getskeleton.com - * Free to use under the MIT license. - * http://www.opensource.org/licenses/mit-license.php - * 8/17/2011 - */ - - -/* #Reset & Basics (Inspired by E. Meyers) -================================================== */ - html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video { - margin: 0; - padding: 0; - border: 0; - font-size: 100%; - font: inherit; - vertical-align: baseline; } - article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section { - display: block; } - body { - line-height: 1; } - ol, ul { - list-style: none; } - blockquote, q { - quotes: none; } - blockquote:before, blockquote:after, - q:before, q:after { - content: ''; - content: none; } - table { - border-collapse: collapse; - border-spacing: 0; } - - -/* #Basic Styles -================================================== */ - body { - background: #fff; - font: 14px/21px "Helvetica Neue", Helvetica, Arial, sans-serif; - color: #444; - -webkit-font-smoothing: antialiased; /* Fix for webkit rendering */ - -webkit-text-size-adjust: 100%; - } - - -/* #Typography -================================================== */ - h1, h2, h3, h4, h5, h6 { - font-family: "Georgia", serif; - font-weight: normal; } - h1 a, h2 a, h3 a, h4 a, h5 a, h6 a { font-weight: inherit; } - h1 { font-size: 34px; line-height: 50px; margin-bottom: 14px;} - h2 { font-size: 28px; line-height: 40px; margin-bottom: 10px; } - h3 { font-size: 23px; line-height: 34px; margin-bottom: 8px; } - h4 { font-size: 19px; line-height: 30px; margin-bottom: 4px; } - h5 { font-size: 16px; line-height: 24px; } - h6 { font-size: 14px; line-height: 21px; } - - p { margin: 0 0 20px 0; } - p img { margin: 0; } - - em { font-style: italic; } - strong { font-weight: bold; color: #333; } - small { font-size: 80%; } - -/* Blockquotes */ - blockquote, blockquote p { font-size: 17px; line-height: 24px; color: #777; font-style: italic; } - blockquote { margin: 0 0 20px; padding: 9px 20px 0 19px; border-left: 1px solid #ddd; } - blockquote cite { display: block; font-size: 12px; color: #555; } - blockquote cite:before { content: "\2014 \0020"; } - blockquote cite a, blockquote cite a:visited, blockquote cite a:visited { color: #555; } - - hr { border: solid #ddd; border-width: 1px 0 0; clear: both; margin: 10px 0 30px; height: 0; } - - -/* #Links -================================================== */ - a, a:visited { - color: #2d81c5; - text-decoration: none; outline: 0; - -webkit-transition: color 250ms ease-in-out; - -moz-transition: color 250ms ease-in-out; - transition: color 250ms ease-in-out; - } - a:hover, a:focus { - color: #2569a0; - } - p a, p a:visited { line-height: inherit; } - - -/* #Lists -================================================== */ - ul, ol { margin-bottom: 20px; } - ul { list-style: none outside; } - ol { list-style: decimal; } - ol, ul.square, ul.circle, ul.disc { margin-left: 30px; } - ul.square { list-style: square outside; } - ul.circle { list-style: circle outside; } - ul.disc { list-style: disc outside; } - ul ul, ul ol, - ol ol, ol ul { margin: 4px 0 5px 30px; font-size: 90%; } - ul ul li, ul ol li, - ol ol li, ol ul li { margin-bottom: 6px; } - li { line-height: 18px; margin-bottom: 12px; } - ul.large li { line-height: 21px; } - li p { line-height: 21px; } - - -/* #Images -================================================== */ - - img.scale-with-grid { - max-width: 100%; - height: auto; } - - -/* #Misc -================================================== */ - .remove-bottom { margin-bottom: 0 !important; } - .half-bottom { margin-bottom: 10px !important; } - .add-bottom { margin-bottom: 20px !important; } - - -/* #Base 960 Grid -================================================== */ - - .container { position: relative; width: 960px; margin: 0 auto; padding: 0; } - .container .column { float: left; display: inline; margin-left: 10px; margin-right: 10px; } - .row { margin-bottom: 20px; } - - /* Base Grid */ - .container .sidebar.column { width: 220px; } - .container .content.column { width: 700px; } - - -/* #Tablet (Portrait) -================================================== */ - - /* Note: Design for a width of 768px */ - - @media only screen and (min-width: 768px) and (max-width: 959px) { - .container { width: 768px; } - .container .column { margin-left: 10px; margin-right: 10px; } - - .container .sidebar.column { width: 172px; } - .container .content.column { width: 556px; } - } - - -/* #Mobile (Portrait) -================================================== */ - - /* Note: Design for a width of 320px */ - - @media only screen and (max-width: 767px) { - .container { width: 300px; } - .container .column { margin: 0; } - - .container .sidebar.column, - .container .content.column { width: 300px; } - } - - -/* #Mobile (Landscape) -================================================== */ - - /* Note: Design for a width of 480px */ - - @media only screen and (min-width: 480px) and (max-width: 767px) { - .container { width: 420px; } - .container .column { margin: 0; } - - .container .sidebar.column, - .container .content.column { width: 420px; } - } - - -/* #Clearing -================================================== */ - - /* Self Clearing Goodness */ - .container:after { content: "\0020"; display: block; height: 0; clear: both; visibility: hidden; } - - -/* #CoffeeDoc styles -================================================== */ - -code { - color: #000; - background: #f6f6f6; - padding: 2px 4px; - border: 1px solid #ccc; - font-size: 12px; line-height: 18px; - font-family: Monaco, Consolas, "Lucida Console", monospace; - border-radius: 2px; -} -pre code { - display: block; - border-radius: 4px; - margin-bottom: 20px; - padding: 10px; -} -header { - width: 100%; - border-bottom: 1px solid #bbb; - margin-bottom: 20px; - background-image: -webkit-linear-gradient(top, #fff, #d0d0d0); - background-image: -moz-linear-gradient(top, #fff, #d0d0d0); - background-image: linear-gradient(top, #fff, #d0d0d0); -} -header h1 { - margin: 0; - line-height: 50px; - font-size: 20px; - text-align: center; -} -h1, h2 { - border-bottom: 1px solid #ccc; -} -h3 { - border-bottom: 1px solid #ddd; -} - - -/* #Module index -================================================== */ - -.module { - margin-bottom: 25px; -} -.module .header h1 { - margin-bottom: 20px; - border-bottom: none; - box-shadow: 0 5px 5px -6px rgba(45, 129, 197, 0.4); - -webkit-transition: box-shadow 250ms ease-in-out; - -moz-transition: box-shadow 250ms ease-in-out; - transition: box-shadow 250ms ease-in-out; -} -.module .header h1:hover { - box-shadow: 0 5px 5px -6px rgb(45, 129, 197); -} -.module-content h1 { - font-size: 30px; - line-height: 44px; -} - - -/* #Module pages -================================================== */ - -.function, .class { - margin-bottom: 30px; -} -.method { - margin-bottom: 20px; -} -.class .header { - border-bottom: 1px solid #ccc; - margin-bottom: 10px; -} -.class .header h3 { - display: inline; - border: none; -} -.class .header .parent { - color: #aaa; -} -.class .header .parent:hover { - color: #2569a0; -} - - -/* #Syntax highlighting -============================================================== */ - -/* github.com style (c) Vasily Polovnyov */ - -pre .comment, -pre .template_comment, -pre .diff .header, -pre .javadoc { - color: #998; - font-style: italic -} - -pre .keyword, -pre .css .rule .keyword, -pre .winutils, -pre .javascript .title, -pre .lisp .title, -pre .subst { - color: #000; - font-weight: bold -} - -pre .number, -pre .hexcolor { - color: #40a070 -} - -pre .string, -pre .tag .value, -pre .phpdoc, -pre .tex .formula { - color: #d14 -} - -pre .title, -pre .id { - color: #900; - font-weight: bold -} - -pre .javascript .title, -pre .lisp .title, -pre .subst { - font-weight: normal -} - -pre .class .title, -pre .haskell .label, -pre .tex .command { - color: #458; - font-weight: bold -} - -pre .tag, -pre .tag .title, -pre .rules .property, -pre .django .tag .keyword { - color: #000080; - font-weight: normal -} - -pre .attribute, -pre .variable, -pre .instancevar, -pre .lisp .body { - color: #008080 -} - -pre .regexp { - color: #009926 -} - -pre .class { - color: #458; - font-weight: bold -} - -pre .symbol, -pre .ruby .symbol .string, -pre .ruby .symbol .keyword, -pre .ruby .symbol .keymethods, -pre .lisp .keyword, -pre .tex .special, -pre .input_number { - color: #990073 -} - -pre .builtin, -pre .built_in, -pre .lisp .title { - color: #0086b3 -} - -pre .preprocessor, -pre .pi, -pre .doctype, -pre .shebang, -pre .cdata { - color: #999; - font-weight: bold -} - -pre .deletion { - background: #fdd -} - -pre .addition { - background: #dfd -} - -pre .diff .change { - background: #0086b3 -} - -pre .chunk { - color: #aaa -} - -pre .tex .formula { - opacity: 0.5; -} diff --git a/docs/signature.rst b/docs/signature.rst deleted file mode 100644 index 6af5fb7..0000000 --- a/docs/signature.rst +++ /dev/null @@ -1,4 +0,0 @@ -Signature -========= - -.. autoclass:: gitteh::Signature diff --git a/docs/tag.rst b/docs/tag.rst deleted file mode 100644 index b0358b5..0000000 --- a/docs/tag.rst +++ /dev/null @@ -1,4 +0,0 @@ -Tag -=== - -.. autoclass:: gitteh::Tag diff --git a/docs/tree.rst b/docs/tree.rst deleted file mode 100644 index 9194f0f..0000000 --- a/docs/tree.rst +++ /dev/null @@ -1,4 +0,0 @@ -Tree -==== - -.. autoclass:: gitteh::Tree diff --git a/examples/clone.js b/examples/clone.js deleted file mode 100644 index 215591d..0000000 --- a/examples/clone.js +++ /dev/null @@ -1,25 +0,0 @@ -var gitteh = require("../lib/gitteh"); -var path = require("path"); -var temp = require("temp"); - -var repoPath = temp.mkdirSync(); -var repo = "http://github.com/libgit2/node-gitteh.git"; - -console.log("Cloning " + repo + " into " + repoPath); -var clone = gitteh.clone(repo, repoPath); - -clone.on("status", function(bytes, total, done) { - var updateString = "Transferred " + bytes + " bytes."; - if(done > 0) updateString += " (" + done + "/" + total + " objects )" - process.stdout.write("\r" + updateString); -}); - -clone.on("complete", function(repo) { - console.log("\n... Complete!"); - console.log(repo); -}); - -clone.on("error", function(err) { - console.log("\n... Error during clone!"); - console.error(err); -}); \ No newline at end of file diff --git a/examples/display-commit-tree.js b/examples/display-commit-tree.js deleted file mode 100644 index 4f2ac36..0000000 --- a/examples/display-commit-tree.js +++ /dev/null @@ -1,40 +0,0 @@ -/** - * This example will load the Git repository for gitteh, and display the commit - * tree of the latest revision. You have to have cloned the gitteh Git repo for - * this to work, of course. - */ - -var gitteh = require("gitteh"), - path = require("path"), - fs = require("fs"); - -var repository = gitteh.openRepository(path.join(__dirname, "..", ".git")); -var headRef = repository.getReference("HEAD"); -headRef = headRef.resolve(); - -var commit = repository.getCommit(headRef.target); - -var displayTreeContents = function(treeId, tabs) { - var tree = repository.getTree(treeId); - - var tabStr = ""; for(var i = 0; i < tabs; i++) tabStr += " "; - - for(var i = 0, len = tree.entries.length; i < len; i++) { - var entry = tree.entries[i]; - var line = tabStr ; - line += entry.name; - - // 16384 == 40000 in octal (which is directory attribute in Git). - if(entry.attributes == 16384) { - line += "/"; - console.log(line); - displayTreeContents(entry.id, tabs + 1); - } - else { - //line += " - " + entry.id; - console.log(line); - } - } -}; - -displayTreeContents(commit.tree, 1); diff --git a/examples/load_blob.js b/examples/load_blob.js deleted file mode 100644 index d995d48..0000000 --- a/examples/load_blob.js +++ /dev/null @@ -1,10 +0,0 @@ -var gitteh = require("../lib/gitteh"), - path = require("path"); - -gitteh.openRepository(path.join(__dirname, ".."), function(err, repo) { - repo.blob("aa4306ebb3e97b8ec76136feab1bb5fcd096b28a", function(err, blob) { - if(err) return console.error(err); - console.log(blob); - console.log(blob.data.toString("UTF-8")); - }); -}); diff --git a/examples/load_commit.js b/examples/load_commit.js deleted file mode 100644 index 96c58ca..0000000 --- a/examples/load_commit.js +++ /dev/null @@ -1,8 +0,0 @@ -var gitteh = require("../lib/gitteh"); -var path = require("path"); - -gitteh.openRepository(path.join(__dirname, ".."), function(err, repo) { - repo.commit("8a916d5fbce49f5780668a1ee780e0ef2e89360f", function (err, commit) { - console.log(commit); - }); -}); diff --git a/examples/load_commit_tree.js b/examples/load_commit_tree.js deleted file mode 100644 index 81cca44..0000000 --- a/examples/load_commit_tree.js +++ /dev/null @@ -1,10 +0,0 @@ -var gitteh = require("../lib/gitteh"); -var path = require("path"); - -gitteh.openRepository(path.join(__dirname, ".."), function(err, repo) { - repo.commit("8a916d5fbce49f5780668a1ee780e0ef2e89360f", function (err, commit) { - commit.tree(function(err, tree) { - console.log(tree.entries); - }); - }); -}); diff --git a/examples/load_reference.js b/examples/load_reference.js deleted file mode 100644 index eab8385..0000000 --- a/examples/load_reference.js +++ /dev/null @@ -1,8 +0,0 @@ -var gitteh = require("../lib/gitteh"), - path = require("path"); - -gitteh.openRepository(path.join(__dirname, ".."), function(err, repo) { - repo.ref("HEAD", true, function(err, ref) { - console.log(ref); - }); -}); diff --git a/examples/load_repository.js b/examples/load_repository.js deleted file mode 100644 index ca02262..0000000 --- a/examples/load_repository.js +++ /dev/null @@ -1,7 +0,0 @@ -var gitteh = require("../lib/gitteh"); -var path = require("path"); - -gitteh.openRepository(path.join(__dirname, ".."), function(err, repo) { - exports.repo = repo; - console.log(repo); -}); diff --git a/examples/load_tag.js b/examples/load_tag.js deleted file mode 100644 index 9fa7b0c..0000000 --- a/examples/load_tag.js +++ /dev/null @@ -1,15 +0,0 @@ -var gitteh = require("../lib/gitteh"), - path = require("path"); - -gitteh.openRepository(path.join(__dirname, ".."), function(err, repo) { - repo.tag("5eab735c859e9d808204532061a4316ea7d6b57a", function(err, tag) { - if(err) return console.error(err); - - console.log(tag); - - tag.target(function(err, obj) { - if(err) return console.error(err); - console.log(obj); - }); - }); -}); diff --git a/examples/show_remote.js b/examples/show_remote.js deleted file mode 100644 index af9b00a..0000000 --- a/examples/show_remote.js +++ /dev/null @@ -1,17 +0,0 @@ -var gitteh = require("../lib/gitteh"); -var path = require("path"); - -gitteh.openRepository(path.join(__dirname, ".."), function(err, repo) { - exports.repo = repo; - - repo.remote("test", function(err, remote) { - exports.remote = remote; - - remote.connect("fetch", function(err) { - if(err) return console.error(err); - console.log(remote); - console.log(remote.connected); - console.log(remote.refs); - }); - }); -}); diff --git a/examples/walk-revisions.js b/examples/walk-revisions.js deleted file mode 100644 index 83e936e..0000000 --- a/examples/walk-revisions.js +++ /dev/null @@ -1,63 +0,0 @@ -/** - * This example will open the Gitteh Git repo and walk the entire revision - * history, displaying a screen output fairly similar to what you'd get when you - * run `git log`. - */ -var gitteh = require("gitteh"), - path = require("path"), - fs = require("fs"); - -var startTime = Date.now(); - -// Load up the node-gitteh repository. This will only work if you cloned the -// repo of course. -// You can point this to anywhere that is housing a git repo, even a bare one. -// You have to point it to the GIT directory though, so if you're working with -// a repo that has a working copy checked out, you need to point it to the .git -// folder. -var repository = gitteh.openRepository(path.join(__dirname, "..", ".git")); - -// First step is to grab the HEAD commit. We use the ref management features of -// gitteh to achieve this. -var headRef = repository.getReference("HEAD"); - -// Just in case the reference is pointing to another reference (symbolic link), -// we "resolve" the reference to a direct reference (one that points to an OID). -// If the ref being pointed to by HEAD is already direct, then resolve does -// nothing but return the same reference. -headRef = headRef.resolve(); - -// Let's create a revision walker and traverse the entire commit history. -var walker = repository.createWalker(); - -// Let's push the head commit onto the revision walker and start walkin'! - -// This will sort our commits by time. They can also be sorted "topologically", -// which will prioritize parents before children. Also SORT_REVERSE can be -// added to sorting, which will reverse all sorting options chosen. - -// This will start from the most recent commit, and go back in time. -// Note that you have to set sorting BEFORE you push a commit to traverse from. -walker.sort(gitteh.GIT_SORT_TIME); -walker.push(headRef.target); - -// This output basically mimicks a basic `git log` command. -var commit; -while(commit = walker.next()) { - console.log("commit " + commit.id); - - console.log("Author: " + commit.author.name + " <" + - commit.author.email + ">"); - - if((commit.committer.name != commit.author.name) || - (commit.committer.email != commit.author.email)) { - console.log("Committer: " + commit.committer.name + " <" + - commit.committer.email + ">"); - } - - console.log("Date: " + commit.committer.time.toUTCString()); - - console.log("\n " + commit.message + "\n"); -} - -console.log((Date.now() - startTime) + "ms"); \ No newline at end of file diff --git a/install.js b/install.js deleted file mode 100644 index c31fc10..0000000 --- a/install.js +++ /dev/null @@ -1,77 +0,0 @@ -var async = require("async"), - child_process = require("child_process"), - spawn = child_process.spawn, - path = require("path"), - request = require('request'), - fs = require('fs'), - tar = require('tar'), - zlib = require('zlib'); - -function passthru() { - var args = Array.prototype.slice.call(arguments); - var cb = args.splice(-1)[0]; - var cmd = args.splice(0, 1)[0]; - var opts = {}; - if(typeof(args.slice(-1)[0]) === "object") { - opts = args.splice(-1)[0]; - } - var child = spawn(cmd, args, opts); - - child.stdout.pipe(process.stdout); - child.stderr.pipe(process.stderr); - child.on("exit", cb); -} - -function shpassthru() { - var cmd = - passthru.apply(null, ["/bin/sh", "-c"].concat(Array.prototype.slice.call(arguments))); -} - -function envpassthru() { - passthru.apply(null, ["/usr/bin/env"].concat(Array.prototype.slice.call(arguments))); -} - -var libgit2Dir = path.join(__dirname, "deps/libgit2"); -var buildDir = path.join(libgit2Dir, "build"); -async.series([ - function(cb) { - console.log("[gitteh] Downloading libgit2 dependency."); - if (fs.existsSync(path.join(__dirname, '.git'))) { - console.log("[gitteh] ...via git submodule"); - envpassthru("git", "submodule", "update", "--init", cb); - } else { - console.log("[gitteh] ...via tarball"); - var libgit2Version = "v0.19.0"; - var url = "https://github.com/libgit2/libgit2/tarball/" + libgit2Version; - request({url: url}) - .pipe(zlib.createUnzip()) - .pipe(tar.Extract({ - path: libgit2Dir, - strip: true - })).on('end', cb); - } - }, - function(cb) { - console.log("[gitteh] Building libgit2 dependency."); - envpassthru("mkdir", "-p", buildDir, cb); - }, - function(cb) { - envpassthru("cmake", "-DCMAKE_C_FLAGS='-fPIC'", "-DTHREADSAFE=1", "-DBUILD_CLAR=0", "..", { - cwd: buildDir - }, cb); - }, - function(cb) { - envpassthru("cmake", "--build", ".", { - cwd: buildDir - }, cb); - }, - function(cb) { - console.log("[gitteh] Building native module."); - shpassthru("./node_modules/.bin/node-gyp configure", cb); - }, - function(cb) { - shpassthru("./node_modules/.bin/node-gyp build", cb); - } -], function(err) { - if(err) process.exit(err); -}); diff --git a/lib/args.js b/lib/args.js new file mode 100644 index 0000000..be21735 --- /dev/null +++ b/lib/args.js @@ -0,0 +1,115 @@ +(function() { + var fn, objectTypes, oidRegex, remoteDirs, + __hasProp = Object.prototype.hasOwnProperty; + + module.exports = fn = function(params) { + var arg, argn, args, i, left, leftRequired, name, numRequired, param, paramList, ret, right, rightRequired, _len, _len2, _len3; + paramList = (function() { + var _results; + _results = []; + for (name in params) { + if (!__hasProp.call(params, name)) continue; + param = params[name]; + param.name = name; + _results.push(param); + } + return _results; + })(); + ret = []; + numRequired = 0; + leftRequired = (function() { + var _i, _len, _results; + _results = []; + for (_i = 0, _len = paramList.length; _i < _len; _i++) { + param = paramList[_i]; + if (param.hasOwnProperty("default")) break; + numRequired++; + _results.push(param); + } + return _results; + })(); + paramList.splice(0, leftRequired.length); + rightRequired = (function() { + var _i, _len, _ref, _results; + _ref = paramList.slice(0).reverse(); + _results = []; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + param = _ref[_i]; + if (param.hasOwnProperty("default")) break; + numRequired++; + _results.push(param); + } + return _results; + })(); + rightRequired = rightRequired.reverse(); + paramList.splice(-rightRequired.length); + args = Array.prototype.slice.call(fn.caller.arguments); + if (args.length < numRequired) throw new Error("Not enough arguments."); + left = args.splice(0, leftRequired.length); + right = args.splice(-rightRequired.length); + argn = 0; + for (i = 0, _len = left.length; i < _len; i++) { + arg = left[i]; + argn++; + param = leftRequired[i]; + if (!fn.validators[param.type](arg)) { + throw new TypeError("" + param.name + " (" + argn + ") is not a valid " + param.type); + } + ret.push(arg); + } + for (i = 0, _len2 = paramList.length; i < _len2; i++) { + param = paramList[i]; + argn++; + if (args.length > i) { + arg = args[i]; + if (!fn.validators[param.type](arg)) { + throw new TypeError("" + param.name + " (" + argn + ") is not a valid " + param.type); + } + ret.push(arg); + } else { + ret.push(param["default"]); + } + } + for (i = 0, _len3 = right.length; i < _len3; i++) { + arg = right[i]; + argn++; + param = rightRequired[i]; + if (!fn.validators[param.type](arg)) { + throw new TypeError("" + param.name + " (" + argn + ") is not a valid " + param.type); + } + ret.push(arg); + } + return ret; + }; + + fn.oidRegex = oidRegex = /^[a-zA-Z0-9]{0,40}$/; + + objectTypes = ["any", "blob", "commit", "tag", "tree"]; + + remoteDirs = ["push", "fetch"]; + + fn.validators = { + string: function(val) { + return typeof val === "string"; + }, + "function": function(val) { + return typeof val === "function"; + }, + bool: function(val) { + return typeof val === "boolean"; + }, + oid: function(val) { + if (typeof val !== "string") return false; + if (!oidRegex.test(val)) return false; + if (val.length < fn.minOidLength) return false; + return true; + }, + objectType: function(val) { + return objectTypes.indexOf(val > -1); + }, + remoteDir: function(val) { + return remoteDirs.indexOf(val > -1); + } + }; + +}).call(this); diff --git a/lib/bindings/bindings.js b/lib/bindings/bindings.js deleted file mode 100644 index 1d86fcc..0000000 --- a/lib/bindings/bindings.js +++ /dev/null @@ -1,674 +0,0 @@ -/** - * @fileOverview This is just an empty file containing JSDoc markup to generate nice documentation for stuff that is actually implemented in C++. - * @author Sam Day - * @version 0.1.0 - */ - -/** - * Represents an open Git repository. The majority of the functionality offered - * by Gitteh is contained in here. - * @class - */ -var Repository = function() {}; - -/** - * This is the namespace of the Gitteh module. - * @namespace - * @example - * var gitteh = require("gitteh"); - */ -var Gitteh = { }; - -/** - * Opens a Git repository at the location provided. You can either provide a - * path to a Git repository, which will open the repository "bare" (no working - * directory), or you can provide an object containing paths to the various - * critical Git directories needed for Git to operate. - * @param {String|Object} path - * @param {String} path.gitDirectory The path to the Git repository folder (e.g /foo/.git) - * @param {String} [path.workTree] The path to the Git working directory (e.g /foo). Omitting this will assume the repository is bare. - * @param {String} [path.objectDirectory] The path to the ODB directory (e.g /foo/.git/objects). Omitting this will default to path.gitDirectory + "/objects" - * @param {String} [path.indexFile] The path to the repository index file (e.g /foo/.git/index). Omitting this will default to path.gitDirectory + "/index" - * @param {Function} [callback] If provided, the repository will be opened asynchronously, and the provided callback will be fired when the repository has been opened. - * @returns {Repository} - * @throws If the path provided is incorrect, or the repository is corrupt in some way. - */ -Gitteh.openRepository = function(path) { }; - -/** - * Creates a new Git repository at the provided path. The repository will be - * created at the path provided, unless bare is set to true, in which case the - * repository will be initialized in a .git directory inside the path - * provided. - * @param {String} path The path to initialize the new Git repository in. - * @param {Boolean} [bare] Initialize the repository as bare or "checked out". - * @param {Function} [callback] If provided, the repository will be created asynchronously. The provided callback will be fired when the repository has been created. - */ -Gitteh.initRepository = function(path, bare, callback) { }; - -/** - * Contains the various error constants found throughout Gitteh. - * @namespace - */ -Gitteh.error = { }; - -// Ffs. There's supposed to be a JSDoc "metatag" that allows me to define one -// set of tags and it will apply to everything that follows. It doesn't work. -// Hence the bullshit here. -/** - * @static - * @constant - */ -Gitteh.error.GIT_OK = undefined; -/** - * @static - * @constant - */ -Gitteh.error.GIT_ERROR = undefined; -/** - * @static - * @constant - */ -Gitteh.error.GIT_ENOTOID = undefined; -/** - * @static - * @constant - */ -Gitteh.error.GIT_ENOTFOUND = undefined; -/** - * @static - * @constant - */ -Gitteh.error.GIT_ENOMEM = undefined; -/** - * @static - * @constant - */ -Gitteh.error.GIT_EOSERR = undefined; -/** - * @static - * @constant - */ -Gitteh.error.GIT_EOBJTYPE = undefined; -/** - * @static - * @constant - */ -Gitteh.error.GIT_EOBJCORRUPTED = undefined; -/** - * @static - * @constant - */ -Gitteh.error.GIT_ENOTAREPO = undefined; -/** - * @static - * @constant - */ -Gitteh.error.GIT_EINVALIDTYPE = undefined; -/** - * @static - * @constant - */ -Gitteh.error.GIT_EMISSINGOBJDATA = undefined; -/** - * @static - * @constant - */ -Gitteh.error.GIT_EPACKCORRUPTED = undefined; -/** - * @static - * @constant - */ -Gitteh.error.GIT_EFLOCKFAIL = undefined; -/** - * @static - * @constant - */ -Gitteh.error.GIT_EZLIB = undefined; -/** - * @static - * @constant - */ -Gitteh.error.GIT_EBUSY = undefined; -/** - * @static - * @constant - */ -Gitteh.error.GIT_EBAREINDEX = undefined; -/** - * @static - * @constant - */ -Gitteh.error.GIT_EINVALIDREFNAME = undefined; -/** - * @static - * @constant - */ -Gitteh.error.GIT_EREFCORRUPTED = undefined; -/** - * @static - * @constant - */ -Gitteh.error.GIT_ETOONESTEDSYMREF = undefined; -/** - * @static - * @constant - */ -Gitteh.error.GIT_EPACKEDREFSCORRUPTED = undefined; -/** - * @static - * @constant - */ -Gitteh.error.GIT_EINVALIDPATH = undefined; -/** - * @static - * @constant - */ -Gitteh.error.GIT_EREVWALKOVER = undefined; -/** - * @static - * @constant - */ -Gitteh.error.GIT_EINVALIDREFSTATE = undefined; -/** - * @static - * @constant - */ -Gitteh.error.GIT_ENOTIMPLEMENTED = undefined; - -/** - * Retrieves a {@link Commit} from the repository with the given sha1 hash id. - * @param {String} sha1 The sha1 hash ID of the commit. - * @param {Function} [callback] If callback is provided, Vommit will be retrieved asynchronously and passed to to the callback provided. - * @return {Commit} - * @throws If commit wasn't found, or there is some other error. - */ -Repository.prototype.getCommit = function(sha1, callback) {}; - -/** - * Creates a new Commit and immediately stores it in the Repository. - * @param {Object} data The data for the commit. Should be the same properties that a {@link Commit} contains. - * @param {Function} [callback] If provided, the Commit will be created asynchronously, and the newly created Commit object returned to the callback. - * @throws If Commit couldn't be created. - */ -Repository.prototype.createCommit = function(data, callback) {}; - -/** - * Retrieves a {@link Tree} from the repository with the given sha1 hash id. - * @param {String} sha1 The sha1 hash ID of the tree. - * @param {Function} [callback] If a callback is provided, the Tree will be retrieved asynchronously and returned via the callback given. - * @return {Tree} - * @throws If Tree wasn't found, or some other error occurs. - */ -Repository.prototype.getTree = function(sha1, callback) {}; - -/** - * Creates a new {@link Tree} in the Repository with the given data. NOTE: - * this is currently unimplemented. - * @param {Object} data - * @param {Function} [callback] - */ -Repository.prototype.createTree = function(data, callback) {}; - -/** - * Retrieves a {@link Reference} from the Repository with the given name. - * @param {String} name The name of the reference, for example: refs/heads/master. You may also retrieve HEAD using this method. - * @param {Function} [callback] If provided, the reference will be obtained asychronously, and provided to the callback. - * @return {Reference} - * @throws If Reference does not exist, or some other error occured. - */ -Repository.prototype.getReference = function(name, callback) {}; - -/** - * Creates a new OID (direct) {@link Reference} in the Repository. - * @param {String} name The name of the Reference to be created. - * @param {String} oid The ID of the {@link Commit} being pointed to. - * @param {Function} [callback] When provided, the Reference shall be created asynchronously. The callback will be notified when creation is complete. - * @returns {Reference} - * @throws If there was an error creating the Reference. - */ -Repository.prototype.createOidReference = function(name, oid, callback) {}; - -/** - * Creates a new symbolic (indirect) {@link Reference} in the Repository. - * @param {String} name The name of the Reference to be created. - * @param {String} target The name of the Reference being pointed to. - * @param {Function} [callback] When provided, the Reference shall be created asynchronously. The callback will be notified when creation is complete. - * @returns {Reference} - * @throws If there was an error creating the Reference. - */ -Repository.prototype.createSymbolicReference = function(name, target, callback) {}; - -/** - * Requests a list of References from the Repository. This will return a list of - * Strings, each String is a name of a reference in the Repository. - * @param {Integer} [flags] If provided, the list will be filtered based on input. Valid values are {@link Gitteh.GIT_REF_OID}, {@link Gitteh.GIT_REF_SYMBOLIC}, {@link Gitteh.GIT_REF_PACKED}, and {@link Gitteh.GIT_REF_LISTALL} - * @param {Function} [callback] If provided, the list will be built asynchronously, and the results provided to the callback. - * @returns {String[]} - * @throws If an error occurs during the listing process. - * - * @see Gitteh.GIT_REF_OID - * @see Gitteh.GIT_REF_SYMBOLIC - * @see Gitteh.GIT_REF_PACKED - * @see Gitteh.GIT_REF_LISTALL - */ -Repository.prototype.listReferences = function(flags, callback) {}; - -/** - * Orders the Repository to pack all loose {@link Reference}s. This method will - * ensure any currently active {@link Reference}s remain valid (even though they - * have now been moved inside the packed-references file). - * @param {Function} [callback] If provided, the packing process will be performed asynchronously and the callback notified of the result. - * @returns {Boolean} true if successful - * @throws If an error occurs during the packing process. - */ -Repository.prototype.packReferences = function(callback) {}; - -/** - * Creates a new {@link RevisionWalker}. - * @param {Function} [callback] If provided, the walker will be created asychronously. - * @returns {RevisionWalker} - * @throws If an error occurs. - */ -Repository.prototype.createWalker = function(callback) {}; - -/** - * Loads the Index for the Repository. - * @param {Function} [callback] If provided, the Index will be loaded asynchronously, and the result handed to the callback. - * @returns {Index} - * @throws If an error occurred while loading Index. - */ -Repository.prototype.getIndex = function(callback) {}; - -/** - * Creates a new {@link Tag} with the provided data. - * @param {Object} data The data to be stored in the Tag. The fields in this object should be the same as the fields in a {@link Tag}. - * @param {Function} [callback] If provided, the tag will be created asynchronously and the newly created Tag provided to the callback. - * @return {Tag} - * @throws If an error occurred whilst creating the Tag. - */ -Repository.prototype.createTag = function(data, callback) {}; - -/** - * Gets a {@link Tag} from the Repository with the given sha1 hash id. - * @param {String} sha1 the sha1 hash ID of the Tag. - * @param {Function} [callback] When provided, the Tag will be retrieved asynchronously and results handed to the callback. - * @return {Tag} - * @throws If an error occurred while loading the Tag. - */ -Repository.prototype.getTag = function(sha1, callback) {}; - -/** - * Creates a new {@link Blob} in the Repository. - * @param {Object} data The data for the Blob. Valid fields in this data are the same as the fields in {@link Blob} - * @param {Function} [callback] If provided, the Blob will be created asynchronously, and the results passed to the callback. - * @returns {Blob} - * @throws If an error occurs while creating the Blob. - */ -Repository.prototype.createBlob = function(data, callback) {}; - -/** - * Retrieves a Blob from the Repository with given id. - * @param {String} sha1 The sha1 hash id of the blob. - * @param {Function} [callback] If provided, the Blob will be retrieved asynchronously, and provided to the callback. - * @returns {Blob} - * @throws If an error occurs while loading the Blob. - */ -Repository.prototype.getBlob = function(sha1, callback) {}; - -/** - * Checks if the Repository contains an object with the specified sha1 hash. - * @param {String} sha1 SHA1 hash id of the object being searched for. - * @param {Function} [callback] If provided, the search will be performed asynchronously, with the result passed back to callback. - * @returns {Boolean} true if object exists, false if not. - * @throws If an error occurs. - */ -Repository.prototype.exists = function(sha1, callback) {}; - -/** - * @class - * @property {String} id The id of the commit. This property is read-only. - * @property {String} message The commit message. - * @property {Signature} author The author of the commit. - * @property {Signature} committer The commit committer. - * @property {Tree} tree The tree associated with the commit. - * @property {Commit[]} parents The parents of this commit, if any. - * - * @see Repository#getCommit - * @see Repository#createCommit - */ -var Commit = function() {}; - -/** - * Saves the commit to the repository. This will update the {@link id} property - * when successful. - * @param {Function} [callback] If provided, commit will be saved asynchronously, and the result of the save will be passed to the callback. - * @return {Boolean} true if successful. - * @throws If the commit failed to save. - */ -Commit.prototype.save = function() {}; - -/** - * A Tree represents the snapshot of a repo for a specific {@link Commit}. - * @class - * @property {String} id The sha1 hash of this Tree. - * @property {TreeEntry[]} entries The entries contained in this Tree. - * - * @see Repository#getTree - * @see Repository#createTree - */ -var Tree = function() {}; - -/** - * Saves the Tree to the Repository. THIS IS UNIMPLEMENTED CURRENTLY - * @throws If called, because it's currently unimplemented. - */ -Tree.prototype.save = function() {}; - -/** - * A single entry in a {@link Tree}. Note this isn't a "real" class, as there's - * no constructor. Tree entries are just plain old Javascript objects. This is - * just here for reference. - * @class - * @property {String} id SHA1 hash of the {@link Blob} this entry points to. - * @property {String} name Filename of the entry. - * @property {Integer} attributes File attributes for the entry. - */ -var TreeEntry = function() {}; - -/** - * A reference serves as a pointer of sorts to a specific Commit. References can - * either be direct or symbolic. Direct references point to a commit - * OID, symbolic references point to other references (which may also be symbolic). - * @class - * @property {String} name The name of the reference - e.g refs/heads/master - * @property {String} type The type of reference this is. Can be either "oid" or "symbolic". CANNOT be changed. - * @property {String} target Either the SHA1 hash of the {@link Commit} being pointed to by this Reference, if it's type is "oid". If it's a symbolic Reference, this will point to another reference name. - * - * @see Repository#getReference - * @see Repository#createOidReference - * @see Repository#createSymbolicReference - */ -var Reference = function() {}; - -/** - * Renames this Reference. Name of the new Reference must not already exist in the Repository. - * @param {String} newName The new name. - * @param {Function} [callback] If provided, the rename will occur asynchronously, and the callback will be fired when rename has completed. - * @return {Boolean} true if successful. - * @throws If an error occurred during renaming process. - */ -Reference.prototype.rename = function(newName, callback) { }; - -/** - * Deletes the Reference permanently. Once deleted, the Reference will no longer - * be accessible from the Repository. It will be deleted from the filesystem - * also. If this Reference is involved in any symbolic link chains, they will - * become invalid. After calling this, any further calls on the Reference will - * throw an Error. - * @name Reference#delete - * @function - * @param {Function} [callback] If provided, the deletion will occur asynchronously and return the status of the delete to the callback. - * @return {Boolean} true if successful - * @throws If an error occurred while deleting the Reference. - */ -// Used @name tag because Eclipse linter doesn't like method name being "delete". -//Reference.prototype.delete = function(callback) { }; - -/** - * Resolves this Reference to a direct oid Reference. This means it will follow - * symbolic links until it arrives at the direct link pointing to a {@ link Commit}. - * Note that if you call this on a Reference that is already pointing to a Commit, it - * will just return the Reference. - * @param {Function} [callback] When given, the resolution will be done asynchronously and the resulting Reference passed to the callback. - * @return {Reference} The result of the resolution. - * @throws If an error occurred while resolving the Reference. - */ -Reference.prototype.resolve = function(callback) { }; - -/** - * Sets the target of this Reference. This change is immediate. Note: You - * can't change the type of a Reference. For example, if this Reference is an - * OID reference, you can't set the target to another Reference. If you need to - * do this, delete the original ref, and recreate it as the other type. - * @param {String} newTarget either the oid, or name of another Reference. - * @param {Function} [callback] If provided, the Reference will be re-targeted asynchronously. The callback will be notified when this occurs. - * @return {Boolean} true if successful. - * @throws If an error occurred while setting target. - */ -Reference.prototype.setTarget = function(newTarget, callback) { }; - -/** - * List OID (direct) References - * @static - */ -Gitteh.GIT_REF_OID = undefined; -/** - * List symbolic (indirect) References. - * @static - */ -Gitteh.GIT_REF_SYMBOLIC = undefined; -/** - * Include packed References in list. - * @static - */ -Gitteh.GIT_REF_PACKED = undefined; -/** - * List all References in the Repository. - * @static - */ -Gitteh.GIT_REF_LISTALL = undefined; - -/** - * A Blob is a binary store of a specific file that has been committed into a - * Repository at some point. - * @class - * @property {String} id The SHA1 id of the Blob. - * @property {Buffer} data The data this Blob contains. - * - * @see Repository#createBlob - * @see Repository#getBlob - */ -var Blob = function() {}; - -/** - * Saves this blob to Repository and updates its id. - * @param {Function} [callback] If provided, the save will be performed asynchronously, and the result passed to the callback. - * @return {Boolean} true if successful. - * @throws If save was not successful. - */ -Blob.prototype.save = function(callback) {}; - -/** - * The Index represents the cache Git stores for your working directory. When - * you "stage" a file in Git, this is basically just a command that will add - * or update your file in the Git index. Running a Commit in Git is essentially - * just writing a Commit with a Tree that matches an Index. Note: There - * will be a method soon to create a Tree from an opened Index, this feature has - * not yet been implemented by libgit2, as soon as it is it will be in Gitteh. - * @class - * @property {Integer} entryCount Read-only How many entries are contained in the Index. - * - * @see Repository#getIndex - */ -var Index = function() {}; - -/** - * Retrieves an {@link IndexEntry} from the Index. - * @param {Integer} index The index to retrieve. - * @param {Function} [callback] When provided, IndexEntry will be retrieved asynchronously and provided back to the callback. - * @return {IndexEntry} - * @throws If index is out of bounds, or some other error occurs. - */ -Index.prototype.getEntry = function(index, callback) {}; - -/** - * Searches the Index for an entry that matches the given filename. - * @param {String} [fileName] The filename of entry to search for. - * @param {Function} [callback] If provided, entry will be searched for in a non-blocking manner, and results returned to the callback. - * @return {IndexEntry} - * @throws If entry could not be found, or some other error occurs. - */ -Index.prototype.findEntry = function(fileName, callback) {}; - -/** - * Adds an entry to the Index for the given fileName. This file should already - * exist in the working directory of the Repository. Note: this function - * will fail if called on a Index for a bare repository, as it has no working - * directory. - * @param {String} fileName Name of the file to update index entry for. - * @param {Function} [callback] When provided, the callback will be notified when the entry has been added asynchronously. - * @returns {Boolean} true if successful - * @throws If there was an error adding the entry. - */ -Index.prototype.addEntry = function(fileName, callback) {}; - -/** - * Changes to an Index will not be updated on the actual index file until this - * method is called. - * @param {Function} [callback] When provided, the writeback will be performed in an asynchronous fashion, and the result will be passed back to the callback. - * @returns {Boolean} true if successful. - * @throws If there was an error writing the Index. - */ -Index.prototype.write = function(callback) {}; - -/** - * Represents a single entry in the Git {@link Index}. Note: While the - * constructor for this class is being exposed, it is not recommended to - * extend its functionality, as it may be removed altogether in a future release. - * @class - * @property {Date} ctime - * @property {Date} mtime - * @property {Integer} dev - * @property {Integer} ino - * @property {Integer} mode - * @property {Integer} uid - * @property {Integer} gid - * @property {Integer} file_size - * @property {String} oid - * @property {Integer} flags - * @property {Integer} flags_extended - * @property {String} path - */ -var IndexEntry = function() {}; - -/** - * A RevisionWalker provides a clean interface to walk the commit history of a - * {@link Repository}. A RevisionWalker may be obtained via {@link Repository#createWalker} - * @class - * - * @see Repository#createWalker - */ -var RevisionWalker = function() {}; - -/** - * Pushes a Commit onto the Revision Walker to begin the walking process. - * @param {String|Commit} commit The commit to push onto the walker. Can either be an sha1 id string, or a previously loaded Commit. - * @returns {Boolean} true if successful. - * @throws If there was an error pushing the Commit. - */ -RevisionWalker.prototype.push = function(commit, callback) {}; - -/** - * Hides a specific Commit (and all its ancestors/descendants) from the walker. - * @param {String|Commit} commit The commit to ignore. Can either be a sha1 id string, or a previously loaded Commit. - * @param {Function} [callback] If provided, the hide process will be performed in a non-blocking fashion, and the results passed back to the callback. - * @returns {Boolean} true if successful. - * @throws If there was an error hiding the Commit. - */ -RevisionWalker.prototype.hide = function(commit, callback) {}; - -/** - * Gets the next Commit in the queue from the RevisionWalker. - * @param {Function} [callback] If provided, the next Commit will be retrieved asynchronously, and the results passed back to callback. - * @returns {Commit} - * @throws If an error occurs while getting the next Commit. - */ -RevisionWalker.prototype.next = function(callback) {}; - -/** - * Sets a specific sorting method on the RevisionWalker. - * @param {Integer} sorting The sorting method to use on this walker. The valid values are {@link Gitteh.GIT_SORT_NONE}, {@link Gitteh.GIT_SORT_TOPOLOGICAL}, {@link Gitteh.GIT_SORT_TIME}, and {@link Gitteh.GIT_SORT_REVERSE}. - * @param {Function} [callback] If provided, walker will be configured with sorting options in a non-blocking manner, and the results of the operation passsed to the callback. - * @returns {Boolean} true if successful. - * @throws If an error occurred while setting sorting. - * @see Gitteh.GIT_SORT_NONE - * @see Gitteh.GIT_SORT_TOPOLOGICAL - * @see Gitteh.GIT_SORT_TIME - * @see Gitteh.GIT_SORT_REVERSE - */ -RevisionWalker.prototype.sort = function(sorting, callback) {}; - -/** - * Resets the RevisionWalker to an identity state ready to begin another walk. - * @param {Function} [callback] If provided, the walker will be reset asynchronously and the results passed to the callback. - * @returns {Boolean} true if successful. - * @throws If an error occurred. - */ -RevisionWalker.prototype.reset = function(callback) {}; - -/** - * @public - * @static - */ -Gitteh.GIT_SORT_NONE = undefined; -/** - * @public - * @static - */ -Gitteh.GIT_SORT_TOPOLOGICAL = undefined; -/** - * @public - * @static - */ -Gitteh.GIT_SORT_TIME = undefined; -/** - * @public - * @static - */ -Gitteh.GIT_SORT_REVERSE = undefined; - -/** - * @class - * @property {String} id Read-only The sha1 hash of this Tag. - * @property {String} message The message associated with this Tag. - * @property {String} name The name of this Tag. - * @property {Signature} tagger The person who created this Tag. - * @property {String} targetId The object this Tag is pointing at. - * @property {String} targetType The type of object this Tag is pointing at. - * - * @see Repository#getTag - * @see Repository#createTag - */ -var Tag = function() {}; - -/** - * Saves the data contained in this Tag and updates the ID. - * @param {Function} [callback] If provided, the Tag will be saved asynchronously and the results provided to the callback. - * @returns {Boolean} true if successful. - * @throws If an error occurs during save process. - */ -Tag.prototype.save = function(callback) {}; - -/** - * A Signature is used to store metadata about a person. It is used in {@link Commit}s - * and {@link Tag}s. Note that there is no actual constructor for a Signature, - * it's just a regular JS object. This documentation just serves as a guide to - * what properties should be in a Signature. - * @class - * @property {String} name - * @property {String} email - * @property {Date} time - * @property {Integer} timeOffset In seconds. e.g GMT+10 is stored as 600. - */ -var Signature = function() {}; - -/** - * Errors thrown by Gitteh will generally include additional data if it's a Git - * related issue. Note that there is no actual Error type called GitError, this - * is just for illustrative purposes only. - * @class - * @property {Integer} gitError The error number. The possible errors are detailed in {@link Gitteh.error}. - * @property {String} gitErrorStr A short message explaining the error. - */ -var GitError = function() {}; diff --git a/lib/gitteh.js b/lib/gitteh.js new file mode 100644 index 0000000..61f14f8 --- /dev/null +++ b/lib/gitteh.js @@ -0,0 +1,921 @@ +/* + This file provides wrappers for the actual native bindings and performs additional validation of arguments + and other types of error and exception handling that are more cumbersome to do in C++. You should require + this file rather than requiring the binary of the binding directly. +*/ + +(function() { + + EventEmitter = require("events").EventEmitter; + async = require("async"); + fs = require("fs"); + _path = require("path"); + args = require("./args"); + env = "Release"; + bindings = require("../build/" + env + "/gitteh"); + + var Blob, Commit, EventEmitter, Gitteh, Index, NativeRemote, NativeRepository, Reference, Refspec, Remote, Repository, Signature, Tag, Tree, args, async, bindings, env, fs, minOidLength, types, _createPrivate, _getPrivate, _immutable, _path, _wrapCallback, + + _this = this; + + if (env === "Debug") (require("segfault-handler")).registerHandler(); + + minOidLength = bindings.minOidLength, types = bindings.types, NativeRepository = bindings.NativeRepository, NativeRemote = bindings.NativeRemote; + + args.minOidLength = minOidLength; + + Gitteh = module.exports = {}; + + _getPrivate = function(obj) { + _getPrivate.lock++; + return obj._private; + }; + + _getPrivate.lock = 0; + + _createPrivate = function(obj) { + var _priv; + _priv = {}; + Object.defineProperty(obj, "_private", { + enumerable: false, + configurable: false, + get: function() { + if (!_getPrivate.lock--) throw new Error("Bad request"); + return _priv; + } + }); + return _priv; + }; + + _wrapCallback = function(orig, cb) { + return function(err) { + if (err != null) return orig(err); + return cb.apply(null, Array.prototype.slice.call(arguments, 1)); + }; + }; + + _immutable = function(obj, src) { + var o; + return o = { + set: function(name, target) { + if (target == null) target = name; + if (Array.isArray(src[name])) { + Object.defineProperty(obj, target, { + get: function() { + return src[name].slice(0); + }, + configurable: false, + enumerable: true + }); + return o; + } + Object.defineProperty(obj, target, { + value: src[name], + writable: false, + configurable: false, + enumerable: true + }); + return o; + } + }; + }; + + Gitteh.Signature = Signature = (function() { + /* + Contains the name/email/time for a :class:`gitteh::Commit` author/committer + or :class:`gitteh::Tag` tagger. + + Signatures contain the following *immutable* properties: + + - **name**: *(String)* + - **email**: *(String)* + - **time**: *(Date)* + - **offset**: *(Number)* timezone offset in seconds from GMT. + */ + function Signature(obj) { + _immutable(this, obj).set("name").set("email").set("time").set("offset"); + } + + return Signature; + + })(); + + Gitteh.Refspec = Refspec = (function() { + /* + Describes the way remote repository references will be mapped to the local + repository. + + For more information refer to http://git-scm.com/book/ch9-5.html + */ + function Refspec(src, dst) { + var _priv; + _priv = _createPrivate(this); + _priv.srcRoot = (src != null) && src.slice(-1) === "*" ? src.slice(0, -1) : src; + _priv.dstRoot = (dst != null) && dst.slice(-1) === "*" ? dst.slice(0, -1) : dst; + _immutable(this, { + src: src, + dst: dst + }).set("src").set("dst"); + } + + Refspec.prototype.matchesSrc = function(refName) { + /* + Returns true/false if given `refName` matches source of this Refspec. + */ + var _priv; + _priv = _getPrivate(this); + if (refName.length <= _priv.srcRoot.length) return false; + return refName.indexOf(_priv.srcRoot) === 0; + }; + + Refspec.prototype.matchesDst = function(refName) { + /* + Returns true/false if given `refName` matches destination of this + Refspec. + */ + var _priv; + _priv = _getPrivate(this); + if (refName.length <= _priv.dstRoot.length) return false; + return refName.indexOf(_priv.dstRoot) === 0; + }; + + Refspec.prototype.transformTo = function(refName) { + /* + Transforms given `refName` to destination, provided it matches src + pattern, and throws an error if it doesn't. + */ if (!this.matchesSrc(refName)) throw new Error("Ref doesn't match src."); + return "" + this.dst.slice(0, -2) + refName.slice(this.src.length - 2); + }; + + Refspec.prototype.transformFrom = function(refName) { + /* + Transforms provided refName from destination back to source, provided it + matches dst pattern, and throws an Error if it doesn't. This is the + reverse of :func:`gitteh::Refspec.transformTo` + */ if (!this.matchesDst(refName)) throw new Error("Ref doesn't match dst."); + return "" + this.src.slice(0, -2) + refName.slice(this.dst.length - 2); + }; + + return Refspec; + + })(); + + Gitteh.Commit = Commit = (function() { + /* + Commits, made by an author, and an optional different committer, contain a + message, an associated :class:`gitteh::Tree`, and zero or more parent + :class:`gitteh::Commit` objects. Zero parents generally indicate the initial + commit for the repository. More than one parent commits indicate a merge + commit. + + Properties: + + * **id**: *(String)* OID of this commit (SHA1 hash) + * **treeId**: *(String)* OID of associated :class:`gitteh::Tree` + * **parents**: *(String[]) list of parent commit OIDs + * **message**: *(String)* + * **messageEncoding**: *(???)* ??? TODO: + * **author**: (:class:`gitteh::Signature`) + * **committer**: (:class:`gitteh::Signature`) + */ + function Commit(repository, obj) { + this.repository = repository; + obj.author = new Signature(obj.author); + obj.committer = new Signature(obj.committer); + _immutable(this, obj).set("id").set("tree", "treeId").set("parents").set("message").set("messageEncoding").set("author").set("committer"); + } + + Commit.prototype.tree = function(cb) { + /* + Fetches the :class:`gitteh::Tree` for this Commit. Shortcut for calling + :func:`gitteh::Repository.tree` with this commits `treeId`. + */ return this.repository.tree(this.treeId, cb); + }; + + return Commit; + + })(); + + Gitteh.Tree = Tree = (function() { + /* + A Tree contains a list of named entries, which can either be + :class:`gitteh::Blob` objects or nested :class:`gitteh::Tree` objects. Each + entry is referenced by its OID. + + Properties: + + * **id**: *(String)* OID of this Tree. + * **entries**: *(TreeEntry[])* + + ## Tree Entries + + Each element of a Tree contains the following properties: + + * **id**: *(String)* OID this entry points to. + * **name**: *(String)* file name of this entry. + * **type**: *(String)* kind of object pointed to by this entry + * **attributes**: *(Number)* UNIX file attributes for this entry. + */ + function Tree(repository, obj) { + var entry, origEntry, _i, _len, _ref; + this.repository = repository; + obj._entries = obj.entries; + obj.entries = []; + _ref = obj._entries; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + origEntry = _ref[_i]; + obj.entries.push(entry = {}); + _immutable(entry, origEntry).set("id").set("name").set("type").set("attributes"); + } + _immutable(this, obj).set("id").set("entries"); + } + + return Tree; + + })(); + + Gitteh.Blob = Blob = (function() { + /* + Contains raw data for a file stored in Git. + + Properties: + + * **id**: *(String)* OID of this Blob. + * **data**: *(Buffer)* a standard Node buffer containing binary data. + */ + function Blob(repository, obj) { + this.repository = repository; + _immutable(this, obj).set("id").set("data"); + } + + return Blob; + + })(); + + Gitteh.Tag = Tag = (function() { + /* + Git tags are similar to references, and indeed "lightweight" Git tags are + actually implemented as :class:`gitteh::Reference` with a name prefix + of "tags/". When additional metadata is needed (message/name/email/GPG + signature), a proper heavyweight Tag object is used. + + Properties: + + * **id**: *(String)* OID of this Tag. + * **name**: *(String)* + * **message**: *(String)* + * **tagger**: *(Signature)* + * **targetId**: *(String)* OID this Tag points to + * **type**: *(String)* the type of object this Tag points to. + */ + function Tag(repository, obj) { + this.repository = repository; + obj.tagger = new Signature(obj.tagger); + _immutable(this, obj).set("id").set("name").set("message").set("tagger").set("target", "targetId").set("type"); + } + + Tag.prototype.target = function(cb) { + /* + Convenience method to get the object this Tag points to. Shorthand for + calling :func:`gitteh::Repository.object` with this *targetId* + */ return this.repository.object(this.targetId, this.type, cb); + }; + + return Tag; + + })(); + + Gitteh.Remote = Remote = (function() { + /* + Remotes designate the location and rules of remote Git repositories. Remotes + can be obtained by using :func:`gitteh::Repository.remote` + + Properties: + + * **connected**: *(Boolean)* true if there is an active connection to the Remotes' endpoint. + * **name**: *(String)* + * **url**: *(String)* address of Remotes' endpoint + * **fetchSpec**: (:class:`gitteh::Refspec`) Refspec used when fetching from Remote + * **pushSpec**: (:class:`gitteh::Refspec`) Refspec used when pushing to Remote + * **HEAD**: *(String)* the remote HEAD reference name (only set after connected to Remote) + * **refs**: *(String[])* names of references on remote (only set after connected to Remote) + */ + function Remote(repository, nativeRemote) { + var fetchSpec, pushSpec, _priv; + this.repository = repository; + _priv = _createPrivate(this); + _priv["native"] = nativeRemote; + _priv.connected = false; + if (!(nativeRemote instanceof NativeRemote)) { + throw new Error("Don't construct me, see Repository.remote()"); + } + Object.defineProperty(this, "connected", { + get: function() { + return _priv.connected; + }, + enumerable: true, + configurable: false + }); + _immutable(this, nativeRemote).set("name").set("url"); + fetchSpec = new Refspec(nativeRemote.fetchSpec.src, nativeRemote.fetchSpec.dst); + pushSpec = new Refspec(nativeRemote.pushSpec.src, nativeRemote.pushSpec.dst); + _immutable(this, { + fetchSpec: fetchSpec, + pushSpec: pushSpec + }).set("fetchSpec").set("pushSpec"); + } + + Remote.prototype.connect = function() { + /* + Opens a connection to the :class:`gitteh::Remote` endpoint. This is + needed before :func:`gitteh::Remote.fetch` or :func:`gitteh::Remote.push` + can be called. `direction` must be supplied as either "push" or "fetch" + and `cb` will be called once Remote is connected. + */ + var cb, dir, _priv, _ref, + _this = this; + _priv = _getPrivate(this); + _ref = args({ + dir: { + type: "remoteDir" + }, + cb: { + type: "function" + } + }), dir = _ref[0], cb = _ref[1]; + dir = dir === "push" ? bindings.GIT_DIRECTION_PUSH : bindings.GIT_DIRECTION_FETCH; + return _priv["native"].connect(dir, _wrapCallback(cb, function(refs) { + var headOid, headRef, oid, ref, refNames; + refNames = Object.keys(refs); + headOid = refs["HEAD"]; + for (ref in refs) { + oid = refs[ref]; + if (ref === "HEAD") continue; + if (oid === headOid) { + headRef = _this.fetchSpec.transformTo(ref); + _immutable(_this, { + headRef: headRef + }).set("headRef", "HEAD"); + break; + } + } + _immutable(_this, { + refNames: refNames + }).set("refNames", "refs"); + _priv.connected = true; + return cb(); + })); + }; + + Remote.prototype.fetch = function() { + /* + Fetches Git objects from remote that do not exist locally. `progressCb` + will be called regularly to notify callers of fetch progress and `cb` + will be called once fetch has completed. + */ + var cb, progressCb, update, updateTimer, _priv, _ref, + _this = this; + _priv = _getPrivate(this); + if (!this.connected) throw new Error("Remote isn't connected."); + _ref = args({ + progressCb: { + type: "function" + }, + cb: { + type: "function" + } + }), progressCb = _ref[0], cb = _ref[1]; + updateTimer = null; + update = function() { + var bytes, done, total, _ref2; + _ref2 = _priv["native"].stats, bytes = _ref2.bytes, total = _ref2.total, done = _ref2.done; + progressCb(bytes, total, done); + return updateTimer = setTimeout(update, 500); + }; + setTimeout(update, 500); + return _priv["native"].download(function(err) { + clearTimeout(updateTimer); + if (err != null) return cb(err); + return _priv["native"].updateTips(_wrapCallback(cb, function() { + return cb(); + })); + }); + }; + + return Remote; + + })(); + + Gitteh.Index = Index = (function() { + /* + The Git index is used to stage changed files before they are written to the + repository proper. Bindings for the Index are currently minimal, expect + this to change in a newer version. + */ + var write; + + function Index(nativeIndex) { + var _priv; + _priv = _createPrivate(this); + _priv["native"] = nativeIndex; + } + + Index.prototype.readTree = function() { + /* + Updates the Git index to reflect the state of provided + :class:`gitteh::Tree` (using OID passed from `id` parameter). `cb` will + be called once index update has completed. + */ + var cb, id, _priv, _ref; + _priv = _getPrivate(this); + _ref = args({ + id: { + type: "oid" + }, + cb: { + type: "function" + } + }), id = _ref[0], cb = _ref[1]; + return _priv["native"].readTree(id, cb); + }; + + Index.prototype.write = function() { + /* + Synchronizes the in-memory Git index with the indexfile located in + repository, and calls `cb` once synchronization is complete. + */ + var cb, _priv; + _priv = _getPrivate(this); + cb = args({ + cb: { + type: "function" + } + })[0]; + return _priv["native"].write(cb); + }; + + return Index; + + })(); + + Gitteh.Reference = Reference = (function() { + /* + A Reference is a named pointer to a :class:`gitteh::Commit` object. That is, + refs are the DNS of Git-land. References can either be direct or symbolic. + Direct references point to the object id of a commit. Symbolic refs point + to other references. + + References can be obtained using :func:`gitteh::Repository.reference` and + created using :func:`gitteh::Repository.createReference`. + + Properties: + + * **name**: *(String)* + * **direct**: *(Boolean)* true if Reference points directly to an object id. + * **packed**: *(Boolean)* true if Reference is in a packfile + * **target**: *(String)* object id reference points to, or another reference + name if not a direct reference. + * **repository**: (:class:`gitteh::Repository`) owner of this Reference. + */ + function Reference(repo, nativeRef) { + var _priv; + _priv = _createPrivate(this); + _priv["native"] = nativeRef; + _immutable(this, nativeRef).set("name").set("direct").set("packed").set("target"); + _immutable(this, { + repo: repo + }).set("repo", "repository"); + } + + return Reference; + + })(); + + Gitteh.Repository = Repository = (function() { + /* + Represents a local Git repository that has been opened by Gitteh. Objects + such as :class:`gitteh::Commit`, :class:`gitteh.Tree` and + :class:`gitteh.Reference` can be obtained and created from a Repository. + + Repositories can be *bare* - they will not have a working directory, in this + case the contents of what is usually in a .git subdirectory will be in the + top level. + + Properties: + + * **bare**: *(Boolean)* true if this repository is bare. + * **path**: *(String)* location of the Git metadata directory + * **workingDirectory**: *(String)* location of the working directory, if applicable (non-bare repository) + * **remotes**: *(String[])* names of remotes configured for this repository + * **references**: *(String[])* names of references contained in this repository. + * **index**: (:class:`gitteh::Index`) The Git index for this repository. + */ + function Repository(nativeRepo) { + var index, _priv; + if (!(nativeRepo instanceof NativeRepository)) { + throw new Error("Don't construct me, see gitteh.(open|init)Repository"); + } + _priv = _createPrivate(this); + _priv["native"] = nativeRepo; + _immutable(this, nativeRepo).set("bare").set("path").set("workDir", "workingDirectory").set("remotes").set("references").set("submodules"); + index = new Index(nativeRepo.index); + _immutable(this, { + index: index + }).set("index"); + } + + Repository.prototype.exists = function(oid, cb) { + /* + Checks if an object with given `oid` exists. Calls `cb` with result. + */ + var _priv, _ref; + _priv = _getPrivate(this); + _ref = args({ + oid: { + type: "oid" + }, + cb: { + type: "function" + } + }), oid = _ref[0], cb = _ref[1]; + return _priv["native"].exists(oid, cb); + }; + + Repository.prototype.object = function() { + /* + Fetches an object with given `oid` and returns the result to provided + `cb`. The object returned will be a Gitteh wrapper corresponding to the + type of Git object fetched. + + Alternatively, objects with an expected type can be fetched using the + :func:`gitteh::Repository.blob` :func:`gitteh::Repository.commit` + :func:`gitteh::Repository.tag` :func:`gitteh::Repository.tree` and + :func:`gitteh::Repository.reference` methods. + */ + var cb, oid, type, _priv, _ref, + _this = this; + _priv = _getPrivate(this); + _ref = args({ + oid: { + type: "oid" + }, + type: { + type: "objectType", + "default": "any" + }, + cb: { + type: "function" + } + }), oid = _ref[0], type = _ref[1], cb = _ref[2]; + return _priv["native"].object(oid, type, _wrapCallback(cb, function(object) { + var clazz; + clazz = (function() { + switch (object._type) { + case types.commit: + return Commit; + case types.tree: + return Tree; + case types.blob: + return Blob; + case types.tag: + return Tag; + default: + return; + } + })(); + if (clazz === void 0) return cb(new TypeError("Unexpected object type")); + return cb(null, new clazz(_this, object)); + })); + }; + + Repository.prototype.blob = function(oid, cb) { + /* + Fetches a :class:`gitteh::Blob` object with given `oid` from the + repository. This is a stricter variant of :func:`gitteh::Repository.object` + - an error will be thrown if requested object isnt a Blob. + */ return this.object(oid, "blob", cb); + }; + + Repository.prototype.commit = function(oid, cb) { + /* + Fetches a :class:`gitteh::Commit` object with given `oid` from the + repository. This is a stricter variant of :func:`gitteh::Repository.object` + - an error will be thrown if requested object isnt a Commit. + */ return this.object(oid, "commit", cb); + }; + + Repository.prototype.tag = function(oid, cb) { + /* + Fetches a :class:`gitteh::Tag` object with given `oid` from the + repository. This is a stricter variant of :func:`gitteh::Repository.object` + - an error will be thrown if requested object isnt a Tag. + */ return this.object(oid, "tag", cb); + }; + + Repository.prototype.tree = function(oid, cb) { + /* + Fetches a :class:`gitteh::Tree` object with given `oid` from the + repository. This is a stricter variant of :func:`gitteh::Repository.object` + - an error will be thrown if requested object isnt a Tree. + */ return this.object(oid, "tree", cb); + }; + + Repository.prototype.reference = function() { + /* + Fetches a :class:`gitteh::Reference` object with given `oid` from the + repository. This is a stricter variant of :func:`gitteh::Repository.object` + - an error will be thrown if requested object isnt a Reference. + */ + var cb, name, resolve, _priv, _ref, + _this = this; + _priv = _getPrivate(this); + _ref = args({ + name: { + type: "string" + }, + resolve: { + type: "bool", + "default": false + }, + cb: { + type: "function" + } + }), name = _ref[0], resolve = _ref[1], cb = _ref[2]; + return _priv["native"].reference(name, resolve, _wrapCallback(cb, function(ref) { + return cb(null, new Reference(_this, ref)); + })); + }; + + Repository.prototype.createReference = function() { + /* + Creates a new reference, which can either by direct or symbolic. + + Parameters: + + * **name**: *(String)* + * **target**: *(String)* reference/oid targetted by the new reference. + * **[force=false]**: *(String)* force creation of this reference, destroying the reference with same name, if it exists. + * **cb**: *(String)* called when reference has been created. + */ + var cb, fn, force, name, target, _priv, _ref, + _this = this; + _priv = _getPrivate(this); + _ref = args({ + name: { + type: "string" + }, + target: { + type: "string" + }, + force: { + type: "bool", + "default": false + }, + cb: { + type: "function" + } + }), name = _ref[0], target = _ref[1], force = _ref[2], cb = _ref[3]; + fn = "createSymReference"; + if (target.length === 40 && args.oidRegex.test(target)) { + fn = "createOidReference"; + } + return _priv["native"][fn](name, target, force, _wrapCallback(cb, function(ref) { + return cb(null, new Reference(_this, ref)); + })); + }; + + Repository.prototype.remote = function() { + /** + Loads a remote with given `name`. + */ + var cb, name, _priv, _ref, + _this = this; + _priv = _getPrivate(this); + _ref = args({ + name: { + type: "string" + }, + cb: { + type: "function" + } + }), name = _ref[0], cb = _ref[1]; + return _priv["native"].remote(name, _wrapCallback(cb, function(remote) { + return cb(null, new Remote(_this, remote)); + })); + }; + + Repository.prototype.createRemote = function() { + /** + Create a new :class:`gitteh::Remote` for this repository with the given + `name` and `url`. Calls `cb` when the operation has completed. + */ + var cb, name, url, _priv, _ref, + _this = this; + _priv = _getPrivate(this); + _ref = args({ + name: { + type: "string" + }, + url: { + type: "string" + }, + cb: { + type: "function" + } + }), name = _ref[0], url = _ref[1], cb = _ref[2]; + return _priv["native"].createRemote(name, url, _wrapCallback(cb, function(remote) { + return cb(null, new Remote(_this, remote)); + })); + }; + + return Repository; + + })(); + + /** + * Alias of {@link #reference}. + * @param {String} oid id of reference to be fetched. + * @param {Function} cb called when reference has been fetched. + * @see #reference + */ + + Repository.prototype.ref = Repository.prototype.reference; + + Gitteh.openRepository = function() { + /* + Opens a local Git repository with the given `path`. Calls `cb` once + a :class:`gitteh::Repository` has been opened. + */ + var cb, path, _ref; + _ref = args({ + path: { + type: "string" + }, + cb: { + type: "function" + } + }), path = _ref[0], cb = _ref[1]; + return bindings.openRepository(path, _wrapCallback(cb, function(repo) { + return cb(null, new Repository(repo)); + })); + }; + +Gitteh.openIndex = function() { + /* + Opens a local Git repository index. Calls `cb` once + a :class:`gitteh::Index` has been opened. + */ + var cb, path, _ref; + _ref = args({ + repo: { + type: "repository" + }, + cb: { + type: "function" + } + }), repo = _ref[0], cb = _ref[1]; + return bindings.openIndex(repo, _wrapCallback(cb, function(repo) { + return cb(null, new Index(repo)); + })); + }; + + + + Gitteh.initRepository = function() { + /* + Creates a new Git repository at `path`, and calls `cb` providing the new + :class:`gitteh::Repository` when operation has completed. + + If `bare` is specified as true the repository will be created without a + working directory. For more information see (TODO: link to page describing + bare repositories.) + */ + var bare, cb, path, _ref; + _ref = args({ + path: { + type: "string" + }, + bare: { + type: "bool", + "default": false + }, + cb: { + type: "function" + } + }), path = _ref[0], bare = _ref[1], cb = _ref[2]; + return bindings.initRepository(path, bare, _wrapCallback(cb, function(repo) { + return cb(null, new Repository(repo)); + })); + }; + + Gitteh.clone = function() { + /* + Provides high level "git clone" functionality. + + Creates a new repository on the local filesystem at `path`, creates a + default "origin" :class:`gitteh::Remote` with the provided `url`, fetches + the references from the remote, checks out the master branch into the + working directory. + + Currently, libgit2 only supports HTTP/Git protocols - there is no support + for git+ssh yet. + */ + var cb, emitter, path, url, _ref; + _ref = args({ + url: { + type: "string" + }, + path: { + type: "string" + } + }), url = _ref[0], path = _ref[1], cb = _ref[2]; + emitter = new EventEmitter; + async.waterfall([ + function(cb) { + return Gitteh.initRepository(path, false, cb); + }, function(repo, cb) { + return repo.createRemote("origin", url, _wrapCallback(cb, function(remote) { + return cb(null, repo, remote); + })); + }, function(repo, remote, cb) { + return remote.connect("fetch", _wrapCallback(cb, function() { + return cb(null, repo, remote); + })); + }, function(repo, remote, cb) { + var emitProgress; + emitProgress = function(bytes, done, complete) { + return emitter.emit("status", bytes, done, complete); + }; + return remote.fetch(emitProgress, _wrapCallback(cb, function() { + return cb(null, repo, remote); + })); + }, function(repo, remote, cb) { + return repo.ref(remote.HEAD, true, _wrapCallback(cb, function(ref) { + return cb(null, repo, remote, ref); + })); + }, function(repo, remote, headRef, cb) { + var refName; + refName = remote.fetchSpec.transformFrom(remote.HEAD); + return repo.createReference(refName, headRef.target, _wrapCallback(cb, function() { + return cb(null, repo, remote, headRef); + })); + }, function(repo, remote, headRef, cb) { + return repo.commit(headRef.target, _wrapCallback(cb, function(commit) { + return cb(null, repo, remote, commit); + })); + }, function(repo, remote, headCommit, cb) { + return headCommit.tree(_wrapCallback(cb, function(tree) { + return cb(null, repo, remote, tree); + })); + }, function(repo, remote, headTree, cb) { + var checkoutTree, handleEntry; + handleEntry = function(dest, entry, cb) { + var subPath; + if (entry.type === "tree") { + subPath = _path.join(dest, entry.name); + return async.series([ + function(cb) { + return fs.mkdir(subPath, cb); + }, function(cb) { + return repo.tree(entry.id, _wrapCallback(cb, function(subtree) { + return checkoutTree(subtree, subPath, cb); + })); + } + ], cb); + } else if (entry.type === "blob") { + return repo.blob(entry.id, _wrapCallback(cb, function(blob) { + var file; + file = fs.createWriteStream(_path.join(dest, entry.name), { + mode: entry.attributes + }); + file.write(blob.data); + file.end(); + return cb(); + })); + } else { + return cb(); + } + }; + checkoutTree = function(tree, dest, cb) { + return async.forEach(tree.entries, handleEntry.bind(null, dest), cb); + }; + return checkoutTree(headTree, repo.workingDirectory, _wrapCallback(cb, function() { + return cb(null, repo, remote, headTree); + })); + }, function(repo, remote, headTree, cb) { + return repo.index.readTree(headTree.id, _wrapCallback(cb, function() { + return cb(null, repo, remote); + })); + }, function(repo, remote, cb) { + return repo.index.write(_wrapCallback(cb, function() { + return cb(null, repo, remote); + })); + } + ], function(err, repo) { + if (err != null) return emitter.emit("error", err); + return emitter.emit("complete", repo); + }); + return emitter; + }; + +}).call(this); diff --git a/preinstall.js b/preinstall.js deleted file mode 100644 index 4b02742..0000000 --- a/preinstall.js +++ /dev/null @@ -1,10 +0,0 @@ -var child_process = require("child_process"); - -child_process.exec("which cmake", function(err) { - if(err && err.code != 0) { - console.error("[ERROR] CMake is required for installation.") - console.error("Please ensure CMake is installed to a standard location" + - "in your system."); - process.exit(1); - } -}); diff --git a/src/args.coffee b/src/args.coffee deleted file mode 100644 index 8ebe3aa..0000000 --- a/src/args.coffee +++ /dev/null @@ -1,74 +0,0 @@ -module.exports = fn = (params) -> - paramList = for own name, param of params - param.name = name - param - ret = [] - - numRequired = 0 - leftRequired = for param in paramList - break if param.hasOwnProperty("default") - numRequired++ - param - paramList.splice 0, leftRequired.length - rightRequired = for param in paramList.slice(0).reverse() - break if param.hasOwnProperty("default") - numRequired++ - param - rightRequired = rightRequired.reverse() - paramList.splice -rightRequired.length - - args = Array.prototype.slice.call fn.caller.arguments - throw new Error("Not enough arguments.") if args.length < numRequired - - left = args.splice 0, leftRequired.length - right = args.splice -rightRequired.length - - argn = 0 - for arg, i in left - argn++ - param = leftRequired[i] - if not fn.validators[param.type] arg - throw new TypeError "#{param.name} (#{argn}) is not a valid #{param.type}" - ret.push arg - - for param, i in paramList - argn++ - if args.length > i - arg = args[i] - if not fn.validators[param.type] arg - throw new TypeError "#{param.name} (#{argn}) is not a valid #{param.type}" - ret.push arg - else ret.push param.default - for arg, i in right - argn++ - param = rightRequired[i] - if not fn.validators[param.type] arg - throw new TypeError "#{param.name} (#{argn}) is not a valid #{param.type}" - ret.push arg - return ret - - -fn.oidRegex = oidRegex = /^[a-zA-Z0-9]{0,40}$/ -objectTypes = ["any", "blob", "commit", "tag", "tree"] -remoteDirs = ["push", "fetch"] - -fn.validators = - string: (val) -> - return typeof val is "string" - - function: (val) -> return typeof val is "function" - - bool: (val) -> - return typeof val is "boolean" - - oid: (val) -> - return false if typeof val isnt "string" - return false if not oidRegex.test val - return false if val.length < fn.minOidLength - return true - - objectType: (val) -> - return objectTypes.indexOf val > -1 - - remoteDir: (val) -> - return remoteDirs.indexOf val > -1 \ No newline at end of file diff --git a/src/baton.cc b/src/baton.cc index 5f1070a..abe0fe2 100644 --- a/src/baton.cc +++ b/src/baton.cc @@ -1,8 +1,8 @@ #include "baton.h" -#include "gitteh.h" +#include "sgit.h" #include -namespace gitteh { +namespace sgit { Baton::Baton() { errorCode = 0; @@ -54,4 +54,4 @@ void Baton::defaultCallback() { } } -}; // namespace gitteh +}; // namespace sgit diff --git a/src/baton.h b/src/baton.h index 11231b2..6a1688e 100644 --- a/src/baton.h +++ b/src/baton.h @@ -1,5 +1,5 @@ -#ifndef GITTEH_BATON_H -#define GITTEH_BATON_H +#ifndef SGIT_BATON_H +#define SGIT_BATON_H #include #include @@ -9,7 +9,7 @@ using namespace v8; using std::string; -namespace gitteh { +namespace sgit { /** A Baton class specifically for libgit2 work. Users of this Baton are expected to copy a git_error into this class. @@ -32,6 +32,6 @@ class Baton { void defaultCallback(); }; -}; // namespace gitteh +}; // namespace sgit -#endif // GITTEH_BATON_H +#endif // SGIT_BATON_H diff --git a/src/blah.py b/src/blah.py deleted file mode 100644 index 9ad2b08..0000000 --- a/src/blah.py +++ /dev/null @@ -1,6 +0,0 @@ -def hello(): - """ - Omgawd. - """ - - print(":D") diff --git a/src/blob.cc b/src/blob.cc deleted file mode 100644 index bbcf668..0000000 --- a/src/blob.cc +++ /dev/null @@ -1,46 +0,0 @@ -/* - * The MIT License - * - * Copyright (c) 2010 Sam Day - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#include "blob.h" -#include - -static Persistent data_symbol; - -namespace gitteh { - namespace Blob { - void Init(Handle target) { - HandleScope scope; - data_symbol = NODE_PSYMBOL("data"); - } - - Handle Create(git_blob *blob) { - HandleScope scope; - Handle o = Object::New(); - int len = git_blob_rawsize(blob); - Buffer *buffer = Buffer::New((char*)git_blob_rawcontent(blob), len); - o->Set(data_symbol, MakeFastBuffer(buffer, len)); - return scope.Close(o); - } - } -}; diff --git a/src/blob.h b/src/blob.h deleted file mode 100644 index 095cafb..0000000 --- a/src/blob.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef GITTEH_BLOB_H -#define GITTEH_BLOB_H - -#include "gitteh.h" - -namespace gitteh { - namespace Blob { - void Init(Handle); - Handle Create(git_blob*); - } -}; - -#endif // GITTEH_BLOB_H diff --git a/src/commit.cc b/src/commit.cc deleted file mode 100644 index de8a4a0..0000000 --- a/src/commit.cc +++ /dev/null @@ -1,68 +0,0 @@ -/* - * The MIT License - * - * Copyright (c) 2010 Sam Day - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#include "commit.h" -#include "signature.h" - -static Persistent message_symbol; -static Persistent message_encoding_symbol; -static Persistent author_symbol; -static Persistent committer_symbol; -static Persistent tree_symbol; -static Persistent parents_symbol; - -namespace gitteh { - namespace Commit { - void Init(Handle target) { - HandleScope scope; - message_symbol = NODE_PSYMBOL("message"); - message_encoding_symbol = NODE_PSYMBOL("messageEncoding"); - author_symbol = NODE_PSYMBOL("author"); - committer_symbol = NODE_PSYMBOL("committer"); - tree_symbol = NODE_PSYMBOL("tree"); - parents_symbol = NODE_PSYMBOL("parents"); - } - - Handle Create(git_commit *cm) { - HandleScope scope; - Handle o = Object::New(); - o->Set(tree_symbol, CastToJS(git_commit_tree_id(cm))); - o->Set(message_symbol, CastToJS(git_commit_message(cm))); - const char *encoding = git_commit_message_encoding(cm); - if(encoding) { - o->Set(message_encoding_symbol, CastToJS(encoding)); - } - Handle parents = Array::New(); - int parentCount = git_commit_parentcount(cm); - for(int i = 0; i < parentCount; i++) { - parents->Set(i, CastToJS(git_commit_parent_id(cm, i))); - } - o->Set(parents_symbol, parents); - o->Set(author_symbol, CastToJS(git_commit_author(cm))); - o->Set(committer_symbol, CastToJS(git_commit_committer(cm))); - - return scope.Close(o); - } - }; -}; diff --git a/src/commit.h b/src/commit.h deleted file mode 100644 index a4ac0c8..0000000 --- a/src/commit.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef GITTEH_COMMIT_H -#define GITTEH_COMMIT_H - -#include "gitteh.h" - -namespace gitteh { - namespace Commit { - void Init(Handle); - Handle Create(git_commit*); - }; -}; // namespace gitteh - -#endif // GITTEH_COMMIT_H diff --git a/src/error.h b/src/error.h index 8ea647a..b147a04 100644 --- a/src/error.h +++ b/src/error.h @@ -1,9 +1,9 @@ -#ifndef GITTEH_ERROR_H -#define GITTEH_ERROR_H +#ifndef SGIT_ERROR_H +#define SGIT_ERROR_H -#include "gitteh.h" +#include "sgit.h" -namespace gitteh { +namespace sgit { static inline void ErrorInit(Handle target) { HandleScope scope; @@ -37,4 +37,4 @@ namespace gitteh { } } -#endif // GITTEH_ERROR_H +#endif // SGIT_ERROR_H diff --git a/src/gitteh.coffee b/src/gitteh.coffee deleted file mode 100644 index fb8bf41..0000000 --- a/src/gitteh.coffee +++ /dev/null @@ -1,719 +0,0 @@ -### -Omg gitteh is freakin' sweet! :) -### - -{EventEmitter} = require "events" -async = require "async" -fs = require "fs" -_path = require "path" -args = require "./args" - -# env = if process.env.npm_lifecycle_event is "test" then "Debug" else "Release" -env = "Release" -bindings = require "../build/#{env}/gitteh" - -(require "segfault-handler").registerHandler() if env is "Debug" - -{minOidLength, types, NativeRepository, NativeRemote} = bindings -args.minOidLength = minOidLength - -Gitteh = module.exports = {} - -_getPrivate = (obj) -> - _getPrivate.lock++ - return obj._private -_getPrivate.lock = 0 - -_createPrivate = (obj) -> - _priv = {} - Object.defineProperty obj, "_private", - enumerable: false - configurable: false - get: -> - throw new Error "Bad request" if not _getPrivate.lock-- - return _priv - return _priv - -_wrapCallback = (orig, cb) -> - return (err) -> - return orig err if err? - cb.apply null, Array.prototype.slice.call arguments, 1 - -_immutable = (obj, src) -> - return o = { - set: (name, target = name) -> - if Array.isArray src[name] - Object.defineProperty obj, target, - get: () -> src[name].slice(0) - configurable: false - enumerable: true - return o - Object.defineProperty obj, target, - value: src[name] - writable: false - configurable: false - enumerable: true - return o - } - - -Gitteh.Signature = class Signature - ### - Contains the name/email/time for a :class:`gitteh::Commit` author/committer - or :class:`gitteh::Tag` tagger. - - Signatures contain the following *immutable* properties: - - - **name**: *(String)* - - **email**: *(String)* - - **time**: *(Date)* - - **offset**: *(Number)* timezone offset in seconds from GMT. - ### - - constructor: (obj) -> - _immutable(@, obj) - .set("name") - .set("email") - .set("time") - .set("offset") - - -Gitteh.Refspec = class Refspec - ### - Describes the way remote repository references will be mapped to the local - repository. - - For more information refer to http://git-scm.com/book/ch9-5.html - ### - - constructor: (src, dst) -> - _priv = _createPrivate @ - - _priv.srcRoot = if src? and src[-1..] is "*" then src[0...-1] else src - _priv.dstRoot = if dst? and dst[-1..] is "*" then dst[0...-1] else dst - - _immutable(@, {src, dst}) - .set("src") - .set("dst") - - matchesSrc: (refName) -> - ### - Returns true/false if given `refName` matches source of this Refspec. - ### - _priv = _getPrivate @ - return false if refName.length <= _priv.srcRoot.length - return refName.indexOf(_priv.srcRoot) is 0 - - matchesDst: (refName) -> - ### - Returns true/false if given `refName` matches destination of this - Refspec. - ### - _priv = _getPrivate @ - return false if refName.length <= _priv.dstRoot.length - return refName.indexOf(_priv.dstRoot) is 0 - - transformTo: (refName) -> - ### - Transforms given `refName` to destination, provided it matches src - pattern, and throws an error if it doesn't. - ### - throw new Error "Ref doesn't match src." if not @matchesSrc refName - return "#{@dst[0...-2]}#{refName[(@src.length-2)..]}" - - transformFrom: (refName) -> - ### - Transforms provided refName from destination back to source, provided it - matches dst pattern, and throws an Error if it doesn't. This is the - reverse of :func:`gitteh::Refspec.transformTo` - ### - throw new Error "Ref doesn't match dst." if not @matchesDst refName - return "#{@src[0...-2]}#{refName[(@dst.length-2)..]}" - - -Gitteh.Commit = class Commit - ### - Commits, made by an author, and an optional different committer, contain a - message, an associated :class:`gitteh::Tree`, and zero or more parent - :class:`gitteh::Commit` objects. Zero parents generally indicate the initial - commit for the repository. More than one parent commits indicate a merge - commit. - - Properties: - - * **id**: *(String)* OID of this commit (SHA1 hash) - * **treeId**: *(String)* OID of associated :class:`gitteh::Tree` - * **parents**: *(String[]) list of parent commit OIDs - * **message**: *(String)* - * **messageEncoding**: *(???)* ??? TODO: - * **author**: (:class:`gitteh::Signature`) - * **committer**: (:class:`gitteh::Signature`) - ### - - constructor: (@repository, obj) -> - obj.author = new Signature obj.author - obj.committer = new Signature obj.committer - _immutable(@, obj) - .set("id") - .set("tree", "treeId") - .set("parents") - .set("message") - .set("messageEncoding") - .set("author") - .set("committer") - - tree: (cb) -> - ### - Fetches the :class:`gitteh::Tree` for this Commit. Shortcut for calling - :func:`gitteh::Repository.tree` with this commits `treeId`. - ### - @repository.tree @treeId, cb - - -Gitteh.Tree = class Tree - ### - A Tree contains a list of named entries, which can either be - :class:`gitteh::Blob` objects or nested :class:`gitteh::Tree` objects. Each - entry is referenced by its OID. - - Properties: - - * **id**: *(String)* OID of this Tree. - * **entries**: *(TreeEntry[])* - - ## Tree Entries - - Each element of a Tree contains the following properties: - - * **id**: *(String)* OID this entry points to. - * **name**: *(String)* file name of this entry. - * **type**: *(String)* kind of object pointed to by this entry - * **attributes**: *(Number)* UNIX file attributes for this entry. - ### - - constructor: (@repository, obj) -> - obj._entries = obj.entries - obj.entries = [] - for origEntry in obj._entries - obj.entries.push entry = {} - _immutable(entry, origEntry) - .set("id") - .set("name") - .set("type") - .set("attributes") - _immutable(@, obj) - .set("id") - .set("entries") - - -Gitteh.Blob = class Blob - ### - Contains raw data for a file stored in Git. - - Properties: - - * **id**: *(String)* OID of this Blob. - * **data**: *(Buffer)* a standard Node buffer containing binary data. - ### - - constructor: (@repository, obj) -> - _immutable(@, obj) - .set("id") - .set("data") - - -Gitteh.Tag = class Tag - ### - Git tags are similar to references, and indeed "lightweight" Git tags are - actually implemented as :class:`gitteh::Reference` with a name prefix - of "tags/". When additional metadata is needed (message/name/email/GPG - signature), a proper heavyweight Tag object is used. - - Properties: - - * **id**: *(String)* OID of this Tag. - * **name**: *(String)* - * **message**: *(String)* - * **tagger**: *(Signature)* - * **targetId**: *(String)* OID this Tag points to - * **type**: *(String)* the type of object this Tag points to. - ### - - constructor: (@repository, obj) -> - obj.tagger = new Signature obj.tagger - _immutable(@, obj) - .set("id") - .set("name") - .set("message") - .set("tagger") - .set("target", "targetId") - .set("type") - - target: (cb) -> - ### - Convenience method to get the object this Tag points to. Shorthand for - calling :func:`gitteh::Repository.object` with this *targetId* - ### - @repository.object @targetId, @type, cb - - -Gitteh.Remote = class Remote - ### - Remotes designate the location and rules of remote Git repositories. Remotes - can be obtained by using :func:`gitteh::Repository.remote` - - Properties: - - * **connected**: *(Boolean)* true if there is an active connection to the Remotes' endpoint. - * **name**: *(String)* - * **url**: *(String)* address of Remotes' endpoint - * **fetchSpec**: (:class:`gitteh::Refspec`) Refspec used when fetching from Remote - * **pushSpec**: (:class:`gitteh::Refspec`) Refspec used when pushing to Remote - * **HEAD**: *(String)* the remote HEAD reference name (only set after connected to Remote) - * **refs**: *(String[])* names of references on remote (only set after connected to Remote) - ### - - constructor: (@repository, nativeRemote) -> - _priv = _createPrivate @ - _priv.native = nativeRemote - _priv.connected = false - - if nativeRemote not instanceof NativeRemote - throw new Error "Don't construct me, see Repository.remote()" - - Object.defineProperty @, "connected", - get: -> return _priv.connected - enumerable: true - configurable: false - - _immutable(@, nativeRemote) - .set("name") - .set("url") - - fetchSpec = new Refspec nativeRemote.fetchSpec.src, nativeRemote.fetchSpec.dst - pushSpec = new Refspec nativeRemote.pushSpec.src, nativeRemote.pushSpec.dst - _immutable(@, {fetchSpec, pushSpec}) - .set("fetchSpec") - .set("pushSpec") - - connect: -> - ### - Opens a connection to the :class:`gitteh::Remote` endpoint. This is - needed before :func:`gitteh::Remote.fetch` or :func:`gitteh::Remote.push` - can be called. `direction` must be supplied as either "push" or "fetch" - and `cb` will be called once Remote is connected. - ### - _priv = _getPrivate @ - [dir, cb] = args - dir: type: "remoteDir" - cb: type: "function" - dir = if dir is "push" then bindings.GIT_DIRECTION_PUSH else bindings.GIT_DIRECTION_FETCH - _priv.native.connect dir, _wrapCallback cb, (refs) => - refNames = Object.keys refs - - # Determine symref for HEAD. - headOid = refs["HEAD"] - for ref, oid of refs - continue if ref is "HEAD" - if oid is headOid - headRef = @fetchSpec.transformTo ref - _immutable(@, {headRef}).set "headRef", "HEAD" - break - - _immutable(@, {refNames}).set "refNames", "refs" - _priv.connected = true - cb() - - fetch: -> - ### - Fetches Git objects from remote that do not exist locally. `progressCb` - will be called regularly to notify callers of fetch progress and `cb` - will be called once fetch has completed. - ### - _priv = _getPrivate @ - throw new Error "Remote isn't connected." if not @connected - [progressCb, cb] = args - progressCb: type: "function" - cb: type: "function" - - updateTimer = null - update = => - {bytes, total, done} = _priv.native.stats - progressCb bytes, total, done - updateTimer = setTimeout update, 500 - setTimeout update, 500 - - _priv.native.download (err) => - clearTimeout updateTimer - return cb err if err? - _priv.native.updateTips _wrapCallback cb, => - cb() - - -Gitteh.Index = class Index - ### - The Git index is used to stage changed files before they are written to the - repository proper. Bindings for the Index are currently minimal, expect - this to change in a newer version. - ### - - constructor: (nativeIndex) -> - _priv = _createPrivate @ - _priv.native = nativeIndex - - readTree: -> - ### - Updates the Git index to reflect the state of provided - :class:`gitteh::Tree` (using OID passed from `id` parameter). `cb` will - be called once index update has completed. - ### - _priv = _getPrivate @ - [id, cb] = args - id: type: "oid" - cb: type: "function" - _priv.native.readTree id, cb - - write = -> - ### - Synchronizes the in-memory Git index with the indexfile located in - repository, and calls `cb` once synchronization is complete. - ### - _priv = _getPrivate @ - [cb] = args - cb: type: "function" - _priv.native.write cb - - -Gitteh.Reference = class Reference - ### - A Reference is a named pointer to a :class:`gitteh::Commit` object. That is, - refs are the DNS of Git-land. References can either be direct or symbolic. - Direct references point to the object id of a commit. Symbolic refs point - to other references. - - References can be obtained using :func:`gitteh::Repository.reference` and - created using :func:`gitteh::Repository.createReference`. - - Properties: - - * **name**: *(String)* - * **direct**: *(Boolean)* true if Reference points directly to an object id. - * **packed**: *(Boolean)* true if Reference is in a packfile - * **target**: *(String)* object id reference points to, or another reference - name if not a direct reference. - * **repository**: (:class:`gitteh::Repository`) owner of this Reference. - ### - - constructor: (repo, nativeRef) -> - _priv = _createPrivate @ - _priv.native = nativeRef - _immutable(@, nativeRef) - .set("name") - .set("direct") - .set("packed") - .set("target") - _immutable(@, {repo}).set "repo", "repository" - - -Gitteh.Repository = class Repository - ### - Represents a local Git repository that has been opened by Gitteh. Objects - such as :class:`gitteh::Commit`, :class:`gitteh.Tree` and - :class:`gitteh.Reference` can be obtained and created from a Repository. - - Repositories can be *bare* - they will not have a working directory, in this - case the contents of what is usually in a .git subdirectory will be in the - top level. - - Properties: - - * **bare**: *(Boolean)* true if this repository is bare. - * **path**: *(String)* location of the Git metadata directory - * **workingDirectory**: *(String)* location of the working directory, if applicable (non-bare repository) - * **remotes**: *(String[])* names of remotes configured for this repository - * **references**: *(String[])* names of references contained in this repository. - * **index**: (:class:`gitteh::Index`) The Git index for this repository. - ### - - constructor: (nativeRepo) -> - if nativeRepo not instanceof NativeRepository - throw new Error "Don't construct me, see gitteh.(open|init)Repository" - _priv = _createPrivate @ - _priv.native = nativeRepo - - _immutable(@, nativeRepo) - .set("bare") - .set("path") - .set("workDir", "workingDirectory") - .set("remotes") - .set("references") - .set("submodules") - index = new Index nativeRepo.index - _immutable(@, {index}).set "index" - - exists: (oid, cb) -> - ### - Checks if an object with given `oid` exists. Calls `cb` with result. - ### - _priv = _getPrivate @ - [oid, cb] = args - oid: type: "oid" - cb: type: "function" - _priv.native.exists oid, cb - - object: -> - ### - Fetches an object with given `oid` and returns the result to provided - `cb`. The object returned will be a Gitteh wrapper corresponding to the - type of Git object fetched. - - Alternatively, objects with an expected type can be fetched using the - :func:`gitteh::Repository.blob` :func:`gitteh::Repository.commit` - :func:`gitteh::Repository.tag` :func:`gitteh::Repository.tree` and - :func:`gitteh::Repository.reference` methods. - ### - _priv = _getPrivate @ - [oid, type, cb] = args - oid: type: "oid" - type: type: "objectType", default: "any" - cb: type: "function" - _priv.native.object oid, type, _wrapCallback cb, (object) => - clazz = switch object._type - when types.commit then Commit - when types.tree then Tree - when types.blob then Blob - when types.tag then Tag - else undefined - return cb new TypeError("Unexpected object type") if clazz is undefined - return cb null, new clazz @, object - - blob: (oid, cb) -> - ### - Fetches a :class:`gitteh::Blob` object with given `oid` from the - repository. This is a stricter variant of :func:`gitteh::Repository.object` - - an error will be thrown if requested object isnt a Blob. - ### - @object oid, "blob", cb - - commit: (oid, cb) -> - ### - Fetches a :class:`gitteh::Commit` object with given `oid` from the - repository. This is a stricter variant of :func:`gitteh::Repository.object` - - an error will be thrown if requested object isnt a Commit. - ### - @object oid, "commit", cb - - tag: (oid, cb) -> - ### - Fetches a :class:`gitteh::Tag` object with given `oid` from the - repository. This is a stricter variant of :func:`gitteh::Repository.object` - - an error will be thrown if requested object isnt a Tag. - ### - @object oid, "tag", cb - - tree: (oid, cb) -> - ### - Fetches a :class:`gitteh::Tree` object with given `oid` from the - repository. This is a stricter variant of :func:`gitteh::Repository.object` - - an error will be thrown if requested object isnt a Tree. - ### - @object oid, "tree", cb - - reference: -> - ### - Fetches a :class:`gitteh::Reference` object with given `oid` from the - repository. This is a stricter variant of :func:`gitteh::Repository.object` - - an error will be thrown if requested object isnt a Reference. - ### - _priv = _getPrivate @ - [name, resolve, cb] = args - name: type: "string" - resolve: type: "bool", default: false - cb: type: "function" - _priv.native.reference name, resolve, _wrapCallback cb, (ref) => - cb null, new Reference @, ref - - createReference: -> - ### - Creates a new reference, which can either by direct or symbolic. - - Parameters: - - * **name**: *(String)* - * **target**: *(String)* reference/oid targetted by the new reference. - * **[force=false]**: *(String)* force creation of this reference, destroying the reference with same name, if it exists. - * **cb**: *(String)* called when reference has been created. - ### - _priv = _getPrivate @ - [name, target, force, cb] = args - name: type: "string" - target: type: "string" - force: type: "bool", default: false - cb: type: "function" - fn = "createSymReference" - if target.length is 40 and args.oidRegex.test target - fn = "createOidReference" - _priv.native[fn] name, target, force, _wrapCallback cb, (ref) => - cb null, new Reference @, ref - - remote: -> - ###* - Loads a remote with given `name`. - ### - _priv = _getPrivate @ - [name, cb] = args - name: type: "string" - cb: type: "function" - _priv.native.remote name, _wrapCallback cb, (remote) => - return cb null, new Remote @, remote - - createRemote: -> - ###* - Create a new :class:`gitteh::Remote` for this repository with the given - `name` and `url`. Calls `cb` when the operation has completed. - ### - _priv = _getPrivate @ - [name, url, cb] = args - name: type: "string" - url: type: "string" - cb: type: "function" - _priv.native.createRemote name, url, _wrapCallback cb, (remote) => - return cb null, new Remote @, remote - -###* - * Alias of {@link #reference}. - * @param {String} oid id of reference to be fetched. - * @param {Function} cb called when reference has been fetched. - * @see #reference -### -Repository.prototype.ref = Repository.prototype.reference - - -Gitteh.openRepository = -> - ### - Opens a local Git repository with the given `path`. Calls `cb` once - a :class:`gitteh::Repository` has been opened. - ### - [path, cb] = args - path: type: "string" - cb: type: "function" - bindings.openRepository path, _wrapCallback cb, (repo) -> - cb null, new Repository repo - -Gitteh.initRepository = () -> - ### - Creates a new Git repository at `path`, and calls `cb` providing the new - :class:`gitteh::Repository` when operation has completed. - - If `bare` is specified as true the repository will be created without a - working directory. For more information see (TODO: link to page describing - bare repositories.) - ### - [path, bare, cb] = args - path: type: "string" - bare: type: "bool", default: false - cb: type: "function" - bindings.initRepository path, bare, _wrapCallback cb, (repo) -> - cb null, new Repository repo - -Gitteh.clone = => - ### - Provides high level "git clone" functionality. - - Creates a new repository on the local filesystem at `path`, creates a - default "origin" :class:`gitteh::Remote` with the provided `url`, fetches - the references from the remote, checks out the master branch into the - working directory. - - Currently, libgit2 only supports HTTP/Git protocols - there is no support - for git+ssh yet. - ### - [url, path, cb] = args - url: type: "string" - path: type: "string" - - emitter = new EventEmitter - - async.waterfall [ - # Initialize a fresh repo in the path specified. - (cb) -> Gitteh.initRepository path, false, cb - - # Create the origin remote with provided URL. - (repo, cb) -> - repo.createRemote "origin", url, _wrapCallback cb, (remote) -> - cb null, repo, remote - - # Connect to the remote to commence fetch. - (repo, remote, cb) -> - remote.connect "fetch", _wrapCallback cb, -> - cb null, repo, remote - - # Perform the actual fetch, sending progress updates as they come in. - (repo, remote, cb) -> - emitProgress = (bytes, done, complete) -> - emitter.emit "status", bytes, done, complete - remote.fetch emitProgress, _wrapCallback cb, -> - cb null, repo, remote - - # The connect step earlier resolved remote HEAD. Let's fetch that ref. - (repo, remote, cb) -> - repo.ref remote.HEAD, true, _wrapCallback cb, (ref) -> - cb null, repo, remote, ref - - # We now have fully resolved OID head ref. Create a local branch. - (repo, remote, headRef, cb) -> - refName = remote.fetchSpec.transformFrom remote.HEAD - repo.createReference refName, headRef.target, _wrapCallback cb, -> - cb null, repo, remote, headRef - - # And now fetch the commit. - (repo, remote, headRef, cb) -> - repo.commit headRef.target, _wrapCallback cb, (commit) -> - cb null, repo, remote, commit - - # Now fetch the tree for the commit. - (repo, remote, headCommit, cb) -> - headCommit.tree _wrapCallback cb, (tree) -> - cb null, repo, remote, tree - - # Now we can go ahead and checkout this tree into working directory. - (repo, remote, headTree, cb) -> - handleEntry = (dest, entry, cb) -> - if entry.type is "tree" - subPath = _path.join dest, entry.name - async.series [ - # TODO: mode? - (cb) -> fs.mkdir subPath, cb - (cb) -> - repo.tree entry.id, _wrapCallback cb, (subtree) -> - checkoutTree subtree, subPath, cb - ], cb - else if entry.type is "blob" - repo.blob entry.id, _wrapCallback cb, (blob) -> - file = fs.createWriteStream _path.join(dest, entry.name), - mode: entry.attributes - file.write blob.data - file.end() - cb() - else - cb() - checkoutTree = (tree, dest, cb) -> - async.forEach tree.entries, handleEntry.bind(null, dest), cb - checkoutTree headTree, repo.workingDirectory, _wrapCallback cb, -> - cb null, repo, remote, headTree - - # Update the git index with the tree we just checked out. - (repo, remote, headTree, cb) -> - repo.index.readTree headTree.id, _wrapCallback cb, -> - cb null, repo, remote - - # Now write the index back to disk. - (repo, remote, cb) -> - repo.index.write _wrapCallback cb, -> - cb null, repo, remote - ], (err, repo) -> - return emitter.emit "error", err if err? - - emitter.emit "complete", repo - - return emitter diff --git a/src/index.cc b/src/index.cc deleted file mode 100644 index 60e8cc8..0000000 --- a/src/index.cc +++ /dev/null @@ -1,137 +0,0 @@ -#include "index.h" -#include "baton.h" -#include "repository.h" - -namespace gitteh { - static Persistent class_symbol; - - class IndexBaton : public Baton { - public: - Index *index_; - Repository *repository_; - - IndexBaton(Index *index) : Baton(), index_(index) { - repository_ = index->repository_; - index_->Ref(); - } - - ~IndexBaton() { - index_->Unref(); - } - }; - - class ReadTreeBaton : public IndexBaton { - public: - git_oid treeId; - - ReadTreeBaton(Index *index) : IndexBaton(index) { } - }; - - Persistent Index::constructor_template; - - Index::Index(Repository *repository, git_index *index) : - repository_(repository), index_(index) { - - } - - Index::~Index() { - - } - - void Index::Init(Handle module) { - HandleScope scope; - - class_symbol = NODE_PSYMBOL("NativeIndex"); - - Local t = FunctionTemplate::New(New); - constructor_template = Persistent::New(t); - constructor_template->SetClassName(class_symbol); - t->InstanceTemplate()->SetInternalFieldCount(1); - - NODE_SET_PROTOTYPE_METHOD(t, "readTree", ReadTree); - NODE_SET_PROTOTYPE_METHOD(t, "write", Write); - - module->Set(class_symbol, constructor_template->GetFunction()); - } - - Handle Index::New(const Arguments &args) { - HandleScope scope; - REQ_EXT_ARG(0, repoArg); - REQ_EXT_ARG(1, indexArg); - Handle me = args.This(); - - Repository *repository = static_cast(repoArg->Value()); - git_index *rawIndex = static_cast(indexArg->Value()); - Index *index = new Index(repository, rawIndex); - index->Wrap(me); - - return scope.Close(me); - } - - Handle Index::ReadTree(const Arguments &args) { - HandleScope scope; - Index *index = ObjectWrap::Unwrap(args.This()); - - ReadTreeBaton *baton = new ReadTreeBaton(index); - baton->treeId = CastFromJS(args[0]); - baton->setCallback(args[1]); - - uv_queue_work(uv_default_loop(), &baton->req, AsyncReadTree, - NODE_094_UV_AFTER_WORK_CAST(AsyncAfterReadTree)); - - return Undefined(); - } - - void Index::AsyncReadTree(uv_work_t *req) { - ReadTreeBaton *baton = GetBaton(req); - - baton->repository_->lockRepository(); - - git_tree *tree; - if(AsyncLibCall(git_tree_lookup(&tree, baton->repository_->repo_, - &baton->treeId), baton)) { - AsyncLibCall(git_index_read_tree(baton->index_->index_, - tree), baton); - git_tree_free(tree); - } - - baton->repository_->unlockRepository(); - } - - void Index::AsyncAfterReadTree(uv_work_t *req) { - HandleScope scope; - ReadTreeBaton *baton = GetBaton(req); - - baton->defaultCallback(); - - delete baton; - } - - Handle Index::Write(const Arguments &args) { - HandleScope scope; - Index *index = ObjectWrap::Unwrap(args.This()); - IndexBaton *baton = new IndexBaton(index); - baton->setCallback(args[0]); - - uv_queue_work(uv_default_loop(), &baton->req, AsyncWrite, - NODE_094_UV_AFTER_WORK_CAST(AsyncAfterWrite)); - - return Undefined(); - } - - void Index::AsyncWrite(uv_work_t *req) { - IndexBaton *baton = GetBaton(req); - - AsyncLibCall(git_index_write(baton->index_->index_), baton); - } - - void Index::AsyncAfterWrite(uv_work_t *req) { - HandleScope scope; - IndexBaton *baton = GetBaton(req); - - baton->defaultCallback(); - - delete baton; - } - -}; // namespace gitteh diff --git a/src/index.h b/src/index.h deleted file mode 100644 index bb5ff7a..0000000 --- a/src/index.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef GITTEH_INDEX_H -#define GITTEH_INDEX_H - -#include "gitteh.h" - -namespace gitteh { - class IndexBaton; - class Repository; - - class Index : public ObjectWrap { - public: - static Persistent constructor_template; - - friend class IndexBaton; - - Index(Repository*, git_index*); - ~Index(); - static void Init(Handle); - protected: - static Handle New(const Arguments&); - static Handle ReadTree(const Arguments&); - static Handle Write(const Arguments&); - private: - Repository *repository_; - git_index *index_; - - static void AsyncReadTree(uv_work_t*); - static void AsyncAfterReadTree(uv_work_t*); - static void AsyncWrite(uv_work_t*); - static void AsyncAfterWrite(uv_work_t*); - }; - -} // namespace gitteh - -#endif // GITTEH_INDEX_H diff --git a/src/remote.cc b/src/remote.cc deleted file mode 100644 index aabc9c5..0000000 --- a/src/remote.cc +++ /dev/null @@ -1,284 +0,0 @@ -#include "remote.h" -#include "git2/strarray.h" - -using std::map; -using std::pair; - -namespace gitteh { - static Persistent class_symbol; - static Persistent name_symbol; - static Persistent url_symbol; - static Persistent fetchspecs_symbol; - static Persistent pushspecs_symbol; - static Persistent progress_symbol; - - static Persistent refspec_src_symbol; - static Persistent refspec_dst_symbol; - - static Persistent progress_total_objects_symbol; - static Persistent progress_indexed_objects_symbol; - static Persistent progress_received_objects_symbol; - static Persistent progress_received_bytes_symbol; - - class RemoteBaton : public Baton { - public: - Remote *remote_; - - RemoteBaton(Remote *remote) : Baton(), remote_(remote) { - remote_->Ref(); - } - - ~RemoteBaton() { - remote_->Unref(); - } - }; - - class UpdateTipsBaton : public RemoteBaton { - public: - UpdateTipsBaton(Remote *remote) : RemoteBaton(remote) { } - }; - - class ConnectBaton : public RemoteBaton { - public: - git_direction direction; - map refs; - - ConnectBaton(Remote *remote, int direction) : - RemoteBaton(remote), direction((git_direction)direction) { } - }; - - class DownloadBaton : public RemoteBaton { - public: - git_off_t *bytes; - git_transfer_progress *stats; - DownloadBaton(Remote *remote) : - RemoteBaton(remote) { } - }; - - static int SaveRemoteRef(git_remote_head *head, void *payload) { - ConnectBaton *baton = static_cast(payload); - baton->refs.insert(pair(string(head->name), head->oid)); - return GIT_OK; - } - - Persistent Remote::constructor_template; - - Remote::Remote(git_remote *remote) : ObjectWrap() { - remote_ = remote; - } - - Remote::~Remote() { - if(remote_ != NULL) { - git_remote_free(remote_); - remote_ = NULL; - } - } - - void Remote::Init(Handle target) { - HandleScope scope; - - class_symbol = NODE_PSYMBOL("NativeRemote"); - name_symbol = NODE_PSYMBOL("name"); - url_symbol = NODE_PSYMBOL("url"); - fetchspecs_symbol = NODE_PSYMBOL("fetchSpecs"); - pushspecs_symbol = NODE_PSYMBOL("pushSpecs"); - progress_symbol = NODE_PSYMBOL("progress"); - - refspec_src_symbol = NODE_PSYMBOL("src"); - refspec_dst_symbol = NODE_PSYMBOL("dst"); - - progress_total_objects_symbol = NODE_PSYMBOL("totalObjects"); - progress_indexed_objects_symbol = NODE_PSYMBOL("indexedObjects"); - progress_received_objects_symbol = NODE_PSYMBOL("receivedObjects"); - progress_received_bytes_symbol = NODE_PSYMBOL("receivedBytes"); - - Local t = FunctionTemplate::New(New); - constructor_template = Persistent::New(t); - constructor_template->SetClassName(class_symbol); - t->InstanceTemplate()->SetInternalFieldCount(1); - - NODE_SET_PROTOTYPE_METHOD(t, "updateTips", UpdateTips); - NODE_SET_PROTOTYPE_METHOD(t, "connect", Connect); - NODE_SET_PROTOTYPE_METHOD(t, "download", Download); - - target->Set(class_symbol, constructor_template->GetFunction()); - } - - Handle Remote::New(const Arguments& args) { - HandleScope scope; - REQ_EXT_ARG(0, remoteArg); - Handle me = args.This(); - - git_remote *remote = static_cast(remoteArg->Value()); - Remote *remoteObj = new Remote(remote); - remoteObj->Wrap(me); - - // Get the fetch- and push-specs - Handle fetchspecsArr = Array::New(); - git_strarray fetchspecs = {NULL, 0}; - if (!git_remote_get_fetch_refspecs(&fetchspecs, remote)) { - for (size_t i=0; iSet(i, CastToJS(fetchspecs.strings[i])); - } - me->Set(fetchspecs_symbol, fetchspecsArr); - - Handle pushspecsArr = Array::New(); - git_strarray pushspecs = {NULL, 0}; - if (!git_remote_get_push_refspecs(&pushspecs, remote)) { - for (size_t i=0; iSet(i, CastToJS(pushspecs.strings[i])); - } - me->Set(pushspecs_symbol, pushspecsArr); - - me->Set(name_symbol, CastToJS(git_remote_name(remote))); - me->Set(url_symbol, CastToJS(git_remote_url(remote))); - - return scope.Close(me); - } - - Handle Remote::UpdateTips(const Arguments& args) { - HandleScope scope; - Remote *remote = ObjectWrap::Unwrap(args.This()); - UpdateTipsBaton *baton = new UpdateTipsBaton(remote); - baton->setCallback(args[0]); - uv_queue_work(uv_default_loop(), &baton->req, AsyncUpdateTips, - NODE_094_UV_AFTER_WORK_CAST(AsyncAfterUpdateTips)); - return Undefined(); - } - - void Remote::AsyncUpdateTips(uv_work_t *req) { - UpdateTipsBaton *baton = GetBaton(req); - // TODO: use the callback to get changed refs once fn accepts a payload - AsyncLibCall(git_remote_update_tips(baton->remote_->remote_), - baton); - } - - void Remote::AsyncAfterUpdateTips(uv_work_t *req) { - HandleScope scope; - UpdateTipsBaton *baton = GetBaton(req); - - if(baton->isErrored()) { - Handle argv[] = { baton->createV8Error() }; - FireCallback(baton->callback, 1, argv); - } - else { - Handle argv[] = { Undefined() }; - FireCallback(baton->callback, 1, argv); - } - - delete baton; - } - - Handle Remote::Connect(const Arguments& args) { - HandleScope scope; - Remote *remote = ObjectWrap::Unwrap(args.This()); - ConnectBaton *baton = new ConnectBaton(remote, CastFromJS(args[0])); - baton->setCallback(args[1]); - uv_queue_work(uv_default_loop(), &baton->req, AsyncConnect, - NODE_094_UV_AFTER_WORK_CAST(AsyncAfterConnect)); - return Undefined(); - } - - void Remote::AsyncConnect(uv_work_t *req) { - ConnectBaton *baton = GetBaton(req); - if(AsyncLibCall(git_remote_connect(baton->remote_->remote_, - baton->direction), baton)) { - git_remote_ls(baton->remote_->remote_, SaveRemoteRef, baton); - } - } - - void Remote::AsyncAfterConnect(uv_work_t *req) { - HandleScope scope; - ConnectBaton *baton = GetBaton(req); - - if(baton->isErrored()) { - Handle argv[] = { baton->createV8Error() }; - FireCallback(baton->callback, 1, argv); - } - else { - Handle argv[] = { Undefined(), CastToJS(baton->refs) }; - FireCallback(baton->callback, 2, argv); - } - - delete baton; - } - - Handle Remote::Download(const Arguments &args) { - HandleScope scope; - Remote *remote = ObjectWrap::Unwrap(args.This()); - DownloadBaton *baton = new DownloadBaton(remote); - baton->setCallback(args[0]); - baton->bytes = &remote->downloadBytes_; - baton->stats = &remote->progress_; - - // Re-initialize stat counters. - remote->downloadBytes_ = 0; - memset(&remote->progress_, 0, sizeof(git_transfer_progress)); - - // Setup download stats accessor. - remote->handle_->SetAccessor(progress_symbol, GetStats); - - uv_queue_work(uv_default_loop(), &baton->req, AsyncDownload, - NODE_094_UV_AFTER_WORK_CAST(AsyncAfterDownload)); - return Undefined(); - } - - int Remote::DownloadTransferProgressCallback( - const git_transfer_progress *stats, - void *payload) - { - DownloadBaton *baton = (DownloadBaton*)payload; - baton->remote_->progress_ = *stats; - return 0; - } - - void Remote::AsyncDownload(uv_work_t *req) { - DownloadBaton *baton = GetBaton(req); - AsyncLibCall(git_remote_download(baton->remote_->remote_, - DownloadTransferProgressCallback, baton), baton); - } - - void Remote::AsyncAfterDownload(uv_work_t *req) { - HandleScope scope; - DownloadBaton *baton = GetBaton(req); - - baton->remote_->handle_->Delete(progress_symbol); - - if(baton->isErrored()) { - Handle argv[] = { baton->createV8Error() }; - FireCallback(baton->callback, 1, argv); - } - else { - Handle argv[] = { Undefined() }; - FireCallback(baton->callback, 1, argv); - } - - delete baton; - } - - Handle Remote::GetStats(Local property, const AccessorInfo &info) { - HandleScope scope; - Remote *remote = ObjectWrap::Unwrap(info.This()); - Handle o = Object::New(); - o->Set(progress_total_objects_symbol, CastToJS(remote->progress_.total_objects)); - o->Set(progress_indexed_objects_symbol, CastToJS(remote->progress_.indexed_objects)); - o->Set(progress_received_objects_symbol, CastToJS(remote->progress_.received_objects)); - o->Set(progress_received_bytes_symbol, CastToJS(remote->progress_.received_bytes)); - return scope.Close(o); - } - -}; // namespace gitteh - - -namespace cvv8 { - template<> - struct NativeToJS { - Handle operator() (git_refspec const *refspec) const { - HandleScope scope; - Handle o = Object::New(); - o->Set(gitteh::refspec_src_symbol, CastToJS(git_refspec_src(refspec))); - o->Set(gitteh::refspec_dst_symbol, CastToJS(git_refspec_dst(refspec))); - return scope.Close(o); - } - }; -} diff --git a/src/remote.h b/src/remote.h deleted file mode 100644 index 6715c72..0000000 --- a/src/remote.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef GITTEH_REMOTE_H -#define GITTEH_REMOTE_H - -#include "gitteh.h" - -namespace gitteh { - class RemoteBaton; - - class Remote : public ObjectWrap { - public: - friend class RemoteBaton; - - static Persistent constructor_template; - static void Init(Handle); - Remote(git_remote*); - ~Remote(); - - protected: - static Handle New(const Arguments&); - static Handle UpdateTips(const Arguments&); - static Handle Connect(const Arguments&); - static Handle Download(const Arguments&); - - private: - git_remote *remote_; - git_transfer_progress progress_; - git_off_t downloadBytes_; - - static Handle GetStats(Local, const AccessorInfo&); - static void AsyncUpdateTips(uv_work_t*); - static void AsyncAfterUpdateTips(uv_work_t*); - static void AsyncConnect(uv_work_t*); - static void AsyncAfterConnect(uv_work_t*); - static int DownloadTransferProgressCallback(const git_transfer_progress*, void*); - static void AsyncDownload(uv_work_t*); - static void AsyncAfterDownload(uv_work_t*); - }; -}; - -#endif diff --git a/src/repository.cc b/src/repository.cc index 86f1a39..9ed92f8 100644 --- a/src/repository.cc +++ b/src/repository.cc @@ -32,7 +32,7 @@ using std::list; -namespace gitteh { +namespace sgit { static Persistent repo_class_symbol; static Persistent path_symbol; static Persistent bare_symbol; @@ -731,4 +731,4 @@ void Repository::unlockRepository() { UNLOCK_MUTEX(gitLock_); } -} // namespace gitteh +} // namespace sgit diff --git a/src/repository.h b/src/repository.h index d94f002..6d851c7 100644 --- a/src/repository.h +++ b/src/repository.h @@ -1,9 +1,9 @@ -#ifndef GITTEH_REPO_H -#define GITTEH_REPO_H +#ifndef SGIT_REPO_H +#define SGIT_REPO_H -#include "gitteh.h" +#include "sgit.h" -namespace gitteh { +namespace sgit { class RepositoryBaton; @@ -71,16 +71,16 @@ class Repository : public ObjectWrap { // example. However for now I want this thing to *just work*, I'll worry // about making it a speed demon later. Ideally libgit2 will become thread // safe internally, then I can remove all this shit! - gitteh_lock gitLock_; + sgit_lock gitLock_; // This lock is used during ref packing. The problem is ref packing will // invalidate our previously cached pointers. Ugh. So what we do is update // those pointers after we pack references right? Cool. Only thing is with // async that process might get fucked if we don't stop any more refs from // being opened created while we're in the process of packing. Hence this lock. - // gitteh_lock refLock_; + // sgit_lock refLock_; }; -} // namespace gitteh +} // namespace sgit -#endif // GITTEH_REPO_H +#endif // SGIT_REPO_H diff --git a/src/gitteh.cc b/src/sgit.cc similarity index 93% rename from src/gitteh.cc rename to src/sgit.cc index 63fc21e..05f33a1 100644 --- a/src/gitteh.cc +++ b/src/sgit.cc @@ -22,7 +22,7 @@ * THE SOFTWARE. */ -#include "gitteh.h" +#include "sgit.h" #include "repository.h" #include "commit.h" #include "signature.h" @@ -32,7 +32,7 @@ #include "remote.h" #include "index.h" -namespace gitteh { +namespace sgit { Persistent module; @@ -83,6 +83,6 @@ Handle GetModule() { return module; } -} // namespace gitteh +} // namespace sgit -NODE_MODULE(gitteh, gitteh::init) +NODE_MODULE(sgit, sgit::init) diff --git a/src/gitteh.h b/src/sgit.h similarity index 98% rename from src/gitteh.h rename to src/sgit.h index 58c3ae8..db92b46 100644 --- a/src/gitteh.h +++ b/src/sgit.h @@ -1,5 +1,5 @@ -#ifndef GITTEH_H -#define GITTEH_H +#ifndef SGIT_H +#define SGIT_H #include #include "cvv8/convert.hpp" @@ -39,7 +39,7 @@ using std::string; #define NODE_094_UV_AFTER_WORK_CAST(x) (x) #endif -namespace gitteh { +namespace sgit { Handle GetModule(); static inline Handle CreateGitError() { @@ -116,7 +116,7 @@ namespace gitteh { return scope.Close(fastBuffer); } -} // namespace gitteh +} // namespace sgit namespace cvv8 { template<> @@ -182,4 +182,4 @@ namespace cvv8 { struct NativeToJS : public NativeToJS {}; } -#endif // GITTEH_H +#endif // SGIT_H diff --git a/src/signature.cc b/src/signature.cc deleted file mode 100644 index be6b439..0000000 --- a/src/signature.cc +++ /dev/null @@ -1,29 +0,0 @@ -#include "signature.h" - -static Persistent name_symbol; -static Persistent email_symbol; -static Persistent time_symbol; -static Persistent offset_symbol; - -namespace gitteh { - namespace Signature { - void Init() { - name_symbol = NODE_PSYMBOL("name"); - email_symbol = NODE_PSYMBOL("email"); - time_symbol = NODE_PSYMBOL("time"); - offset_symbol = NODE_PSYMBOL("offset"); - } - }; -}; - -namespace cvv8 { - Handle NativeToJS::operator() (git_signature const *sig) const { - HandleScope scope; - Handle o = Object::New(); - o->Set(name_symbol, CastToJS(sig->name)); - o->Set(email_symbol, CastToJS(sig->email)); - o->Set(time_symbol, Date::New(sig->when.time * 1000)); - o->Set(offset_symbol, CastToJS(sig->when.offset)); - return scope.Close(o); - } -}; diff --git a/src/signature.h b/src/signature.h deleted file mode 100644 index 2118c6f..0000000 --- a/src/signature.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef GITTEH_SIGNATURE_H -#define GITTEH_SIGNATURE_H - -#include "gitteh.h" - -namespace gitteh { - namespace Signature { - void Init(); - Handle Create(const git_signature *sig); - }; -}; - -namespace cvv8 { - template<> - struct NativeToJS { - Handle operator() (git_signature const *sig) const; - }; -}; - -#endif // GITTEH_SIGNATURE_H diff --git a/src/tag.cc b/src/tag.cc deleted file mode 100644 index c4ffbb8..0000000 --- a/src/tag.cc +++ /dev/null @@ -1,56 +0,0 @@ -/* - * The MIT License - * - * Copyright (c) 2010 Sam Day - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#include "tag.h" -#include "signature.h" - -static Persistent name_symbol; -static Persistent message_symbol; -static Persistent tagger_symbol; -static Persistent target_symbol; -static Persistent type_symbol; - -namespace gitteh { - namespace Tag { - void Init(Handle target) { - HandleScope scope; - name_symbol = NODE_PSYMBOL("name"); - message_symbol = NODE_PSYMBOL("message"); - tagger_symbol = NODE_PSYMBOL("tagger"); - target_symbol = NODE_PSYMBOL("target"); - type_symbol = NODE_PSYMBOL("type"); - } - - Handle Create(git_tag *tag) { - HandleScope scope; - Handle o = Object::New(); - o->Set(name_symbol, CastToJS(git_tag_name(tag))); - o->Set(message_symbol, CastToJS(git_tag_message(tag))); - o->Set(tagger_symbol, CastToJS(git_tag_tagger(tag))); - o->Set(target_symbol, CastToJS(git_tag_target_id(tag))); - o->Set(type_symbol, CastToJS(git_tag_target_type(tag))); - return scope.Close(o); - } - } -}; diff --git a/src/tag.h b/src/tag.h deleted file mode 100644 index 34b6775..0000000 --- a/src/tag.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef GITTEH_TAG_H -#define GITTEH_TAG_H - -#include "gitteh.h" - -namespace gitteh { - namespace Tag { - void Init(Handle); - Handle Create(git_tag*); - } -}; - -#endif // GITTEH_TAG_H diff --git a/src/thread.h b/src/thread.h index b4a3783..bd5b7c1 100644 --- a/src/thread.h +++ b/src/thread.h @@ -1,5 +1,5 @@ -#ifndef GITTEH_THREAD_H -#define GITTEH_THREAD_H +#ifndef SGIT_THREAD_H +#define SGIT_THREAD_H // I honestly have no clue what the fuck I'm doing. Libgit2 doesn't seem to be // thread-safe, so I need an object to synchronize with to prevent crazy shit @@ -13,7 +13,7 @@ // pthread_mutex_unlock? Just in case though I'm setting up macros for them here // so I can swap them out or write compiler/platform specific variants later. -typedef pthread_mutex_t gitteh_lock; +typedef pthread_mutex_t sgit_lock; #define CREATE_MUTEX(LOCK) \ pthread_mutex_init (&LOCK, NULL); @@ -27,4 +27,4 @@ typedef pthread_mutex_t gitteh_lock; pthread_mutex_unlock(&LOCK) -#endif // GITTEH_THREAD_H +#endif // SGIT_THREAD_H diff --git a/src/tree.cc b/src/tree.cc deleted file mode 100644 index e41bf64..0000000 --- a/src/tree.cc +++ /dev/null @@ -1,70 +0,0 @@ -/* - * The MIT License - * - * Copyright (c) 2010 Sam Day - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#include "tree.h" - -static Persistent id_symbol; -static Persistent entries_symbol; -static Persistent entry_id_symbol; -static Persistent entry_name_symbol; -static Persistent entry_type_symbol; -static Persistent entry_filemode_symbol; - -static Handle CreateEntry(const git_tree_entry *entry) { - HandleScope scope; - Handle o = Object::New(); - o->Set(entry_id_symbol, CastToJS(git_tree_entry_id(entry))); - o->Set(entry_name_symbol, CastToJS(git_tree_entry_name(entry))); - o->Set(entry_filemode_symbol, CastToJS(git_tree_entry_filemode(entry))); - o->Set(entry_type_symbol, CastToJS(git_tree_entry_type(entry))); - return scope.Close(o); -} - -namespace gitteh { - namespace Tree { - void Init(Handle target) { - HandleScope scope; - id_symbol = NODE_PSYMBOL("id"); - entries_symbol = NODE_PSYMBOL("entries"); - entry_id_symbol = NODE_PSYMBOL("id"); - entry_name_symbol = NODE_PSYMBOL("name"); - entry_type_symbol = NODE_PSYMBOL("type"); - entry_filemode_symbol = NODE_PSYMBOL("filemode"); - } - - Handle Create(git_tree *tree) { - HandleScope scope; - Handle o = Object::New(); - - Handle entries = Array::New(); - int entryCount = git_tree_entrycount(tree); - for(int i = 0; i < entryCount; i++) { - entries->Set(i, CreateEntry(git_tree_entry_byindex(tree, i))); - } - o->Set(entries_symbol, entries); - - return scope.Close(o); - } - }; -}; diff --git a/src/tree.h b/src/tree.h deleted file mode 100644 index 3909e6c..0000000 --- a/src/tree.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef GITTEH_TREE_H -#define GITTEH_TREE_H - -#include "gitteh.h" - -namespace gitteh { - namespace Tree { - void Init(Handle); - Handle Create(git_tree*); - }; -}; - -#endif // GITTEH_TREE_H \ No newline at end of file diff --git a/test/fixtures.coffee b/test/fixtures.coffee deleted file mode 100644 index 6abe7e2..0000000 --- a/test/fixtures.coffee +++ /dev/null @@ -1,31 +0,0 @@ -path = require "path" - -exports.projectRepo = - path: path.join __dirname, "../" - gitPath: path.join __dirname, "..", ".git/" - - firstCommit: - id: "1f4425ce2a14f21b96b9c8dde5bcfd3733467b14" - secondCommit: - id: "8a916d5fbce49f5780668a1ee780e0ef2e89360f" - tree: "aa41780f2129bf03cce1a3eeadc78db47f83d9ad" - parent: "1f4425ce2a14f21b96b9c8dde5bcfd3733467b14" - message: "Stuff." - wscriptBlob: "70cefa94cfaa928cd2b601d38be7ea221f0e219e" - -exports.testRepo = - path: path.join __dirname, "testrepo.git/" - firstCommit: - id: "8496071c1b46c854b31185ea97743be6a8774479" - message: "testing" - secondCommit: - author: - name: "Scott Chacon" - email: "schacon@gmail.com" - time: "Tue, 11 May 2010 20:38:42 GMT" - offset: -420 - id: "5b5b025afb0b4c913b4c338a42934a3863bf3644" - tree: "f60079018b664e4e79329a7ef9559c8d9e0378d1" - parent: "8496071c1b46c854b31185ea97743be6a8774479" - message: "another commit" - readmeBlob: "1385f264afb75a56a5bec74243be9b367ba4ca08" diff --git a/test/stress/cached_object.coffee b/test/stress/cached_object.coffee deleted file mode 100644 index 65cafb0..0000000 --- a/test/stress/cached_object.coffee +++ /dev/null @@ -1,12 +0,0 @@ -gitteh = require "../../lib/gitteh" -{projectRepo} = require "../fixtures" - - -gitteh.openRepository projectRepo.path, (err, repo) -> - repo.exists projectRepo.secondCommit.id, (err, exists) -> - repo.commit projectRepo.secondCommit.id, (err, commit) -> - repo.commit projectRepo.secondCommit.id, (err, commit) -> - console.log "sigh." - - #repo.blob projectRepo.secondCommit.wscriptBlob, (err, blob) -> - # console.log blob \ No newline at end of file diff --git a/test/stress/index.js b/test/stress/index.js deleted file mode 100644 index 1f92d59..0000000 --- a/test/stress/index.js +++ /dev/null @@ -1,2 +0,0 @@ -coffeescript = require("coffee-script"); -require("./runner"); \ No newline at end of file diff --git a/test/stress/repository.coffee b/test/stress/repository.coffee deleted file mode 100644 index e89e447..0000000 --- a/test/stress/repository.coffee +++ /dev/null @@ -1,75 +0,0 @@ -# Open 1000 copies of the same repository location in one async batch, ensure -# each one behaves normally. - -gitteh = require "../../lib/gitteh" -{projectRepo} = require "../fixtures" -assert = require "assert" -async = require "async" - -openCommitAndTree = (i, cb) -> - gitteh.openRepository projectRepo.path, (err, repo) -> - assert repo - async.parallel - commit: (cb) -> repo.commit projectRepo.secondCommit.id, cb - tree: (cb) -> repo.tree projectRepo.secondCommit.tree, cb - , (err, results) -> - return cb err if err? - assert results.commit.id is projectRepo.secondCommit.id - assert results.tree.id is projectRepo.secondCommit.tree - cb() - -openCommitAndTreeSeparately = (i, cb) -> - async.parallel - commit: (cb) -> - gitteh.openRepository projectRepo.path, (err, repo) -> - return cb err if err? - assert repo - repo.commit projectRepo.secondCommit.id, cb - ### - tree: (cb) -> - gitteh.openRepository projectRepo.path, (err, repo) -> - assert repo - repo.tree projectRepo.secondCommit.tree, cb - ### - , cb - -sameCommit = (i, cb) -> - gitteh.openRepository projectRepo.path, (err, repo) -> - return cb err if err? - - async.forEach [1..1000], (i, cb) -> - repo.commit projectRepo.secondCommit.id, (err, commit) -> - return cb err if err? - assert commit.id is projectRepo.secondCommit.id - # console.log cb - cb() - repo.tree projectRepo.secondCommit.tree, (err, tree) -> - return cb err if err? - assert tree.id is projectRepo.secondCommit.tree - # console.log cb - cb() - , () -> - # gc() - cb() - -module.exports = (cb) -> - async.series - openCommitAndTree: (cb) -> - console.time "openCommitAndTree" - async.forEach [1..1000], openCommitAndTree, (err) -> - return cb err if err? - console.timeEnd "openCommitAndTree" - cb() - openCommitAndTreeSeparately: (cb) -> - console.time "openCommitAndTreeSeparately" - async.forEach [1..1000], openCommitAndTreeSeparately, (err) -> - return cb err if err? - console.timeEnd "openCommitAndTreeSeparately" - cb() - sameCommit: (cb) -> - console.time "sameCommit" - async.forEach [1..1000], sameCommit, (err) -> - return cb err if err? - console.timeEnd "sameCommit" - cb() - , cb diff --git a/test/stress/runner.coffee b/test/stress/runner.coffee deleted file mode 100644 index 010bbd6..0000000 --- a/test/stress/runner.coffee +++ /dev/null @@ -1,2 +0,0 @@ -require("./repository") -> - console.log "Done!", arguments \ No newline at end of file diff --git a/test/test.blob.coffee b/test/test.blob.coffee deleted file mode 100644 index 6f3fa9f..0000000 --- a/test/test.blob.coffee +++ /dev/null @@ -1,35 +0,0 @@ -path = require "path" -should = require "should" -crypto = require "crypto" -gitteh = require "../lib/gitteh" -utils = require "./utils" -fixtures = require "./fixtures" - -secondCommit = fixtures.testRepo.secondCommit - -describe "Blob", -> - repo = null - blob = null - - describe "Using the test repo...", -> - it "can find the README blob (#{secondCommit.readmeBlob}) file in second commit", (done) -> - gitteh.openRepository fixtures.testRepo.path, (err, _repo) -> - repo = _repo - repo.blob secondCommit.readmeBlob, (err, _blob) -> - should.not.exist err - blob = _blob - blob.should.be.an.instanceof gitteh.Blob - done() - describe "#id", -> - it "is correct", -> - blob.id.should.equal secondCommit.readmeBlob - it "is immutable", -> utils.checkImmutable blob, "id" - describe "#data", -> - it "is a Buffer", -> - blob.data.should.be.an.instanceof Buffer - it "has correct contents", -> - shasum = crypto.createHash "sha1" - shasum.update "blob #{blob.data.length}\u0000" - shasum.update blob.data.toString("binary") - shasum.digest("hex").should.equal blob.id - it "is immutable", -> utils.checkImmutable blob, "data" diff --git a/test/test.commit.coffee b/test/test.commit.coffee deleted file mode 100644 index 10de542..0000000 --- a/test/test.commit.coffee +++ /dev/null @@ -1,88 +0,0 @@ -path = require "path" -should = require "should" -gitteh = require "../lib/gitteh" -utils = require "./utils" -fixtures = require "./fixtures" - -secondCommit = fixtures.testRepo.secondCommit - -describe "Commit", -> - repo = null - commit = null - - describe "Using the test repo...", -> - it "can find second commit (#{secondCommit.id})", (done) -> - gitteh.openRepository fixtures.testRepo.path, (err, _repo) -> - repo = _repo - repo.commit secondCommit.id, (err, _commit) -> - commit = _commit - should.not.exist err - commit.should.be.an.instanceof gitteh.Commit - done() - describe "The first project commit...", -> - describe "#id", -> - it "is correct", -> - commit.id.should.be.equal secondCommit.id - it "is immutable", -> utils.checkImmutable commit, "id" - describe "#treeId", -> - it "is correct", -> - commit.treeId.should.be.equal secondCommit.tree - it "is immutable", -> utils.checkImmutable commit, "treeId" - describe "#message", -> - it "is correct", -> - commit.message.should.be.equal - it "is immutable", -> utils.checkImmutable commit, "message" - describe "#parents", -> - it "is correct", -> - commit.parents.should.have.length 1 - commit.parents.should.include secondCommit.parent - describe "#author", -> - it "is valid", -> - author = commit.author - author.should.be.a "object" - should.exist author.name - should.exist author.email - should.exist author.time - should.exist author.offset - it "is immutable", -> utils.checkImmutable commit, "author" - describe "#name", -> - it "is valid", -> - commit.author.name.should.be.equal secondCommit.author.name - it "is immutable", -> utils.checkImmutable commit.author, "name" - describe "#email", -> - it "is valid", -> - commit.author.email.should.be.equal secondCommit.author.email - it "is immutable", -> utils.checkImmutable commit.author, "email" - describe "#time", -> - it "is valid", -> - commit.author.time.toUTCString().should.be.equal secondCommit.author.time - it "is immutable", -> utils.checkImmutable commit.author, "time" - describe "#offset", -> - it "is valid", -> - commit.author.offset.should.equal secondCommit.author.offset - it "is immutable", -> utils.checkImmutable commit.author, "offset" - describe "#committer", -> - it "is valid", -> - committer = commit.committer - committer.should.be.a "object" - should.exist committer.name - should.exist committer.email - should.exist committer.time - should.exist committer.offset - it "is immutable", -> utils.checkImmutable commit, "committer" - describe "#name", -> - it "is valid", -> - commit.committer.name.should.be.equal secondCommit.author.name - it "is immutable", -> utils.checkImmutable commit.committer, "name" - describe "#email", -> - it "is valid", -> - commit.committer.email.should.be.equal secondCommit.author.email - it "is immutable", -> utils.checkImmutable commit.committer, "email" - describe "#time", -> - it "is valid", -> - commit.committer.time.toUTCString().should.be.equal secondCommit.author.time - it "is immutable", -> utils.checkImmutable commit.committer, "time" - describe "#offset", -> - it "is valid", -> - commit.committer.offset.should.equal secondCommit.author.offset - it "is immutable", -> utils.checkImmutable commit.committer, "offset" diff --git a/test/test.gitteh.coffee b/test/test.gitteh.coffee deleted file mode 100644 index 3ad7f45..0000000 --- a/test/test.gitteh.coffee +++ /dev/null @@ -1,42 +0,0 @@ -path = require "path" -wrench = require "wrench" -temp = require "temp" -gitteh = require "../lib/gitteh" -fixtures = require "./fixtures" - -describe "Gitteh", -> - describe "#openRepository()", -> - describe "on an invalid path", -> - it "should fail with an Exception", (done) -> - gitteh.openRepository "/i/shouldnt/exist", (err) -> - err.should.be.an.instanceof Error - done() - describe "on project repo", -> - repo = null - it "should open correctly", (done) -> - gitteh.openRepository fixtures.testRepo.path, (err, _repo) -> - repo = _repo - repo.should.be.an.instanceof gitteh.Repository - done() - - describe "#initRepository()", -> - describe "on an invalid path", -> - it "should fail with an Exception", (done) -> - gitteh.initRepository "/i/shouldnt/exist", (err) -> - err.should.be.an.instanceof Error - done() - describe "initializing a bare repository", -> - tempPath = "#{temp.path()}/" - repo = null - describe "to temp location #{tempPath}", -> - after -> - wrench.rmdirSyncRecursive tempPath, true - it "should initialize correctly", (done) -> - gitteh.initRepository tempPath, true, (err, _repo) -> - repo = _repo - repo.should.be.an.instanceof gitteh.Repository - done() - it "should definitely be bare", -> - repo.bare.should.be.true - it "should be in the right place", -> - repo.path.should.be.equal tempPath diff --git a/test/test.reference.coffee b/test/test.reference.coffee deleted file mode 100644 index df8f2b7..0000000 --- a/test/test.reference.coffee +++ /dev/null @@ -1,62 +0,0 @@ -path = require "path" -should = require "should" -fs = require "fs" -gitteh = require "../lib/gitteh" -utils = require "./utils" -fixtures = require "./fixtures" - -secondCommit = fixtures.testRepo.secondCommit - -describe "Reference", -> - repo = null - ref = null - headFile = null - - describe "Using the project repo...", -> - it "can find the HEAD sym reference", (done) -> - gitteh.openRepository fixtures.testRepo.path, (err, _repo) -> - repo = _repo - - # We'll need this later. - headPath = path.join repo.path, "HEAD" - headFile = fs.readFileSync(headPath, "utf8")[5..-2] - - repo.ref "HEAD", false, (err, ref_) -> - should.not.exist err - ref = ref_ - ref.should.be.an.instanceof gitteh.Reference - done() - describe "The HEAD sym reference", -> - describe "#name", -> - it "should be HEAD", -> ref.name.should.equal "HEAD" - it "should be immutable", -> utils.checkImmutable ref, "name" - describe "#target", -> - it "should point to .git/HEAD", -> - ref.target.should.equal headFile - it "should be immutable", -> utils.checkImmutable ref, "target" - describe "#direct", -> - it "should be false", -> ref.direct.should.be.false - it "should be immutable", -> utils.checkImmutable ref, "direct" - describe "Resolving HEAD", -> - it "gives us correct resolved direct ref", -> - repo.ref "HEAD", true, (err, ref) -> - should.not.exist err - ref.name.should.equal headFile - describe "Creating a direct reference to second commit", -> - newRef = null - after (cb) -> - fs.unlink path.join(repo.path, "refs", "heads", "testref"), cb - it "works", (done) -> - repo.createReference "refs/heads/testref", secondCommit.id, (err, _ref) -> - newRef = _ref - should.not.exist err - newRef.should.be.an.instanceof gitteh.Reference - done() - it "should have correct data", -> - newRef.name.should.equal "refs/heads/testref" - newRef.target.should.equal secondCommit.id - it "should fail when trying to create ref with same name again", (done) -> - repo.createReference "refs/heads/testref", secondCommit.id, (err, _ref) -> - should.exist err - err.should.be.an.instanceof Error - done() diff --git a/test/test.repository.coffee b/test/test.repository.coffee deleted file mode 100644 index 10e8a2a..0000000 --- a/test/test.repository.coffee +++ /dev/null @@ -1,88 +0,0 @@ -path = require "path" -should = require "should" -gitteh = require "../lib/gitteh" -fixtures = require "./fixtures" - -describe "Repository", -> - describe "Using the test repo...", -> - repo = null - it "opens correctly", (done) -> - gitteh.openRepository fixtures.testRepo.path, (err, _repo) -> - repo = _repo - repo.should.be.an.instanceof gitteh.Repository - done() - describe "#bare", -> - it "should be true for this repo", -> - repo.bare.should.be.true - it "should be immutable", -> - repo.bare = 123 - repo.bare.should.be.true - delete repo.path - repo.bare.should.be.true - describe "#path", -> - it "should point to #{fixtures.testRepo.path}", -> - repo.path.should.equal fixtures.testRepo.path - it "should be immutable", -> - repo.path = "foo" - repo.path.should.equal fixtures.testRepo.path - delete repo.path - repo.path.should.equal fixtures.testRepo.path - describe "#workingDirectory", -> - it "should be null", -> - should.not.exist repo.workingDirectory - describe "#exists()", -> - it "should return true for first commit in repo :)", (done) -> - repo.exists fixtures.testRepo.firstCommit.id, (err, exists) -> - exists.should.be.true - done() - it "should reject invalid oids", -> - # Completely invalid oid. - (-> - repo.exists "!!!" - ).should.throw() - - # Valid oid, but full 40 char oids are required for exists() - (-> - repo.exists "abcd123" - ).should.throw() - describe "#object()", -> - it "works for full OID", (done) -> - repo.object fixtures.testRepo.secondCommit.id, (err, obj) -> - should.not.exist err - obj.should.be.an.instanceof gitteh.Commit - done() - it "works for shortened OID", (done) -> - repo.object fixtures.testRepo.secondCommit.id[..8], (err, obj) -> - should.not.exist err - obj.should.be.an.instanceof gitteh.Commit - done() - describe "#commit()", -> - it "works", (done) -> - repo.commit fixtures.testRepo.secondCommit.id, (err, obj) -> - should.not.exist err - obj.should.be.an.instanceof gitteh.Commit - done() - it "fails for objects that aren't a commit", (done) -> - repo.commit fixtures.testRepo.secondCommit.readmeBlob, (err, obj) -> - should.exist err - done() - describe "#tree()", -> - it "works", (done) -> - repo.tree fixtures.testRepo.secondCommit.tree, (err, obj) -> - should.not.exist err - obj.should.be.an.instanceof gitteh.Tree - done() - it "fails for objects that aren't a tree", (done) -> - repo.tree fixtures.testRepo.secondCommit.id, (err, obj) -> - should.exist err - done() - describe "#blob()", -> - it "works", (done) -> - repo.blob fixtures.testRepo.secondCommit.readmeBlob, (err, obj) -> - should.not.exist err - obj.should.be.an.instanceof gitteh.Blob - done() - it "fails for objects that aren't a blob", (done) -> - repo.blob fixtures.testRepo.secondCommit.id, (err, obj) -> - should.exist err - done() diff --git a/test/test.tree.coffee b/test/test.tree.coffee deleted file mode 100644 index 6f6ee44..0000000 --- a/test/test.tree.coffee +++ /dev/null @@ -1,30 +0,0 @@ -path = require "path" -should = require "should" -gitteh = require "../lib/gitteh" -utils = require "./utils" -fixtures = require "./fixtures" - -secondCommit = fixtures.testRepo.secondCommit - -describe "Tree", -> - repo = null - tree = null - - describe "Using the test repo...", -> - it "can find second commit tree (#{secondCommit.tree})", (done) -> - gitteh.openRepository fixtures.testRepo.path, (err, _repo) -> - repo = _repo - - repo.tree secondCommit.tree, (err, _tree) -> - tree = _tree - should.not.exist err - tree.should.be.an.instanceof gitteh.Tree - done() - describe "The second project commit tree...", -> - describe "#id", -> - it "is correct", -> - tree.id.should.equal secondCommit.tree - it "is immutable", -> utils.checkImmutable tree, "id" - describe "#entries", -> - it "are correct", -> - diff --git a/test/testrepo.git/FETCH_HEAD b/test/testrepo.git/FETCH_HEAD deleted file mode 100644 index 4844626..0000000 --- a/test/testrepo.git/FETCH_HEAD +++ /dev/null @@ -1,2 +0,0 @@ -a65fedf39aefe402d3bb6e24df4d4f5fe4547750 branch 'master' of git://example.com/git/testrepo.git -258f0e2a959a364e40ed6603d5d44fbb24765b10 not-for-merge branch 'haacked' of git://example.com/git/testrepo.git diff --git a/test/testrepo.git/HEAD b/test/testrepo.git/HEAD deleted file mode 100644 index cb089cd..0000000 --- a/test/testrepo.git/HEAD +++ /dev/null @@ -1 +0,0 @@ -ref: refs/heads/master diff --git a/test/testrepo.git/HEAD_TRACKER b/test/testrepo.git/HEAD_TRACKER deleted file mode 100644 index 40d876b..0000000 --- a/test/testrepo.git/HEAD_TRACKER +++ /dev/null @@ -1 +0,0 @@ -ref: HEAD diff --git a/test/testrepo.git/config b/test/testrepo.git/config deleted file mode 100644 index 904a4e3..0000000 --- a/test/testrepo.git/config +++ /dev/null @@ -1,36 +0,0 @@ -[core] - repositoryformatversion = 0 - filemode = true - bare = true - logallrefupdates = true -[remote "test"] - url = git://github.com/libgit2/libgit2 - fetch = +refs/heads/*:refs/remotes/test/* -[remote "joshaber"] - url = git://github.com/libgit2/libgit2 -[remote "empty-remote-url"] - url = - -[remote "test_with_pushurl"] - url = git://github.com/libgit2/fetchlibgit2 - pushurl = git://github.com/libgit2/pushlibgit2 - fetch = +refs/heads/*:refs/remotes/test_with_pushurl/* - -[branch "master"] - remote = test - merge = refs/heads/master -[branch "track-local"] - remote = . - merge = refs/heads/master -[branch "cannot-fetch"] - remote = joshaber - merge = refs/heads/cannot-fetch -[branch "remoteless"] - remote = - merge = refs/heads/master -[branch "mergeless"] - remote = test - merge = -[branch "mergeandremoteless"] - remote = - merge = diff --git a/test/testrepo.git/index b/test/testrepo.git/index deleted file mode 100644 index a27fb9c..0000000 Binary files a/test/testrepo.git/index and /dev/null differ diff --git a/test/testrepo.git/logs/HEAD b/test/testrepo.git/logs/HEAD deleted file mode 100644 index 9413b72..0000000 --- a/test/testrepo.git/logs/HEAD +++ /dev/null @@ -1,7 +0,0 @@ -0000000000000000000000000000000000000000 be3563ae3f795b2b4353bcce3a527ad0a4f7f644 Ben Straub 1335806563 -0700 clone: from /Users/ben/src/libgit2/tests/resources/testrepo.git -be3563ae3f795b2b4353bcce3a527ad0a4f7f644 a65fedf39aefe402d3bb6e24df4d4f5fe4547750 Ben Straub 1335806603 -0900 commit: -a65fedf39aefe402d3bb6e24df4d4f5fe4547750 5b5b025afb0b4c913b4c338a42934a3863bf3644 Ben Straub 1335806604 -0900 checkout: moving from master to 5b5b025 -5b5b025afb0b4c913b4c338a42934a3863bf3644 a65fedf39aefe402d3bb6e24df4d4f5fe4547750 Ben Straub 1335806605 -0900 checkout: moving from 5b5b025 to master -a65fedf39aefe402d3bb6e24df4d4f5fe4547750 c47800c7266a2be04c571c04d5a6614691ea99bd Ben Straub 1335806608 -0900 checkout: moving from master to br2 -c47800c7266a2be04c571c04d5a6614691ea99bd a4a7dce85cf63874e984719f4fdd239f5145052f Ben Straub 1335806617 -0900 commit: checking in -a4a7dce85cf63874e984719f4fdd239f5145052f a65fedf39aefe402d3bb6e24df4d4f5fe4547750 Ben Straub 1335806621 -0900 checkout: moving from br2 to master diff --git a/test/testrepo.git/logs/refs/heads/br2 b/test/testrepo.git/logs/refs/heads/br2 deleted file mode 100644 index 4e27f6b..0000000 --- a/test/testrepo.git/logs/refs/heads/br2 +++ /dev/null @@ -1,2 +0,0 @@ -0000000000000000000000000000000000000000 c47800c7266a2be04c571c04d5a6614691ea99bd Ben Straub 1335806608 -0700 branch: Created from refs/remotes/origin/br2 -a4a7dce85cf63874e984719f4fdd239f5145052f a4a7dce85cf63874e984719f4fdd239f5145052f Ben Straub 1335806617 -0700 commit: checking in diff --git a/test/testrepo.git/logs/refs/heads/master b/test/testrepo.git/logs/refs/heads/master deleted file mode 100644 index e1c729a..0000000 --- a/test/testrepo.git/logs/refs/heads/master +++ /dev/null @@ -1,2 +0,0 @@ -0000000000000000000000000000000000000000 be3563ae3f795b2b4353bcce3a527ad0a4f7f644 Ben Straub 1335806563 -0800 clone: from /Users/ben/src/libgit2/tests/resources/testrepo.git -be3563ae3f795b2b4353bcce3a527ad0a4f7f644 a65fedf39aefe402d3bb6e24df4d4f5fe4547750 Ben Straub 1335806603 -0800 commit: checking in diff --git a/test/testrepo.git/logs/refs/heads/not-good b/test/testrepo.git/logs/refs/heads/not-good deleted file mode 100644 index bfbeacb..0000000 --- a/test/testrepo.git/logs/refs/heads/not-good +++ /dev/null @@ -1 +0,0 @@ -0000000000000000000000000000000000000000 a65fedf39aefe402d3bb6e24df4d4f5fe4547750 Ben Straub 1336761944 -0700 branch: Created from master diff --git a/test/testrepo.git/logs/refs/remotes/origin/HEAD b/test/testrepo.git/logs/refs/remotes/origin/HEAD deleted file mode 100644 index f1aac6d..0000000 --- a/test/testrepo.git/logs/refs/remotes/origin/HEAD +++ /dev/null @@ -1 +0,0 @@ -0000000000000000000000000000000000000000 be3563ae3f795b2b4353bcce3a527ad0a4f7f644 Ben Straub 1335806563 -0700 clone: from /Users/ben/src/libgit2/tests/resources/testrepo.git diff --git a/test/testrepo.git/logs/refs/remotes/test/master b/test/testrepo.git/logs/refs/remotes/test/master deleted file mode 100644 index 8d49ba3..0000000 --- a/test/testrepo.git/logs/refs/remotes/test/master +++ /dev/null @@ -1,2 +0,0 @@ -0000000000000000000000000000000000000000 a65fedf39aefe402d3bb6e24df4d4f5fe4547750 Ben Straub 1335806565 -0800 update by push -a65fedf39aefe402d3bb6e24df4d4f5fe4547750 be3563ae3f795b2b4353bcce3a527ad0a4f7f644 Ben Straub 1335806688 -0800 update by push diff --git a/test/testrepo.git/objects/08/b041783f40edfe12bb406c9c9a8a040177c125 b/test/testrepo.git/objects/08/b041783f40edfe12bb406c9c9a8a040177c125 deleted file mode 100644 index d1c032f..0000000 Binary files a/test/testrepo.git/objects/08/b041783f40edfe12bb406c9c9a8a040177c125 and /dev/null differ diff --git a/test/testrepo.git/objects/13/85f264afb75a56a5bec74243be9b367ba4ca08 b/test/testrepo.git/objects/13/85f264afb75a56a5bec74243be9b367ba4ca08 deleted file mode 100644 index cedb2a2..0000000 Binary files a/test/testrepo.git/objects/13/85f264afb75a56a5bec74243be9b367ba4ca08 and /dev/null differ diff --git a/test/testrepo.git/objects/18/1037049a54a1eb5fab404658a3a250b44335d7 b/test/testrepo.git/objects/18/1037049a54a1eb5fab404658a3a250b44335d7 deleted file mode 100644 index 93a16f1..0000000 Binary files a/test/testrepo.git/objects/18/1037049a54a1eb5fab404658a3a250b44335d7 and /dev/null differ diff --git a/test/testrepo.git/objects/18/10dff58d8a660512d4832e740f692884338ccd b/test/testrepo.git/objects/18/10dff58d8a660512d4832e740f692884338ccd deleted file mode 100644 index ba0bfb3..0000000 Binary files a/test/testrepo.git/objects/18/10dff58d8a660512d4832e740f692884338ccd and /dev/null differ diff --git a/test/testrepo.git/objects/1a/443023183e3f2bfbef8ac923cd81c1018a18fd b/test/testrepo.git/objects/1a/443023183e3f2bfbef8ac923cd81c1018a18fd deleted file mode 100644 index 3ec5412..0000000 Binary files a/test/testrepo.git/objects/1a/443023183e3f2bfbef8ac923cd81c1018a18fd and /dev/null differ diff --git a/test/testrepo.git/objects/1b/8cbad43e867676df601306689fe7c3def5e689 b/test/testrepo.git/objects/1b/8cbad43e867676df601306689fe7c3def5e689 deleted file mode 100644 index 6048d4b..0000000 Binary files a/test/testrepo.git/objects/1b/8cbad43e867676df601306689fe7c3def5e689 and /dev/null differ diff --git a/test/testrepo.git/objects/1f/67fc4386b2d171e0d21be1c447e12660561f9b b/test/testrepo.git/objects/1f/67fc4386b2d171e0d21be1c447e12660561f9b deleted file mode 100644 index 225c457..0000000 Binary files a/test/testrepo.git/objects/1f/67fc4386b2d171e0d21be1c447e12660561f9b and /dev/null differ diff --git a/test/testrepo.git/objects/25/8f0e2a959a364e40ed6603d5d44fbb24765b10 b/test/testrepo.git/objects/25/8f0e2a959a364e40ed6603d5d44fbb24765b10 deleted file mode 100644 index cb1ed57..0000000 Binary files a/test/testrepo.git/objects/25/8f0e2a959a364e40ed6603d5d44fbb24765b10 and /dev/null differ diff --git a/test/testrepo.git/objects/27/0b8ea76056d5cad83af921837702d3e3c2924d b/test/testrepo.git/objects/27/0b8ea76056d5cad83af921837702d3e3c2924d deleted file mode 100644 index df40d99..0000000 Binary files a/test/testrepo.git/objects/27/0b8ea76056d5cad83af921837702d3e3c2924d and /dev/null differ diff --git a/test/testrepo.git/objects/2d/59075e0681f540482d4f6223a68e0fef790bc7 b/test/testrepo.git/objects/2d/59075e0681f540482d4f6223a68e0fef790bc7 deleted file mode 100644 index 0a1500a..0000000 Binary files a/test/testrepo.git/objects/2d/59075e0681f540482d4f6223a68e0fef790bc7 and /dev/null differ diff --git a/test/testrepo.git/objects/32/59a6bd5b57fb9c1281bb7ed3167b50f224cb54 b/test/testrepo.git/objects/32/59a6bd5b57fb9c1281bb7ed3167b50f224cb54 deleted file mode 100644 index 321eaa8..0000000 Binary files a/test/testrepo.git/objects/32/59a6bd5b57fb9c1281bb7ed3167b50f224cb54 and /dev/null differ diff --git a/test/testrepo.git/objects/36/97d64be941a53d4ae8f6a271e4e3fa56b022cc b/test/testrepo.git/objects/36/97d64be941a53d4ae8f6a271e4e3fa56b022cc deleted file mode 100644 index 9bb5b62..0000000 Binary files a/test/testrepo.git/objects/36/97d64be941a53d4ae8f6a271e4e3fa56b022cc and /dev/null differ diff --git a/test/testrepo.git/objects/45/b983be36b73c0788dc9cbcb76cbb80fc7bb057 b/test/testrepo.git/objects/45/b983be36b73c0788dc9cbcb76cbb80fc7bb057 deleted file mode 100644 index 7ca4cee..0000000 Binary files a/test/testrepo.git/objects/45/b983be36b73c0788dc9cbcb76cbb80fc7bb057 and /dev/null differ diff --git a/test/testrepo.git/objects/4a/202b346bb0fb0db7eff3cffeb3c70babbd2045 b/test/testrepo.git/objects/4a/202b346bb0fb0db7eff3cffeb3c70babbd2045 deleted file mode 100644 index 8953b6c..0000000 --- a/test/testrepo.git/objects/4a/202b346bb0fb0db7eff3cffeb3c70babbd2045 +++ /dev/null @@ -1,2 +0,0 @@ -xQ -0D)6ͦ "xO-FbEo0 Ǥ,ske[Pn8R,EpD?g}^3 <GhYK8ЖDA);gݧjp4-r;sGA4ۺ=(in7IKFE \ No newline at end of file diff --git a/test/testrepo.git/objects/4a/23e2e65ad4e31c4c9db7dc746650bfad082679 b/test/testrepo.git/objects/4a/23e2e65ad4e31c4c9db7dc746650bfad082679 deleted file mode 100644 index 18e3964..0000000 Binary files a/test/testrepo.git/objects/4a/23e2e65ad4e31c4c9db7dc746650bfad082679 and /dev/null differ diff --git a/test/testrepo.git/objects/4b/22b35d44b5a4f589edf3dc89196399771796ea b/test/testrepo.git/objects/4b/22b35d44b5a4f589edf3dc89196399771796ea deleted file mode 100644 index b4e5aa1..0000000 Binary files a/test/testrepo.git/objects/4b/22b35d44b5a4f589edf3dc89196399771796ea and /dev/null differ diff --git a/test/testrepo.git/objects/52/1d87c1ec3aef9824daf6d96cc0ae3710766d91 b/test/testrepo.git/objects/52/1d87c1ec3aef9824daf6d96cc0ae3710766d91 deleted file mode 100644 index 351cff8..0000000 Binary files a/test/testrepo.git/objects/52/1d87c1ec3aef9824daf6d96cc0ae3710766d91 and /dev/null differ diff --git a/test/testrepo.git/objects/5b/5b025afb0b4c913b4c338a42934a3863bf3644 b/test/testrepo.git/objects/5b/5b025afb0b4c913b4c338a42934a3863bf3644 deleted file mode 100644 index c1f22c5..0000000 --- a/test/testrepo.git/objects/5b/5b025afb0b4c913b4c338a42934a3863bf3644 +++ /dev/null @@ -1,2 +0,0 @@ -x 1ENi@k2 "X$YW0YcÅszMD08!s Xgd::@X0Pw"F/RUzmZZV}|/o5I!1z:vUim}/> -F- \ No newline at end of file diff --git a/test/testrepo.git/objects/75/057dd4114e74cca1d750d0aee1647c903cb60a b/test/testrepo.git/objects/75/057dd4114e74cca1d750d0aee1647c903cb60a deleted file mode 100644 index 2ef4faa..0000000 Binary files a/test/testrepo.git/objects/75/057dd4114e74cca1d750d0aee1647c903cb60a and /dev/null differ diff --git a/test/testrepo.git/objects/76/3d71aadf09a7951596c9746c024e7eece7c7af b/test/testrepo.git/objects/76/3d71aadf09a7951596c9746c024e7eece7c7af deleted file mode 100644 index 716b0c6..0000000 --- a/test/testrepo.git/objects/76/3d71aadf09a7951596c9746c024e7eece7c7af +++ /dev/null @@ -1 +0,0 @@ -xAj!?009o}H6}jUPPZ&Y AԛpFdpz[fYPqLJ.,Z`Ů.`v q $5+9Ot>/DE/龡W*eVdf1>覭ěʙFThk.i^0?PR, \ No newline at end of file diff --git a/test/testrepo.git/objects/7b/4384978d2493e851f9cca7858815fac9b10980 b/test/testrepo.git/objects/7b/4384978d2493e851f9cca7858815fac9b10980 deleted file mode 100644 index 23c462f..0000000 Binary files a/test/testrepo.git/objects/7b/4384978d2493e851f9cca7858815fac9b10980 and /dev/null differ diff --git a/test/testrepo.git/objects/81/4889a078c031f61ed08ab5fa863aea9314344d b/test/testrepo.git/objects/81/4889a078c031f61ed08ab5fa863aea9314344d deleted file mode 100644 index 2f9b6b6..0000000 Binary files a/test/testrepo.git/objects/81/4889a078c031f61ed08ab5fa863aea9314344d and /dev/null differ diff --git a/test/testrepo.git/objects/84/96071c1b46c854b31185ea97743be6a8774479 b/test/testrepo.git/objects/84/96071c1b46c854b31185ea97743be6a8774479 deleted file mode 100644 index 5df58dd..0000000 Binary files a/test/testrepo.git/objects/84/96071c1b46c854b31185ea97743be6a8774479 and /dev/null differ diff --git a/test/testrepo.git/objects/84/9a5e34a26815e821f865b8479f5815a47af0fe b/test/testrepo.git/objects/84/9a5e34a26815e821f865b8479f5815a47af0fe deleted file mode 100644 index 71019a6..0000000 --- a/test/testrepo.git/objects/84/9a5e34a26815e821f865b8479f5815a47af0fe +++ /dev/null @@ -1,2 +0,0 @@ -xM F]s41x(IKݽ/_P@!8)es - N&FGSƄh{+CZzvF7Z-kx\[P8GK/^ l>.4 \ No newline at end of file diff --git a/test/testrepo.git/objects/94/4c0f6e4dfa41595e6eb3ceecdb14f50fe18162 b/test/testrepo.git/objects/94/4c0f6e4dfa41595e6eb3ceecdb14f50fe18162 deleted file mode 100644 index 4cc3f4d..0000000 --- a/test/testrepo.git/objects/94/4c0f6e4dfa41595e6eb3ceecdb14f50fe18162 +++ /dev/null @@ -1 +0,0 @@ -x+)JMU044b040031QrutueXlmmAṃJ}G;UTWRQ`6Kǥ^/-*|W3Py`%E\&g|0{Ӎ1X \ No newline at end of file diff --git a/test/testrepo.git/objects/9a/03079b8a8ee85a0bee58bf9be3da8b62414ed4 b/test/testrepo.git/objects/9a/03079b8a8ee85a0bee58bf9be3da8b62414ed4 deleted file mode 100644 index bf7b2bb..0000000 Binary files a/test/testrepo.git/objects/9a/03079b8a8ee85a0bee58bf9be3da8b62414ed4 and /dev/null differ diff --git a/test/testrepo.git/objects/9f/13f7d0a9402c681f91dc590cf7b5470e6a77d2 b/test/testrepo.git/objects/9f/13f7d0a9402c681f91dc590cf7b5470e6a77d2 deleted file mode 100644 index 7f1cfb2..0000000 --- a/test/testrepo.git/objects/9f/13f7d0a9402c681f91dc590cf7b5470e6a77d2 +++ /dev/null @@ -1,2 +0,0 @@ -xM -0F]d2;XEȎ5R AE &n}ZA \ No newline at end of file diff --git a/test/testrepo.git/objects/9f/d738e8f7967c078dceed8190330fc8648ee56a b/test/testrepo.git/objects/9f/d738e8f7967c078dceed8190330fc8648ee56a deleted file mode 100644 index a796124..0000000 --- a/test/testrepo.git/objects/9f/d738e8f7967c078dceed8190330fc8648ee56a +++ /dev/null @@ -1,3 +0,0 @@ -x[ -0E*fդ "W0-Ft݁pS[Yx^ -Db CLhut}8X*4ZsYUA X3RM) s6輢Mរ&Jm;}<\@ޏpĀv?jۺL?H \ No newline at end of file diff --git a/test/testrepo.git/objects/a4/a7dce85cf63874e984719f4fdd239f5145052f b/test/testrepo.git/objects/a4/a7dce85cf63874e984719f4fdd239f5145052f deleted file mode 100644 index f858869..0000000 --- a/test/testrepo.git/objects/a4/a7dce85cf63874e984719f4fdd239f5145052f +++ /dev/null @@ -1,2 +0,0 @@ -x;j1Dmdǎ|M3`V{ >QvL0I?!4Z=!צ8F!rsQy9]$D&l6A>jFWҵ IKNiZ%S - U~̽>' w [ DGڡQ-M>dO}\8g_ШoYr \ No newline at end of file diff --git a/test/testrepo.git/objects/a6/5fedf39aefe402d3bb6e24df4d4f5fe4547750 b/test/testrepo.git/objects/a6/5fedf39aefe402d3bb6e24df4d4f5fe4547750 deleted file mode 100644 index 29c8e82..0000000 --- a/test/testrepo.git/objects/a6/5fedf39aefe402d3bb6e24df4d4f5fe4547750 +++ /dev/null @@ -1,3 +0,0 @@ -xQ -!@sBQ" ٱ r{ - val = o[prop] - o[prop] = "foo" - o[prop].should.equal val - delete o[prop] - should.exist o[prop] - o[prop].should.equal val