Example #1
0
        public static bool CreateBackup(string repoFolder, string comment, GitRemoteOptions _gitRemoteOptions)
        {
            //var repoFolder = relativeFolder + "/" + name;
            using (var repo = new Repository(repoFolder)) {
                try
                {
                    var opt = new StageOptions();
                    Commands.Stage(repo, "*");
                    var sig = new Signature("maci-auto-committer", "*****@*****.**", DateTimeOffset.Now);
                    repo.Commit(comment, sig, sig);

                    // Push to remote (e.g. Github) if the repo has a configured remote called "origin"
                    Remote remote = repo.Network.Remotes["origin"];
                    if (remote != null)
                    {
                        var options = new PushOptions();
                        options.CredentialsProvider = (_url, _user, _cred) =>
                                                      new UsernamePasswordCredentials
                        {
                            Username = _gitRemoteOptions.Username,
                            Password = _gitRemoteOptions.AccessToken
                        };
                        repo.Network.Push(remote, @"refs/heads/master", options);
                    }
                } catch (EmptyCommitException e)
                {
                    return(false);
                }
            }
            return(true);
        }
Example #2
0
        public ExperimentFileController(ApplicationDbContext context, IMapper mapper,
                                        DirectoryOptions directoryOptions, IOptions <GitRemoteOptions> gitRemoteOptions)
        {
            _context          = context;
            _mapper           = mapper;
            _directoryOptions = directoryOptions;
            _gitRemoteOptions = gitRemoteOptions.Value;

            relativeFolder = _directoryOptions.DataLocation + "/ExperimentTemplates";
        }
        public ExperimentFrameworkController(DirectoryOptions directoyOptions, ILogger <ExperimentFrameworkController> logger,
                                             IOptions <GitRemoteOptions> gitRemoteOptions)
        {
            _directoyOptions  = directoyOptions;
            _logger           = logger;
            _gitRemoteOptions = gitRemoteOptions.Value;

            globalpath   = directoyOptions.DataLocation + "/ExperimentFramework";
            projectpath  = directoyOptions.DataLocation + "/ExperimentTemplates";
            datalocation = directoyOptions.DataLocation;
        }