<commit_before>var fs = require("q-io/fs"),
    q = require("q"),
    git = require("gift-wrapper"),
    generate = require("./generate.js"),
    exec = require('child_process').exec;

var repoDir = __dirname + "/../"
var credentialFilePath = repoDir + ".git/credentials";
var repo = git(repoDir);

function setAuthConfig(){
  var deferred = q.defer();
  exec('git config credential.helper "store --file=' + credentialFilePath + '"', 
    {
        cwd: repoDir,
        encoding: "utf8",
        maxBuffer: 5000 * 1024
    },
    function(err){
      if(err){
        return deferred.reject(err);
      }
      
      return deferred.resolve();
    }
  );
  
  return deferred.promise;
};

function publishChanges(github_personal_access_token){
  return setAuthConfig()
  .then(function(){
    var content = "https://" + github_personal_access_token + ":@github.com"
    return fs.write(credentialFilePath, content);
  })
  .then(function(){
    return repo.identify({name: "zpbappi", email: "<EMAIL>"});
  })
  .then(function(){
    console.log("Adding all files...");
    return repo.add("-A");
  })  
  .then(function(){
    console.log("Committing changes...");
    return repo.commit("[ci skip] automated tag and archive page generation");
  }).
  then(function(){
    console.log("Pushing changes...");
    return repo.remote_push("origin", "master");
  });
};


// the main entry point
generate()
.then(function(){
  return repo.status();
})
.then(function(status){
  console.log(status);
  if(!status.clean){
    return publishChanges(process.env.GH_TOKEN);
  }
})
.fail(console.error);<commit_msg>added post push status logging<commit_after>var fs = require("q-io/fs"),
    q = require("q"),
    git = require("gift-wrapper"),
    generate = require("./generate.js"),
    exec = require('child_process').exec;

var repoDir = __dirname + "/../"
var credentialFilePath = repoDir + ".git/credentials";
var repo = git(repoDir);

function setAuthConfig(){
  var deferred = q.defer();
  exec('git config credential.helper "store --file=' + credentialFilePath + '"', 
    {
        cwd: repoDir,
        encoding: "utf8",
        maxBuffer: 5000 * 1024
    },
    function(err){
      if(err){
        return deferred.reject(err);
      }
      
      return deferred.resolve();
    }
  );
  
  return deferred.promise;
};

function publishChanges(github_personal_access_token){
  return setAuthConfig()
  .then(function(){
    var content = "https://" + github_personal_access_token + ":@github.com"
    return fs.write(credentialFilePath, content);
  })
  .then(function(){
    return repo.identify({name: "zpbappi", email: "<EMAIL>"});
  })
  .then(function(){
    console.log("Adding all files...");
    return repo.add("-A");
  })  
  .then(function(){
    console.log("Committing changes...");
    return repo.commit("[ci skip] automated tag and archive page generation");
  })
  .then(function(){
    console.log("Pushing changes...");
    return repo.remote_push("origin", "master");
  })
  .then(function(){
    console.log("Printing post push status...");
    return repo.status().then(console.log);
  })
};


// the main entry point
generate()
.then(function(){
  return repo.status();
})
.then(function(status){
  console.log(status);
  if(!status.clean){
    return publishChanges(process.env.GH_TOKEN);
  }
})
.fail(console.error);
{'fraction_non_alphanumeric': 0.17592592592592593, 'fraction_numerical': 0.005376344086021506, 'mean_word_length': 3.299101412066752, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3168169', 'n_tokens_mistral': 1072, 'n_tokens_neox': 1043, 'n_words': 218}