Skip to content

Conversation

@pedrogaudencio
Copy link
Collaborator

@pedrogaudencio pedrogaudencio commented Feb 5, 2026

Uses time of article file modification (upon being imported with wiki2md tool) as first commit timestamp upon Wikipedia article creation.

Following discussion in /pull/127 and @eighttrigrams's suggestion.


Open with Devin

@pedrogaudencio pedrogaudencio self-assigned this Feb 5, 2026
@pedrogaudencio pedrogaudencio force-pushed the fetched-timestamp-on-create-article-import branch from 3ce8223 to bf8dacb Compare February 9, 2026 17:21
@pedrogaudencio pedrogaudencio marked this pull request as ready for review February 9, 2026 17:22
Copilot AI review requested due to automatic review settings February 9, 2026 17:22
@pedrogaudencio pedrogaudencio changed the title Use file modification for commit timestamps on article import wiki2md: use file modification for commit timestamps on article import Feb 9, 2026
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the article-creator service to set the initial commit timestamp for imported Wikipedia articles based on the source Markdown file’s modification time (as produced by wiki2md), aligning repository history with when the article was fetched/written to disk.

Changes:

  • Read the Markdown file’s filesystem modification time during import.
  • Pass that timestamp into README creation and use it for the commit’s author/committer dates.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@taoeffect
Copy link
Member

Great work @pedrogaudencio! Minor suggestion from Opus 4.6, you can take it or leave it (let me know!)

Details

The change is small and straightforward. I found one concrete issue and one minor simplification.


1. TOCTOU race and redundant syscall with os.Stat + os.ReadFile

  • main.go:253-261 (the new os.Stat call) followed by main.go:263 (os.ReadFile)

You stat the file to get ModTime, then separately open and read it. This is two syscalls on the same path, and there's a window where the file could be modified or replaced between the stat and the read, giving you a stale ModTime for different content. Open the file once instead:

func (c *giteaClient) processFile(filePath, username string, public bool) bool {
	c.stats.processed++

	fmt.Printf("\nProcessing: %s\n", filepath.Base(filePath))

	// Open file once to get both content and modification time
	f, err := os.Open(filePath)
	if err != nil {
		fmt.Printf("  ✗ Failed to open file: %v\n", err)
		c.stats.failed++
		return false
	}
	defer f.Close()

	fileInfo, err := f.Stat()
	if err != nil {
		fmt.Printf("  ✗ Failed to stat file: %v\n", err)
		c.stats.failed++
		return false
	}

	content, err := io.ReadAll(f)
	if err != nil {
		fmt.Printf("  ✗ Failed to read file: %v\n", err)
		c.stats.failed++
		return false
	}

	// ... rest of function, using fileInfo.ModTime() ...

This also eliminates the need for the intermediate fileModTime variable at what is currently line ~284 — just pass fileInfo.ModTime() directly to createReadmeFile.

Copy link
Member

@taoeffect taoeffect left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent!

@taoeffect taoeffect merged commit 9cb3d31 into master Feb 10, 2026
32 checks passed
@taoeffect taoeffect deleted the fetched-timestamp-on-create-article-import branch February 10, 2026 00:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants