src/SyncTool.Git/main/RepositoryAccess/RepositoryInitHelper.cs
/// <summary>
/// Initializes a new bare repository at the specified location, adds a repository info file to the root directory
/// and tags the initial commit with he value of <see cref="InitialCommitTagName"/>
/// </summary>
Initializes a new bare repository at the specified location, adds a repository info file to the root directory
and tags the initial commit with he value of
Initializes a new bare repository at the specified location adds a repository info file to the root directory and tags the initial commit with he value of
public static void InitializeRepository(string location)
        {            
            Repository.Init(location, true);
            var directoryCreator = new LocalItemCreator();
            using (var tempDirectory = directoryCreator.CreateTemporaryDirectory())
            {
                var clonedRepoPath = Repository.Clone(location, tempDirectory.Directory.Location);
                var repositoryInfoFile = new RepositoryInfoFile(tempDirectory.Directory);
                directoryCreator.CreateFile(repositoryInfoFile, tempDirectory.Directory.Location);
                using (var clonedRepo = new Repository(clonedRepoPath))
                {
                    var signature = SignatureHelper.NewSignature();
                    Commands.Stage(clonedRepo, repositoryInfoFile.Name);                    
                    clonedRepo.Commit("Initial Commit", signature, signature, new CommitOptions());                    
                    clonedRepo.Network.Push(clonedRepo.Network.Remotes["origin"], @"refs/heads/master");                    
                }
            }
            using (var repository = new Repository(location))
            {
                repository.CreateBranch(ConfigurationBranchName.ToString(), repository.GetAllCommits().Single());
                repository.Tags.Add(InitialCommitTagName, repository.GetAllCommits().Single());
            }
        }
public static void InitializeRepository ( string location ) { Repository . Init ( location , true ) ; var directoryCreator = new LocalItemCreator ( ) ; using ( var tempDirectory = directoryCreator . CreateTemporaryDirectory ( ) ) { var clonedRepoPath = Repository . Clone ( location , tempDirectory . Directory . Location ) ; var repositoryInfoFile = new RepositoryInfoFile ( tempDirectory . Directory ) ; directoryCreator . CreateFile ( repositoryInfoFile , tempDirectory . Directory . Location ) ; using ( var clonedRepo = new Repository ( clonedRepoPath ) ) { var signature = SignatureHelper . NewSignature ( ) ; Commands . Stage ( clonedRepo , repositoryInfoFile . Name ) ; clonedRepo . Commit ( " " , signature , signature , new CommitOptions ( ) ) ; clonedRepo . Network . Push ( clonedRepo . Network . Remotes [ " " ] , @"refs/heads/master" ) ; } } using ( var repository = new Repository ( location ) ) { repository . CreateBranch ( ConfigurationBranchName . ToString ( ) , repository . GetAllCommits ( ) . Single ( ) ) ; repository . Tags . Add ( InitialCommitTagName , repository . GetAllCommits ( ) . Single ( ) ) ; } }
Initializes a new bare repository at the specified location, adds a repository info file to the root directory
and tags the initial commit with he value of
Initializes a new bare repository at the specified location adds a repository info file to the root directory and tags the initial commit with he value of
// initialize a bare repository // clone the repository, add initial commit and push the changes back to the actual repository // add a empty file to the repository // commit and push the file to the bare repository we created //create the configuration branch pointing to the initial commit
location
string