This code defines a function that compares two specific Git commits within a project, outputs the differences to a directory, and utilizes Gulp and Promises for task management.
npm run import -- "Display graphs of different commands and scenarios using dry-run"
var path = require('path');
var gulp = require('gulp');
var run = require('gulp-run');
var tap = require('gulp-tap');
var importer = require('../Core');
var gulpPromise = importer.import("gulp task to a Promise",
"{gulp}")
var PROFILE_PATH = process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE || '';
var project = typeof project === 'undefined' ? path.join(PROFILE_PATH, 'Documents/portal') : project;
function getBranchBoundaries(p) {
if(p) {
project = p;
}
gulp.task('git watch', function () {
return run('git diff -w a229417..498d5a5', {cwd: project})
.pipe(tap(file => console.log(file)))
.pipe(gulp.dest('output'))
});
return gulpPromise(['git watch'])
}
module.exports = getBranchBoundaries;
if(typeof $ !== 'undefined') {
$.async();
getBranchBoundaries(project)
.then(r => $.sendResult(r))
.catch(e => $.sendError(e))
}
const path = require('path');
const gulp = require('gulp');
const run = require('gulp-run');
const tap = require('gulp-tap');
const importer = require('../Core');
const gulpPromise = importer.import('gulp task to a Promise', {gulp});
const PROFILE_PATH = process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE || '';
const DEFAULT_PROJECT_PATH = path.join(PROFILE_PATH, 'Documents/portal');
const PROJECT_PATH = process.env.PROJECT_PATH || DEFAULT_PROJECT_PATH;
gulp.task('git-watch', function () {
return run(`git diff -w ${process.env.GIT_BRANCH_START_SHA}..${process.env.GIT_BRANCH_END_SHA}`, {cwd: PROJECT_PATH})
.pipe(tap(file => console.log(file)))
.pipe(gulp.dest('output'));
});
module.exports = function getBranchBoundaries(p = PROJECT_PATH) {
// Get project path from environment variable if provided, otherwise use default value
if (p) {
PROJECT_PATH = p;
}
// Return a promise that resolves when the 'git-watch' task is completed
return gulpPromise(['git-watch']);
};
if (typeof $!== 'undefined') {
$.async();
getBranchBoundaries().then(r => $.sendResult(r)).catch(e => $.sendError(e));
}
This code defines a function getBranchBoundaries
that executes a Git command to compare two specific commits within a project and outputs the differences to a "output" directory.
Here's a breakdown:
Imports:
gulpPromise
to convert a Gulp task into a Promise.Configuration:
PROFILE_PATH
to the user's home directory.project
path based on an environment variable or a default value.getBranchBoundaries
Function:
p
parameter to override the project
path.a229417
and 498d5a5
within the specified project directory.tap
stream to log each file to the console.gulpPromise
to convert the Gulp task into a Promise.Execution:
$
variable is defined (likely indicating a testing environment), it executes the getBranchBoundaries
function, sends the result to $.sendResult
, and handles any errors using $.sendError
.In essence, this code provides a way to compare two Git commits within a project and visualize the differences using Gulp and a custom Promise-based task execution mechanism.