コード例 #1
0
ファイル: NodeSiteBuilder.cs プロジェクト: lookworld/kudu
 private void SafeCleanWebConfig(DeploymentContext context)
 {
     try
     {
         var git = new GitExecutable(Environment.RepositoryPath, DeploymentSettings.GetCommandIdleTimeout());
         string webConfigPath = Path.Combine(ProjectPath, "web.config");
         git.Execute("clean -f " + webConfigPath);
     }
     catch (Exception ex)
     {
         context.Logger.Log(ex);
     }
 }
コード例 #2
0
ファイル: NodeSiteBuilder.cs プロジェクト: plurby/kudu
        private void SafeCleanWebConfig(DeploymentContext context)
        {
            try
            {
                var git = new GitExecutable(Environment.RepositoryPath, DeploymentSettings.GetCommandIdleTimeout());
                string webConfigPath = Path.Combine(ProjectPath, "web.config");

                if (!String.IsNullOrEmpty(HomePath))
                {
                    git.SetHomePath(HomePath);
                }

                git.Execute("clean -f " + webConfigPath);
            }
            catch (Exception ex)
            {
                context.Tracer.TraceError(ex);
            }
        }
コード例 #3
0
 private string Execute(ITracer tracer, string arguments, params object[] args)
 {
     return(_gitExe.Execute(tracer, arguments, args).Item1);
 }
コード例 #4
0
 private void Advertise(ITracer tracer, string serviceName, Stream output)
 {
     _gitExe.Execute(tracer, null, output, @"{0} --stateless-rpc --advertise-refs ""{1}""", serviceName, _gitExe.WorkingDirectory);
 }
コード例 #5
0
        public void Initialize()
        {
            var profiler = _tracerFactory.GetTracer();

            using (profiler.Step("GitExeRepository.Initialize"))
            {
                _gitExe.Execute(profiler, "init");

                _gitExe.Execute(profiler, "config core.autocrlf true");

                // This speeds up git operations like 'git checkout', especially on slow drives like in Azure
                _gitExe.Execute(profiler, "config core.preloadindex true");

                _gitExe.Execute(profiler, @"config user.name ""{0}""", _settings.GetGitUsername());

                _gitExe.Execute(profiler, @"config user.email ""{0}""", _settings.GetGitEmail());

                using (profiler.Step("Configure git server"))
                {
                    // Allow getting pushes even though we're not bare
                    _gitExe.Execute(profiler, "config receive.denyCurrentBranch ignore");
                }

                // to disallow browsing to this folder in case of in-place repo
                using (profiler.Step("Create deny users for .git folder"))
                {
                    string content = "<?xml version=\"1.0\"" + @"?>
<configuration>
  <system.web>
    <authorization>
      <deny users=" + "\"*\"" + @"/>
    </authorization>
  </system.web>
<configuration>";

                    File.WriteAllText(Path.Combine(_gitExe.WorkingDirectory, ".git", "web.config"), content);
                }

                // Server env does not support interactive cred prompt; hence, we intercept any credential provision
                // for git fetch/clone with http/https scheme and return random invalid u/p forcing 'fatal: Authentication failed.'
                using (profiler.Step("Configure git-credential"))
                {
                    FileSystemHelpers.EnsureDirectory(Path.GetDirectoryName(GitCredentialHookPath));

                    string content = @"#!/bin/sh
if [ " + "\"$1\" = \"get\"" + @" ]; then
      echo username=dummyUser
      echo password=dummyPassword
fi" + "\n";

                    File.WriteAllText(GitCredentialHookPath, content);

                    _gitExe.Execute(profiler, "config credential.helper !'{0}'", GitCredentialHookPath);
                }

                using (profiler.Step("Setup post receive hook"))
                {
                    FileSystemHelpers.EnsureDirectory(Path.GetDirectoryName(PostReceiveHookPath));

                    string content = @"#!/bin/sh
read i
echo $i > pushinfo
" + KnownEnvironment.KUDUCOMMAND + "\n";

                    File.WriteAllText(PostReceiveHookPath, content);
                }

                // NOTE: don't add any new init steps after creating the post receive hook,
                // as it's also used to mark that Init was fully executed
            }
        }