Beispiel #1
0
        /**
         * Creates a new empty repository.
         *
         * @param bare
         *            true to create a bare repository; false to make a repository
         *            within its working directory
         * @return the newly created repository, opened for access
         * @throws IOException
         *             the repository could not be created in the temporary area
         */
        private Core.Repository createRepository(bool bare)
        {
            String        uniqueId   = GetType().Name + Guid.NewGuid().ToString();
            String        gitdirName = "test" + uniqueId + (bare ? "" : "/") + Constants.DOT_GIT;
            DirectoryInfo gitdir     = new DirectoryInfo(Path.Combine(trash.FullName, gitdirName));

            Core.Repository db = new Core.Repository(gitdir);

            Assert.IsFalse(gitdir.Exists);
            db.Create();
            toClose.Add(db);
            return(db);
        }
        /**
	 * Creates a new empty repository.
	 *
	 * @param bare
	 *            true to create a bare repository; false to make a repository
	 *            within its working directory
	 * @return the newly created repository, opened for access
	 * @throws IOException
	 *             the repository could not be created in the temporary area
	 */
        private Core.Repository createRepository(bool bare) {
            String uniqueId = GetType().Name + Guid.NewGuid().ToString();
            String gitdirName = "test" + uniqueId + (bare ? "" : "/") + ".git";
            DirectoryInfo gitdir = new DirectoryInfo(Path.Combine(trash.FullName, gitdirName));
            Core.Repository db = new Core.Repository(gitdir);

            Assert.IsFalse(gitdir.Exists);
            db.Create();
            toClose.Add(db);
            return db;
        }
Beispiel #3
0
        /// <summary>
        /// Do it.
        /// </summary>
        public override void Execute()
        {
            if (Source.Length <= 0)
            {
                throw new ArgumentException("fatal: You must specify a repository to clone.");
            }

            if (Directory != null && GitDirectory != null)
            {
                throw new ArgumentException("conflicting usage of --git-dir and arguments");
            }

            var source = new URIish(Source);

            if (Directory == null)
            {
                try
                {
                    Directory = source.getHumanishName();
                }
                catch (InvalidOperationException e)
                {
                    throw new ArgumentException("cannot guess local name from " + source, e);
                }
            }

            if (GitDirectory == null)
            {
                GitDirectory = Path.Combine(Directory, Constants.DOT_GIT);
            }

            if (Mirror)
                Bare = true;
            if (Bare)
            {
                if (OriginName != null)
                    throw new ArgumentException("Bare+Origin", "--bare and --origin " + OriginName + " options are incompatible.");
                NoCheckout = true;
            }
            if (OriginName == null)
                OriginName = Constants.DEFAULT_REMOTE_NAME;

            if (System.IO.Directory.Exists(Directory) && System.IO.Directory.GetFileSystemEntries(Directory).Length != 0)
            {
                throw new InvalidOperationException(string.Format("destination path '{0}' already exists and is not an empty directory.", new DirectoryInfo(Directory).FullName));
            }

            var repo = new Core.Repository(new DirectoryInfo(GitDirectory));
            repo.Create(Bare);
            repo.Config.setBoolean("core", null, "bare", Bare);
            repo.Config.save();
            Repository = new Repository(repo);
            if (!Quiet)
            {
                OutputStream.WriteLine("Initialized empty Git repository in " + repo.Directory.FullName);
                OutputStream.Flush();
            }

            saveRemote(source);

            FetchResult r;
            try
            {
                r = runFetch();
            }
            catch (NoRemoteRepositoryException)
            {
                Repository.Dispose();
                throw;
            }
            GitSharp.Core.Ref branch = guessHEAD(r);
            if (!NoCheckout)
                doCheckout(branch);
        }
Beispiel #4
0
        /// <summary>
        /// Do it.
        /// </summary>
        public override void Execute()
        {
            if (Source.Length <= 0)
            {
                throw new ArgumentException("fatal: You must specify a repository to clone.");
            }

            if (Directory != null && GitDirectory != null)
            {
                throw new ArgumentException("conflicting usage of --git-dir and arguments");
            }

            var source = new URIish(Source);

            if (Directory == null)
            {
                try
                {
                    Directory = source.getHumanishName();
                }
                catch (InvalidOperationException e)
                {
                    throw new ArgumentException("cannot guess local name from " + source, e);
                }
            }

            if (GitDirectory == null)
            {
                GitDirectory = Path.Combine(Directory, Constants.DOT_GIT);
            }

            if (Mirror)
            {
                Bare = true;
            }
            if (Bare)
            {
                if (OriginName != null)
                {
                    throw new ArgumentException("Bare+Origin", "--bare and --origin " + OriginName + " options are incompatible.");
                }
                NoCheckout = true;
            }
            if (OriginName == null)
            {
                OriginName = Constants.DEFAULT_REMOTE_NAME;
            }

            if (System.IO.Directory.Exists(Directory) && System.IO.Directory.GetFileSystemEntries(Directory).Length != 0)
            {
                throw new InvalidOperationException(string.Format("destination path '{0}' already exists and is not an empty directory.", new DirectoryInfo(Directory).FullName));
            }

            var repo = new Core.Repository(new DirectoryInfo(GitDirectory));

            repo.Create(Bare);
            repo.Config.setBoolean("core", null, "bare", Bare);
            repo.Config.save();
            Repository = new Repository(repo);
            if (!Quiet)
            {
                OutputStream.WriteLine("Initialized empty Git repository in " + repo.Directory.FullName);
                OutputStream.Flush();
            }

            saveRemote(source);

            FetchResult r;

            try
            {
                r = runFetch();
            }
            catch (NoRemoteRepositoryException)
            {
                Repository.Dispose();
                throw;
            }
            GitSharp.Core.Ref branch = guessHEAD(r);
            if (!NoCheckout)
            {
                doCheckout(branch);
            }
        }