Skip to content

Instantly share code, notes, and snippets.

@rashkopetrov
Last active June 12, 2016 13:52
Show Gist options
  • Save rashkopetrov/3d6990a7e1d60d0b81c43ba40f7e11af to your computer and use it in GitHub Desktop.
Save rashkopetrov/3d6990a7e1d60d0b81c43ba40f7e11af to your computer and use it in GitHub Desktop.
Cheating - Git Commit By Date
<?php
function getPostValue( $name ) {
if ( empty( $_POST[ $name ] ) ) {
return '';
}
return $_POST[ $name ];
}
function printOldValue( $name = '' ) {
print getPostValue( $name );
}
function printCommitCode() {
$date = getPostValue( 'date' );
if ( ! $date ) {
$date = date('Y-m-d');
}
$time = getPostValue( 'time' );
if ( ! $time ) {
$time = date('H:i:s');
}
$message = getPostValue( 'commit-message' );
if ( ! $message ) {
$message = 'something cool';
}
$commitDate = $date . 'T' . $time;
echo "GIT_AUTHOR_DATE={$commitDate} GIT_COMMITTER_DATE={$commitDate} git commit -a -m \"{$message}\" ";
}
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<link rel="stylesheet" href="//jonthornton.github.io/jquery-timepicker/jquery.timepicker.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script src="//jonthornton.github.io/jquery-timepicker/jquery.timepicker.js"></script>
<style type="text/css">
* { padding: 0; margin: 0; outline: 0; }
form {}
form label { padding: 10px; margin-right: 10px; }
form input,
form button,
form textarea { padding: 5px; }
form input { width: 200px; }
form textarea { width: 200px; height: 75px; resize: none; }
table {}
table th,
table td { padding: 5px; }
code { display: block; padding: 20px; margin: 20px 0; }
</style>
<script>
$(function() {
$( "#date" ).datepicker({ dateFormat: "yy-mm-dd" });
$( "#time" ).timepicker({ timeFormat: 'H:i:s' });
});
</script>
</head>
<body>
<form method="post">
<table>
<tr>
<td>
<label for="date">Date: </label>
</td>
<td>
<input type="text" id="date" name="date" value="<?php printOldValue( 'date' ) ?>">
</td>
</tr>
<tr>
<td>
<label for="time">Time: </label>
</td>
<td>
<input type="text" id="time" name="time" value="<?php printOldValue( 'time' ) ?>">
</td>
</tr>
<tr>
<td>
<label for="commit-message">Commit Message: </label>
</td>
<td>
<textarea id="commit-message" name="commit-message"><?php printOldValue( 'commit-message' ) ?></textarea>
</td>
</tr>
<tr>
<td colspan="2">
<button>Get Code</button>
</td>
</tr>
</table>
</form>
<code><?php printCommitCode() ?></code>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment