src/com/darkyen/GitIntegration.java
/*
	Git version time file format:
	Three lines:
	 1. Number of counted seconds (for tracking purposes of the plugin)
	 2. Formatted first number
	 3. Formatted 0 seconds (line 2 is reset to this when commit is made)
	 */
Git version time file format:
Three lines:
1. Number of counted seconds (for tracking purposes of the plugin)
2. Formatted first number
3. Formatted 0 seconds (line 2 is reset to this when commit is made)
Git version time file format : Three lines : 1 . Number of counted seconds ( for tracking purposes of the plugin ) 2 . Formatted first number 3 . Formatted 0 seconds ( line 2 is reset to this when commit is made )
void updateVersionTimeFile (long versionSeconds, @NotNull final TimePattern gitTimePattern) {
		final Application application = ApplicationManager.getApplication();
		application.invokeLater( () -> {
			if (!Files.isDirectory(gitDirectory)) {
				return;
			}
			final Path timeFile = timeFile();
			long existingSeconds = 0;
			{
				String countedSecondsLine = null;
				if (Files.exists(timeFile)) {
					try (final BufferedReader reader = new BufferedReader(Files
							.newBufferedReader(timeFile, StandardCharsets.UTF_8))) {
						countedSecondsLine = reader.readLine();
					} catch (IOException e) {
						LOG.log(Level.WARNING, "Failed to read git time file", e);
					}
				}
				try {
					if (countedSecondsLine != null) {
						existingSeconds = Long.parseLong(countedSecondsLine);
					}
				} catch (NumberFormatException ignored) {
					LOG.log(Level.WARNING, "Git time file did not contain only numbers: \"" + countedSecondsLine + "\"");
				}
			}
			final long newSeconds = versionSeconds == TimeTrackerService.RESET_TIME_TO_ZERO ? 0 : Math.max(0, existingSeconds + versionSeconds);
			try (final BufferedWriter out = Files.newBufferedWriter(timeFile, StandardCharsets.UTF_8)) {
				out.write(Long.toString(newSeconds));
				out.write('\n');
				out.write(gitTimePattern.secondsToString((int)newSeconds));
				out.write('\n');
				out.write(gitTimePattern.secondsToString(0));
				out.write('\n');
			} catch (IOException e) {
				LOG.log(Level.SEVERE, "Error while writing git time file", e);
			}
		}, ModalityState.NON_MODAL);
	}
void updateVersionTimeFile ( long versionSeconds , @ NotNull final TimePattern gitTimePattern ) { final Application application = ApplicationManager . getApplication ( ) ; application . invokeLater ( ( ) -> { if ( ! Files . isDirectory ( gitDirectory ) ) { return ; } final Path timeFile = timeFile ( ) ; long existingSeconds = 0 ; { String countedSecondsLine = null ; if ( Files . exists ( timeFile ) ) { try ( final BufferedReader reader = new BufferedReader ( Files . newBufferedReader ( timeFile , StandardCharsets . UTF_8 ) ) ) { countedSecondsLine = reader . readLine ( ) ; } catch ( IOException e ) { LOG . log ( Level . WARNING , "Failed to read git time file" , e ) ; } } try { if ( countedSecondsLine != null ) { existingSeconds = Long . parseLong ( countedSecondsLine ) ; } } catch ( NumberFormatException ignored ) { LOG . log ( Level . WARNING , "Git time file did not contain only numbers: \"" + countedSecondsLine + "\"" ) ; } } final long newSeconds = versionSeconds == TimeTrackerService . RESET_TIME_TO_ZERO ? 0 : Math . max ( 0 , existingSeconds + versionSeconds ) ; try ( final BufferedWriter out = Files . newBufferedWriter ( timeFile , StandardCharsets . UTF_8 ) ) { out . write ( Long . toString ( newSeconds ) ) ; out . write ( '\n' ) ; out . write ( gitTimePattern . secondsToString ( ( int ) newSeconds ) ) ; out . write ( '\n' ) ; out . write ( gitTimePattern . secondsToString ( 0 ) ) ; out . write ( '\n' ) ; } catch ( IOException e ) { LOG . log ( Level . SEVERE , "Error while writing git time file" , e ) ; } } , ModalityState . NON_MODAL ) ; }
Git version time file format:
Three lines:
1.
Git version time file format : Three lines : 1 .